Skip to content

Commit

Permalink
add UnsafeConfig for ignore NBT
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Apr 27, 2024
1 parent 8be8351 commit 9d3e528
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class GeneralConfig implements IAPConfig {

LibConfig.build(builder);

builder.pop();
builder.push("Unsafe");

UnsafeConfig.build(builder);

builder.pop();

configSpec = builder.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package de.srendi.advancedperipherals.common.configuration;

import net.minecraftforge.common.ForgeConfigSpec;

public class UnsafeConfig {

private static ForgeConfigSpec.BooleanValue enableUnsafe;
private static ForgeConfigSpec.BooleanValue ignoreTurtlePeripheralItemNBT;

public static void build(final ForgeConfigSpec.Builder builder) {
enableUnsafe = builder.comment("By setting this value to true, I understand all operations below are danger to my adventure, and if they caused unexpected behaviour in my world, I will not consider it as AP's liability").define("enableUnsafe", false);
ignoreTurtlePeripheralItemNBT = builder.comment("Ignore turtle peripheral item's NBT when equipping. **YOU WILL LOST ALL NBT ON THE ITEM**").define("ignoreTurtlePeripheralItemNBT", false);
}

public static boolean enabled() {
return enableUnsafe.get();
}

public static boolean getIgnoreTurtlePeripheralItemNBT() {
return enabled() && ignoreTurtlePeripheralItemNBT.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.api.turtle.TurtleUpgradeType;
import de.srendi.advancedperipherals.common.configuration.UnsafeConfig;
import de.srendi.advancedperipherals.common.util.TranslationUtil;
import de.srendi.advancedperipherals.lib.peripherals.DisabledPeripheral;
import de.srendi.advancedperipherals.lib.peripherals.IBasePeripheral;
Expand Down Expand Up @@ -39,8 +40,11 @@ public IPeripheral createPeripheral(@NotNull ITurtleAccess turtle, @NotNull Turt
}

@Override
public boolean isItemSuitable(@NotNull ItemStack stack ) {
// always accept NBTed items
return true;
public boolean isItemSuitable(@NotNull ItemStack stack) {
if (UnsafeConfig.getIgnoreTurtlePeripheralItemNBT()) {
// always accept NBTed items
return true;
}
return super.isItemSuitable(stack);
}
}

0 comments on commit 9d3e528

Please sign in to comment.