remove glass block selection logic and related configuration options

This commit is contained in:
seb
2026-05-16 05:26:10 +02:00
parent afcec3d799
commit 4afd604605
3 changed files with 3 additions and 59 deletions

View File

@@ -27,10 +27,7 @@ public class Configs implements IConfigHandler {
"Do auto trading with villagers in range");
public static final ConfigBoolean ITEM_FRAME = new ConfigBoolean("selectUsingItemFrame", true,
"Select buy/sell items with item frames (max. distance 3) with items nametagged \"buy\" or \"sell\"");
public static final ConfigBoolean GLASS_BLOCK = new ConfigBoolean("selectUsingGlassBlock", false,
"Select input and output containers by placing red (input) and blue (output) stained glass blocks <selectionBlockOffset> blocks above them (or below if negative)");
public static final ConfigInteger SELECTOR_OFFSET = new ConfigInteger("selectionBlockOffset", 3, -10, 10,
"x Blocks below a red stained glass block will be input container, x Blocks below a blue stained glass block will be output container (or above, if x is negative)");
public static final ConfigBoolean ENABLE_SELL = new ConfigBoolean("enableSell", false,
"Enable selling (if disabled emeralds are taken from the input container)");
public static final ConfigString SELL_ITEM = new ConfigString("sellItem", "minecraft:gold_ingot",
@@ -68,8 +65,8 @@ public class Configs implements IConfigHandler {
public static final ConfigString SELECTED_ENCHANTMENTS = new ConfigString("selectedEnchantments", "",
"Comma-separated list of selected enchantment IDs (set via the \"Select Enchantments\" button on a librarian's trade screen)");
public static final ImmutableList<IConfigValue> OPTIONS = ImmutableList.of(ENABLED, ITEM_FRAME, GLASS_BLOCK,
SELECTOR_OFFSET, ENABLE_SELL, SELL_ITEM, SELL_LIMIT, ENABLE_BUY, BUY_ITEM, BUY_LIMIT, MAX_INPUT_ITEMS,
public static final ImmutableList<IConfigValue> OPTIONS = ImmutableList.of(ENABLED, ITEM_FRAME,
ENABLE_SELL, SELL_ITEM, SELL_LIMIT, ENABLE_BUY, BUY_ITEM, BUY_LIMIT, MAX_INPUT_ITEMS,
INPUT_CONTAINER_X, INPUT_CONTAINER_Y, INPUT_CONTAINER_Z, OUTPUT_CONTAINER_X, OUTPUT_CONTAINER_Y,
OUTPUT_CONTAINER_Z, VOID_TRADING_DELAY, VOID_TRADING_DELAY_AFTER_TELEPORT, CONTAINER_CLOSE_DELAY,
SHOW_TRADES, SELECTED_ENCHANTMENTS);

View File

@@ -43,7 +43,6 @@ final class AutoTradeClientTick {
return;
}
AutoTradeConfigSelectors.tickGlassBlockSelection(mc);
AutoTradeConfigSelectors.tickItemFrameSelection(mc);
merchantScreenTick.tickDeferredResultQuickMove(mc);

View File

@@ -4,7 +4,6 @@ import com.github.sebseb7.autotrade.config.Configs;
import fi.dy.masa.malilib.gui.Message.MessageType;
import fi.dy.masa.malilib.util.InfoUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
@@ -12,57 +11,6 @@ final class AutoTradeConfigSelectors {
private AutoTradeConfigSelectors() {}
static void tickGlassBlockSelection(Minecraft mc) {
if (!Configs.Generic.GLASS_BLOCK.getBooleanValue()) return;
int playerX = (int) mc.player.getX();
int playerZ = (int) mc.player.getZ();
int playerY = (int) mc.player.getY();
int selectorOffset = Configs.Generic.SELECTOR_OFFSET.getIntegerValue();
int absSelectorOffset = Math.abs(selectorOffset);
var redGlass = net.minecraft.world.level.block.Blocks.RED_STAINED_GLASS;
var blueGlass = net.minecraft.world.level.block.Blocks.BLUE_STAINED_GLASS;
for (int x = playerX - (absSelectorOffset + 3); x < playerX + (absSelectorOffset + 3); x++) {
for (int z = playerZ - (absSelectorOffset + 3); z < playerZ + (absSelectorOffset + 3); z++) {
for (int y = playerY - (absSelectorOffset + 3); y < playerY + (absSelectorOffset + 3); y++) {
BlockPos pos = new BlockPos(x, y, z);
if (mc.level.getBlockState(pos).getBlock() == redGlass) {
updateInputContainerPos(x, y, z, selectorOffset);
break;
}
if (mc.level.getBlockState(pos).getBlock() == blueGlass) {
updateOutputContainerPos(x, y, z, selectorOffset);
break;
}
}
}
}
}
private static void updateInputContainerPos(int x, int y, int z, int selectorOffset) {
if (x != Configs.Generic.INPUT_CONTAINER_X.getIntegerValue()
|| (y - selectorOffset) != Configs.Generic.INPUT_CONTAINER_Y.getIntegerValue()
|| z != Configs.Generic.INPUT_CONTAINER_Z.getIntegerValue()) {
Configs.Generic.INPUT_CONTAINER_X.setIntegerValue(x);
Configs.Generic.INPUT_CONTAINER_Y.setIntegerValue(y - selectorOffset);
Configs.Generic.INPUT_CONTAINER_Z.setIntegerValue(z);
InfoUtils.showGuiOrInGameMessage(MessageType.INFO,
"autotrade.message.input_container_set", x, y - selectorOffset, z);
}
}
private static void updateOutputContainerPos(int x, int y, int z, int selectorOffset) {
if (x != Configs.Generic.OUTPUT_CONTAINER_X.getIntegerValue()
|| (y - selectorOffset) != Configs.Generic.OUTPUT_CONTAINER_Y.getIntegerValue()
|| z != Configs.Generic.OUTPUT_CONTAINER_Z.getIntegerValue()) {
Configs.Generic.OUTPUT_CONTAINER_X.setIntegerValue(x);
Configs.Generic.OUTPUT_CONTAINER_Y.setIntegerValue(y - selectorOffset);
Configs.Generic.OUTPUT_CONTAINER_Z.setIntegerValue(z);
InfoUtils.showGuiOrInGameMessage(MessageType.INFO,
"autotrade.message.output_container_set", x, y - selectorOffset, z);
}
}
static void tickItemFrameSelection(Minecraft mc) {
if (!Configs.Generic.ITEM_FRAME.getBooleanValue()) return;
Vec3 pm = new Vec3(mc.player.getX(), mc.player.getY(), mc.player.getZ());