From 62cd66a9f09a95f30cfd4984bb81588ed6f3131a Mon Sep 17 00:00:00 2001 From: noil Date: Sun, 28 Nov 2021 00:07:50 -0500 Subject: [PATCH] 3.1.8 finished, ModuleConfig supports List values --- .../seppuku/impl/config/ModuleConfig.java | 24 +++++++++++++++++++ .../seppuku/impl/fml/SeppukuMod.java | 2 +- .../impl/module/world/AutoToolModule.java | 16 +++++++------ .../impl/module/world/SpeedMineModule.java | 8 ++++--- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/config/ModuleConfig.java b/src/main/java/me/rigamortis/seppuku/impl/config/ModuleConfig.java index 21a1eb1..7ba40e9 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/config/ModuleConfig.java +++ b/src/main/java/me/rigamortis/seppuku/impl/config/ModuleConfig.java @@ -1,5 +1,6 @@ package me.rigamortis.seppuku.impl.config; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import me.rigamortis.seppuku.api.config.Configurable; import me.rigamortis.seppuku.api.module.Module; @@ -7,9 +8,12 @@ import me.rigamortis.seppuku.api.util.FileUtil; import me.rigamortis.seppuku.api.value.Regex; import me.rigamortis.seppuku.api.value.Shader; import me.rigamortis.seppuku.api.value.Value; +import net.minecraft.item.Item; import java.awt.*; import java.io.File; +import java.util.ArrayList; +import java.util.List; /** * @author noil @@ -73,6 +77,16 @@ public class ModuleConfig extends Configurable { val.setValue(new Regex(entry.getValue().getAsString())); } else if (val.getValue() instanceof Shader) { val.setValue(new Shader(entry.getValue().getAsString())); + } else if (val.getValue() instanceof List) { + List unknownList = (List) val.getValue(); + if (unknownList.stream().allMatch(o -> o instanceof Item)) { + List itemList = new ArrayList<>(); + JsonArray unknownArray = (JsonArray) entry.getValue(); + unknownArray.forEach(jsonElement -> { + itemList.add(Item.getItemById(jsonElement.getAsInt())); + }); + val.setValue(itemList); + } } } } @@ -109,6 +123,16 @@ public class ModuleConfig extends Configurable { moduleJsonObject.addProperty(value.getName(), ((Regex) value.getValue()).getPatternString()); } else if (value.getValue() instanceof Shader) { moduleJsonObject.addProperty(value.getName(), ((Shader) value.getValue()).getShaderID()); + } else if (value.getValue() instanceof List) { + List unknownList = (List) value.getValue(); + if (unknownList.stream().allMatch(o -> o instanceof Item)) { + List itemList = (List) unknownList; + JsonArray itemsJsonArray = new JsonArray(); + itemList.forEach(item -> { + itemsJsonArray.add(Item.getIdFromItem(item)); + }); + moduleJsonObject.add(value.getName(), itemsJsonArray); + } } }); } diff --git a/src/main/java/me/rigamortis/seppuku/impl/fml/SeppukuMod.java b/src/main/java/me/rigamortis/seppuku/impl/fml/SeppukuMod.java index c6d5846..4f049f2 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/fml/SeppukuMod.java +++ b/src/main/java/me/rigamortis/seppuku/impl/fml/SeppukuMod.java @@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; @Mod(modid = "seppukumod", name = "Seppuku", version = SeppukuMod.VERSION, certificateFingerprint = "7979b1d0446af2675fcb5e888851a7f32637fdb9") public final class SeppukuMod { - public static final String VERSION = "3.1.7"; + public static final String VERSION = "3.1.8"; /** * Our mods entry point diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/world/AutoToolModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/world/AutoToolModule.java index f2e56dd..54037fd 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/world/AutoToolModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/world/AutoToolModule.java @@ -19,13 +19,15 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; +import java.util.Objects; + /** - * Author Seth - * 4/24/2019 @ 3:04 PM. + * @author Seth + * @author noil */ public final class AutoToolModule extends Module { - public final Value silent = new Value("Silent", new String[]{"Sil"}, "Hold any item and spoof your mining tool. (Best tool must be in inventory)", false); + public final Value silent = new Value<>("Silent", new String[]{"Sil"}, "Hold any item and spoof your mining tool. (Best tool must be in inventory)", false); private boolean send; @@ -97,13 +99,13 @@ public final class AutoToolModule extends Module { } if (mc.player.isPotionActive(MobEffects.HASTE)) { - f *= 1.0F + (float) (mc.player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2F; + f *= 1.0F + (float) (Objects.requireNonNull(mc.player.getActivePotionEffect(MobEffects.HASTE)).getAmplifier() + 1) * 0.2F; } if (mc.player.isPotionActive(MobEffects.MINING_FATIGUE)) { float f1; - switch (mc.player.getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier()) { + switch (Objects.requireNonNull(mc.player.getActivePotionEffect(MobEffects.MINING_FATIGUE)).getAmplifier()) { case 0: f1 = 0.3F; break; @@ -199,7 +201,7 @@ public final class AutoToolModule extends Module { for (int i = 9; i < 36; i++) { final ItemStack stack = Minecraft.getMinecraft().player.inventoryContainer.getSlot(i).getStack(); - if (stack != null && stack != ItemStack.EMPTY) { + if (stack != ItemStack.EMPTY) { final float digSpeed = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, stack); final float destroySpeed = stack.getDestroySpeed(Minecraft.getMinecraft().world.getBlockState(pos)); @@ -220,7 +222,7 @@ public final class AutoToolModule extends Module { for (int i = 0; i <= 9; i++) { final ItemStack stack = Minecraft.getMinecraft().player.inventory.getStackInSlot(i); - if (stack != null && stack != ItemStack.EMPTY) { + if (stack != ItemStack.EMPTY) { final float digSpeed = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, stack); final float destroySpeed = stack.getDestroySpeed(Minecraft.getMinecraft().world.getBlockState(pos)); diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/world/SpeedMineModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/world/SpeedMineModule.java index 5feadd1..0f95f6c 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/world/SpeedMineModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/world/SpeedMineModule.java @@ -23,8 +23,10 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; import java.awt.*; /** - * Author Seth - * 4/24/2019 @ 12:16 PM. + * @author Seth (riga) + * @author noil + * @author hav0x1014 + * @author b2h990 */ public final class SpeedMineModule extends Module { @@ -42,7 +44,7 @@ public final class SpeedMineModule extends Module { public final Value reset = new Value("Reset", new String[]{"Res"}, "Stops current block destroy damage from resetting if enabled", true); public final Value doubleBreak = new Value("DoubleBreak", new String[]{"DoubleBreak", "Double", "DB"}, "Mining a block will also mine the block above it, if enabled", false); - public final Value auto = new Value("Auto", new String[]{}, "When enabled, allows for multi-mining blocks", false); + public final Value auto = new Value("Auto", new String[]{"MultiMine", "MM"}, "When enabled, allows for multi-mining blocks", false); public SpeedMineModule() { super("SpeedMine", new String[]{"FastMine"}, "Allows you to break blocks faster", "NONE", -1, ModuleType.WORLD);