From 52de2fc59f526f67bba85ec58a4c788ab8965e75 Mon Sep 17 00:00:00 2001 From: vhd Date: Sun, 29 Dec 2019 21:48:00 +0200 Subject: [PATCH] Added configurable recycler blacklist (#1934) * Added configurable recycler blacklist. Defaulted to scrap and scrap_box * Fix for bronze dust centrifuge dupe --- .../machine/tier1/RecyclerBlockEntity.java | 32 +++++++++++++++++-- .../techreborn/config/TechRebornConfig.java | 6 ++++ .../recipes/centrifuge/bronze_dust.json | 4 +-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java index 3ac4df771..01028b53f 100644 --- a/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier1/RecyclerBlockEntity.java @@ -26,14 +26,17 @@ package techreborn.blockentity.machine.tier1; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.Direction; +import net.minecraft.util.registry.Registry; import reborncore.api.IToolDrop; import reborncore.api.blockentity.IUpgrade; import reborncore.api.blockentity.InventoryProvider; import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.ContainerBuilder; +import reborncore.common.blockentity.SlotConfiguration; import reborncore.common.blocks.BlockMachineBase; import reborncore.common.powerSystem.PowerAcceptorBlockEntity; import reborncore.common.util.RebornInventory; @@ -42,7 +45,7 @@ import techreborn.init.TRBlockEntities; import techreborn.init.TRContent; public class RecyclerBlockEntity extends PowerAcceptorBlockEntity - implements IToolDrop, InventoryProvider, IContainerProvider { + implements IToolDrop, InventoryProvider, IContainerProvider, SlotConfiguration.SlotFilter { private final RebornInventory inventory = new RebornInventory<>(3, "RecyclerBlockEntity", 64, this); private final int cost = 2; @@ -184,17 +187,40 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity return TRContent.Machine.RECYCLER.getStack(); } + @Override + public boolean isStackValid(int slotID, ItemStack stack) { + if (slotID == 0) { + return canRecycle(stack); + } + return false; + } + + @Override + public int[] getInputSlots() { + return new int[]{0}; + } + // ItemHandlerProvider @Override public RebornInventory getInventory() { return this.inventory; } + public static boolean canRecycle(ItemStack stack) { + Item item = stack.getItem(); + if ((item instanceof IUpgrade)) { + return false; + } + return !TechRebornConfig.recyclerBlackList.contains(Registry.ITEM.getId(item).toString()); + } + // IContainerProvider @Override public BuiltContainer createContainer(int syncID, PlayerEntity player) { return new ContainerBuilder("recycler").player(player.inventory).inventory().hotbar().addInventory() - .blockEntity(this).slot(0, 55, 45, itemStack -> !(itemStack.getItem() instanceof IUpgrade)).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue() - .sync(this::getProgress, this::setProgress).addInventory().create(this, syncID); + .blockEntity(this).slot(0, 55, 45, RecyclerBlockEntity::canRecycle) + .outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue() + .sync(this::getProgress, this::setProgress).addInventory().create(this, syncID); } + } diff --git a/src/main/java/techreborn/config/TechRebornConfig.java b/src/main/java/techreborn/config/TechRebornConfig.java index 332176b0c..c71dbb338 100644 --- a/src/main/java/techreborn/config/TechRebornConfig.java +++ b/src/main/java/techreborn/config/TechRebornConfig.java @@ -26,6 +26,9 @@ package techreborn.config; import reborncore.common.config.Config; +import java.util.Arrays; +import java.util.List; + //All moved into one class as its a lot easier to find the annotations when you know where they all are public class TechRebornConfig { @@ -431,6 +434,9 @@ public class TechRebornConfig { @Config(config = "machines", category = "recycler", key = "RecyclerMaxEnergy", comment = "Recycler Max Energy (Value in EU)") public static int recyclerMaxEnergy = 1000; + @Config(config = "machines", category = "recycler", key = "RecyclerBlacklist", comment = "Recycler blacklist") + public static List recyclerBlackList = Arrays.asList("techreborn:scrap_box", "techreborn:scrap"); + @Config(config = "machines", category = "scrapboxinator", key = "ScrapboxinatorMaxInput", comment = "Scrapboxinator Max Input (Value in EU)") public static int scrapboxinatorMaxInput = 32; diff --git a/src/main/resources/data/techreborn/recipes/centrifuge/bronze_dust.json b/src/main/resources/data/techreborn/recipes/centrifuge/bronze_dust.json index ac755c66b..5360de4f5 100644 --- a/src/main/resources/data/techreborn/recipes/centrifuge/bronze_dust.json +++ b/src/main/resources/data/techreborn/recipes/centrifuge/bronze_dust.json @@ -10,11 +10,11 @@ "results": [ { "item": "techreborn:copper_small_dust", - "count": 6 + "count": 3 }, { "item": "techreborn:tin_small_dust", - "count": 2 + "count": 1 } ] } \ No newline at end of file