Skip to content

Commit

Permalink
visitor drop protection might be done just need testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamKracker committed Nov 25, 2024
1 parent 33fa577 commit 07e820f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,17 @@ private void addFarmingConfig(CookiesTranslationBuilder translationBuilder) {
translationBuilder.add(CONFIG_FARMING_CATEGORIES_VISITORS, "Visitors");

translationBuilder.addConfig(CONFIG_FARMING_VISITOR_DROP_PROTECTION,
"Visitor rare drop protection",
"Rare drop protection",
"Prevents rejecting visitors with rare drops");

translationBuilder.addConfig(CONFIG_FARMING_VISITOR_NOT_AS_RARE_DROP_PROTECTION,
"Common drop protection",
"Prevents rejecting visitors with drops that are not as rare as the ones in the rare drop protection.");

translationBuilder.addConfig(CONFIG_FARMING_VISITOR_DROP_PROTECTION_DELAY,
"Drop protection delay",
"Delay in seconds before the visitor drop protection is removed.");

translationBuilder.add(CONFIG_FARMING_SQUEAKY_MOUSEMAT, "Squeaky Mousemat");
translationBuilder.addConfig(
CONFIG_FARMING_SQUEAKY_MOUSEMAT_OVERLAY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21.3 2024-11-24T03:51:20.3185333 cookies-mod/Language (en_us)
9cb85e4a915fdb8025789ef6ddcb6d46a31b3e21 assets\cookies-mod\lang\en_us.json
// 1.21.3 2024-11-24T23:20:19.0909311 cookies-mod/Language (en_us)
2a521080298e2164486e59634f522b9bdb6e7be3 assets\cookies-mod\lang\en_us.json
6 changes: 5 additions & 1 deletion src/main/generated/assets/cookies-mod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,14 @@
"cookies.config.farming.squeaky_mouse_mat.overlay.name": "Enabled overlay",
"cookies.config.farming.squeaky_mouse_mat.overlay.tooltip": "Enables an overlay for the squeaky mousemat where you can save yaw/pitch for every crop.",
"cookies.config.farming.tooltip": "Farming related settings.",
"cookies.config.farming.visitor_drop_protection.name": "Visitor rare drop protection",
"cookies.config.farming.visitor_drop_protection.name": "Rare drop protection",
"cookies.config.farming.visitor_drop_protection.tooltip": "Prevents rejecting visitors with rare drops",
"cookies.config.farming.visitor_drop_protection_delay.name": "Drop protection delay",
"cookies.config.farming.visitor_drop_protection_delay.tooltip": "Delay in seconds before the visitor drop protection is removed.",
"cookies.config.farming.visitor_material_helper.name": "Show visitor materials",
"cookies.config.farming.visitor_material_helper.tooltip": "Shows the amount of items a visitor needs down to the actual crop.",
"cookies.config.farming.visitor_not_as_rare_drop_protection.name": "Common drop protection",
"cookies.config.farming.visitor_not_as_rare_drop_protection.tooltip": "Prevents rejecting visitors with drops that are not as rare as the ones in the rare drop protection.",
"cookies.config.farming.yaw_pitch_display.name": "Yaw/Pitch display",
"cookies.config.farming.yaw_pitch_display.tooltip": "Displays your yaw/pitch on the screen (in a non obnoxious way).",
"cookies.config.helpers.anvil_helper.name": "Anvil Helper",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import codes.cookies.mod.config.system.Row;
import codes.cookies.mod.config.system.options.BooleanOption;
import codes.cookies.mod.config.system.options.EnumCycleOption;
import codes.cookies.mod.config.system.options.SliderOption;
import codes.cookies.mod.config.system.options.StringInputOption;
import codes.cookies.mod.config.system.options.TextDisplayOption;

import codes.cookies.mod.features.farming.garden.PestTimerHud;
Expand Down Expand Up @@ -47,7 +49,12 @@ public class FarmingConfig extends Category {
@Parent
public TextDisplayOption visitors = new TextDisplayOption(CONFIG_FARMING_CATEGORIES_VISITORS);

public BooleanOption visitorDropProtection = new BooleanOption(CONFIG_FARMING_VISITOR_DROP_PROTECTION, false);
public BooleanOption visitorRareDropProtection = new BooleanOption(CONFIG_FARMING_VISITOR_DROP_PROTECTION, true);

public BooleanOption visitorNotAsRareDropProtection = new BooleanOption(CONFIG_FARMING_VISITOR_NOT_AS_RARE_DROP_PROTECTION, false).onlyIf(visitorRareDropProtection);

//todo:
//public SliderOption<Integer> visitorDropProtectionDelay = SliderOption.integerOption(CONFIG_FARMING_VISITOR_DROP_PROTECTION_DELAY, 5).withMin(1).withMax(10).withStep(1).onlyIf(visitorRareDropProtection);

@Parent
public TextDisplayOption mousemat = new TextDisplayOption(CONFIG_FARMING_SQUEAKY_MOUSEMAT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ private void handleRejectButton(ItemStack rejectButton, boolean visitorItemLore)
}

CookiesUtils.sendMessage("Rejecting visitor drop protection");

rejectButton.set(CookiesDataComponentTypes.ITEM_CLICK_RUNNABLE, Runnables.doNothing());
new java.util.Timer().schedule(
new java.util.TimerTask() {
Expand All @@ -49,6 +48,7 @@ public void run() {
rejectButton.remove(CookiesDataComponentTypes.ITEM_CLICK_RUNNABLE);
}
},
//ConfigManager.getConfig().farmingConfig.visitorDropProtectionDelay.getValue()
5000
);
}
Expand All @@ -69,6 +69,14 @@ private boolean handleAcceptItem(ItemStack visitorItem)
}
}

if(ConfigManager.getConfig().farmingConfig.visitorNotAsRareDropProtection.getValue()) {
for (String commonDrop : commonDrops) {
if (text.getString().contains(commonDrop)) {
return true;
}
}
}

}
}

Expand All @@ -78,25 +86,28 @@ private boolean handleAcceptItem(ItemStack visitorItem)
private static final String[] rareDrops = new String[] {
"Bandana",
"Music",
"Candy",
"Biofuel", //
"Dedication",
"Jungle Key",
"Soul",
"Space",
"Harbinger",
"Overgrown Grass",
};

private static final String[] commonDrops = new String[] {
"Candy",
"Biofuel", //
"Pet Cake", //
"Fine Flour",
"Pelt",
"Soul",
"Space",
"Harbringer",
"Velvet",
"Cashmere",
"Satin",
"Oxford",
"Overgrown Grass",
"Powder",
};

public static void init() {
InventoryEvents.beforeInit("cookies-regex:.*", inv -> LocationUtils.Island.GARDEN.isActive() && ConfigManager.getConfig().farmingConfig.visitorDropProtection.getValue(), VisitorDropProtection::new);
InventoryEvents.beforeInit("cookies-regex:.*", inv -> LocationUtils.Island.GARDEN.isActive() && ConfigManager.getConfig().farmingConfig.visitorRareDropProtection.getValue(), VisitorDropProtection::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ public interface TranslationKeys {

String CONFIG_FARMING_CATEGORIES_VISITORS = CONFIG_FARMING + CATEGORIES_PART + ".visitors";
String CONFIG_FARMING_VISITOR_DROP_PROTECTION = CONFIG_FARMING + ".visitor_drop_protection";
String CONFIG_FARMING_VISITOR_NOT_AS_RARE_DROP_PROTECTION = CONFIG_FARMING + ".visitor_not_as_rare_drop_protection";
String CONFIG_FARMING_VISITOR_DROP_PROTECTION_DELAY = CONFIG_FARMING + ".visitor_drop_protection_delay";

String CONFIG_FARMING_SQUEAKY_MOUSEMAT = CONFIG_FARMING + ".squeaky_mouse_mat";
String CONFIG_FARMING_SQUEAKY_MOUSEMAT_OVERLAY = CONFIG_FARMING_SQUEAKY_MOUSEMAT + ".overlay";
Expand Down

0 comments on commit 07e820f

Please sign in to comment.