Skip to content

Commit

Permalink
3.1.8 finished, ModuleConfig supports List<Item> values
Browse files Browse the repository at this point in the history
  • Loading branch information
uoil committed Nov 28, 2021
1 parent eb7dd5c commit 62cd66a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
24 changes: 24 additions & 0 deletions src/main/java/me/rigamortis/seppuku/impl/config/ModuleConfig.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
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;
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
Expand Down Expand Up @@ -73,6 +77,16 @@ public void onLoad() {
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<Item> itemList = new ArrayList<>();
JsonArray unknownArray = (JsonArray) entry.getValue();
unknownArray.forEach(jsonElement -> {
itemList.add(Item.getItemById(jsonElement.getAsInt()));
});
val.setValue(itemList);
}
}
}
}
Expand Down Expand Up @@ -109,6 +123,16 @@ else if (value.getValue() instanceof Number && !(value.getValue() instanceof Enu
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<Item> itemList = (List<Item>) unknownList;
JsonArray itemsJsonArray = new JsonArray();
itemList.forEach(item -> {
itemsJsonArray.add(Item.getIdFromItem(item));
});
moduleJsonObject.add(value.getName(), itemsJsonArray);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
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<Boolean> silent = new Value<Boolean>("Silent", new String[]{"Sil"}, "Hold any item and spoof your mining tool. (Best tool must be in inventory)", false);
public final Value<Boolean> 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;

Expand Down Expand Up @@ -97,13 +99,13 @@ private float getDigSpeed(IBlockState state, BlockPos pos, ItemStack stack) {
}

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;
Expand Down Expand Up @@ -199,7 +201,7 @@ private int getToolInventory(BlockPos pos) {

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));

Expand All @@ -220,7 +222,7 @@ private int getToolHotbar(BlockPos pos) {

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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
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 {

Expand All @@ -42,7 +44,7 @@ private enum Mode {

public final Value<Boolean> reset = new Value<Boolean>("Reset", new String[]{"Res"}, "Stops current block destroy damage from resetting if enabled", true);
public final Value<Boolean> doubleBreak = new Value<Boolean>("DoubleBreak", new String[]{"DoubleBreak", "Double", "DB"}, "Mining a block will also mine the block above it, if enabled", false);
public final Value<Boolean> auto = new Value<Boolean>("Auto", new String[]{}, "When enabled, allows for multi-mining blocks", false);
public final Value<Boolean> auto = new Value<Boolean>("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);
Expand Down

0 comments on commit 62cd66a

Please sign in to comment.