Skip to content

Commit 7ec9bb0

Browse files
committed
Option to prevent accidental mapart rotation when using autoplace
1 parent 541f1d2 commit 7ec9bb0

5 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/main/java/net/evmodder/evmod/Configs.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static class Generic{
5757
public static final ConfigBoolean PLACEMENT_HELPER_MAPART_FROM_BUNDLE = new ConfigBoolean("placementHelperMapArtFromBundle", true).apply(GENERIC_KEY);
5858
public static final ConfigBooleanHotkeyed MAPART_AUTOPLACE = new ConfigBooleanHotkeyed("mapArtAutoPlace", true, "").apply(GENERIC_KEY);
5959
public static final ConfigInteger MAPART_AUTOPLACE_INV_DELAY = new ConfigInteger("mapArtAutoPlaceInvDelay", 3, 0, 20).apply(GENERIC_KEY);
60+
public static final ConfigBoolean MAPART_AUTOPLACE_ANTI_ROTATE = new ConfigBoolean("mapArtAutoPlaceAntiRotate", true).apply(GENERIC_KEY);
6061

6162
public static final ConfigBooleanHotkeyed MAPART_AUTOREMOVE = new ConfigBooleanHotkeyed("mapArtAutoRemove", true, "").apply(GENERIC_KEY);
6263
public static final ConfigInteger MAPART_AUTOREMOVE_AFTER = new ConfigInteger("mapArtAutoRemoveThreshold", 2, 1, 20).apply(GENERIC_KEY);
@@ -111,7 +112,7 @@ public static final List<IConfigBase> getOptions(){
111112
//PLACEMENT_HELPER_MAPART_REACH
112113
PLACEMENT_HELPER_MAPART_USE_NAMES, PLACEMENT_HELPER_MAPART_USE_IMAGE,
113114
PLACEMENT_HELPER_MAPART_FROM_BUNDLE));
114-
if(main.placementHelperMapArtAuto) availableOptions.addAll(List.of(MAPART_AUTOPLACE, MAPART_AUTOPLACE_INV_DELAY));
115+
if(main.placementHelperMapArtAuto) availableOptions.addAll(List.of(MAPART_AUTOPLACE, MAPART_AUTOPLACE_INV_DELAY, MAPART_AUTOPLACE_ANTI_ROTATE));
115116
}
116117
if(main.gameMessageListener) availableOptions.addAll(List.of(WHISPER_PLAY_SOUND, WHISPER_PEARL_PULL));
117118
if(main.cmdMapArtGroup) availableOptions.add(MAPART_GROUP_INCLUDE_UNLOCKED);

src/main/java/net/evmodder/evmod/keybinds/KeybindMapCopy.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ private void copyMapArtInBundles(final ArrayDeque<InvAction> clicks, final ItemS
288288
if(USE_TEMP_BUNDLE) clicks.add(new InvAction(tempBundleSlot, 1, ActionType.CLICK)); // Take map from temp bundle
289289
else{
290290
final int innerBundleSlot = BUNDLE_SELECT_REVERSE ? content.size()-1 : 0;
291-
// final int innerBundleSlot = BUNDLE_SELECT_REVERSE ? content.size()-(i+1) : i;
292-
// final int innerBundleSlot = BUNDLE_SELECT_REVERSE ? i : content.size()-(i+1);
293291
clicks.add(new InvAction(slotsWithBundles[entry.getKey()], innerBundleSlot, ActionType.BUNDLE_SELECT)); // Select 1st map in bundle
294292
clicks.add(new InvAction(slotsWithBundles[entry.getKey()], 1, ActionType.CLICK)); // Take map from src bundle
295293
}

src/main/java/net/evmodder/evmod/listeners/MapHandRestock.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,30 +506,37 @@ else if(isHotbarSlot){
506506
private ItemFrameEntity lastIfe;
507507
private ItemStack lastStack;
508508
public MapHandRestock(final boolean allowAutoPlacer){
509-
final AutoPlaceMapArt autoPlaceMapArt;
509+
final AutoPlaceMapArt autoPlacer;
510510
if(allowAutoPlacer){
511-
autoPlaceMapArt = new AutoPlaceMapArt();
512-
ClientTickEvents.END_CLIENT_TICK.register(client -> autoPlaceMapArt.placeNearestMap(client));
511+
autoPlacer = new AutoPlaceMapArt();
512+
ClientTickEvents.END_CLIENT_TICK.register(client -> autoPlacer.placeNearestMap(client));
513513
AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
514514
// if(mapAutoPlacer.isActive() && entity instanceof ItemFrameEntity ife && ife.getHeldItemStack().getItem() == Items.FILLED_MAP){
515-
if(autoPlaceMapArt.isActive()){
516-
autoPlaceMapArt.disableAndReset();
515+
if(autoPlacer.isActive()){
516+
autoPlacer.disableAndReset();
517517
Main.LOGGER.info("AutoPlaceMapArt: Disabling due to EntityAttackEvent");
518518
}
519519
return ActionResult.PASS;
520520
});
521521
}
522-
else autoPlaceMapArt = null;
522+
else autoPlacer = null;
523523

524524
UseEntityCallback.EVENT.register((player, _0, hand, entity, _1) -> {
525525
if(!(entity instanceof ItemFrameEntity ife)) return ActionResult.PASS;
526526
//Main.LOGGER.info("clicked item frame");
527527
if(hand != Hand.MAIN_HAND){
528-
Main.LOGGER.info("not main hand: "+hand.name());
528+
Main.LOGGER.info("MapHandRestock: not main hand: "+hand.name());
529529
// return ActionResult.FAIL;
530530
}
531-
//Main.LOGGER.info("placed item from offhand");
532-
if(!ife.getHeldItemStack().isEmpty()) return ActionResult.PASS;
531+
//Main.LOGGER.info("placed item from mainhand");
532+
if(!ife.getHeldItemStack().isEmpty()){
533+
if(allowAutoPlacer && Configs.Generic.MAPART_AUTOPLACE_ANTI_ROTATE.getBooleanValue() && autoPlacer.isActive()
534+
&& ife.getHeldItemStack().getItem() == Items.FILLED_MAP){
535+
Main.LOGGER.info("AutoPlaceMapArt: Ignoring a (likely accidental) map-rotation click");
536+
return ActionResult.FAIL;
537+
}
538+
return ActionResult.PASS;
539+
}
533540
//Main.LOGGER.info("item frame is empty");
534541
ItemStack stack = player.getMainHandStack();
535542
if(waitingForRestock && (stack.isEmpty() || stack.getItem() == Items.FILLED_MAP)){
@@ -544,7 +551,7 @@ public MapHandRestock(final boolean allowAutoPlacer){
544551

545552
UpdateInventoryHighlights.setCurrentlyBeingPlacedMapArt(player, stack);
546553

547-
if(autoPlaceMapArt.recalcIsActive(player, lastIfe, lastStack, ife, stack)){
554+
if(allowAutoPlacer && autoPlacer.recalcIsActive(player, lastIfe, lastStack, ife, stack)){
548555
Main.LOGGER.info("MapRestock: AutoPlaceMapArt is active, no need to handle restock");
549556
}
550557
else{

src/main/resources/assets/evmod/lang/en_us.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"evmod.config.generic.name.placementHelperMapArtFromBundle": "placementHelperMapArtFromBundle",
102102
"evmod.config.generic.name.mapArtAutoPlace": "mapArtAutoPlace",
103103
"evmod.config.generic.name.mapArtAutoPlaceInvDelay": "mapArtAutoPlaceInvDelay",
104+
"evmod.config.generic.name.mapArtAutoPlaceAntiRotate": "mapArtAutoPlaceAntiRotate",
104105
"evmod.config.generic.comment.placementHelperIFrame": "iFrame Helper - An item_frame auto placer",
105106
"evmod.config.generic.comment.placementHelperIFrameMustConnect": "iFrame Helper - Only place connecting iFrames",
106107
"evmod.config.generic.comment.placementHelperIFrameMustMatchBlock": "iFrame Helper - Only place on matching blocks",
@@ -109,6 +110,8 @@
109110
"evmod.config.generic.comment.pla cementHelperMapArtUseImage": "Predict-next-map using map image",
110111
"evmod.config.generic.comment.placementHelperMapArtFromBundle": "Allow mod to pull next-map prediction from bundles",
111112
"evmod.config.generic.comment.mapArtAutoPlace": "Auto-place ids for a mapart from your inventory",
113+
"evmod.config.generic.comment.mapArtAutoPlaceInvDelay": "How many ticks to wait between inventory actions",
114+
"evmod.config.generic.comment.mapArtAutoPlaceAntiRotate": "Disable rotating maparts in frames when AutoPlace is active (helps prevent accidental rotating with misclicks)",
112115

113116
"evmod.config.generic.name.hotbarSlotItemTypeScrollOrder": "hotbarSlotItemTypeScrollOrder",
114117
"evmod.config.generic.name.broadcastAccount": "broadcastAccount",

src/main/resources/assets/evmod/lang/es_ar.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"evmod.config.generic.name.placementHelperMapArtFromBundle": "placementHelperMapArtFromBundle",
9595
"evmod.config.generic.name.mapArtAutoPlace": "ayudante para mapart - AutoPlace",
9696
"evmod.config.generic.name.mapArtAutoPlaceInvDelay": "mapArtAutoPlaceInvDelay",
97+
"evmod.config.generic.name.mapArtAutoPlaceAntiRotate": "mapArtAutoPlaceAntiRotate",
9798
"evmod.config.generic.comment.placementHelperIFrame": "ayudante para colocar marco de items",
9899
"evmod.config.generic.comment.placementHelperIFrameMustConnect": "ayudante para marco de items - Solo coloca item frames conectados",
99100
"evmod.config.generic.comment.placementHelperIFrameMustMatchBlock": "ayudante para marco de items - solo coloca en bloques que coinciden",
@@ -102,6 +103,8 @@
102103
"evmod.config.generic.comment.placementHelperMapArtUseImage": "Precide el siguiente mapa usando la imagen",
103104
"evmod.config.generic.comment.placementHelperMapArtFromBundle": "Allow mod to pull next-map prediction from bundles",
104105
"evmod.config.generic.comment.mapArtAutoPlace": "coloca automaticamente mapas desde tu inventario",
106+
"evmod.config.generic.comment.mapArtAutoPlaceInvDelay": "How many ticks to wait between inventory actions",
107+
"evmod.config.generic.comment.mapArtAutoPlaceAntiRotate": "Disable rotating maparts in frames when AutoPlace is active (helps prevent accidental rotating with misclicks)",
105108

106109
"evmod.config.generic.name.hotbarSlotItemTypeScrollOrder": "hotbarSlotItemTypeScrollOrder",
107110
"evmod.config.generic.name.broadcastAccount": "broadcastAccount",

0 commit comments

Comments
 (0)