Added configurable recycler blacklist (#1934)

* Added configurable recycler blacklist. Defaulted to scrap and scrap_box

* Fix for bronze dust centrifuge dupe
This commit is contained in:
vhd 2019-12-29 21:48:00 +02:00 committed by modmuss50
parent 4f45a63a7a
commit 52de2fc59f
3 changed files with 37 additions and 5 deletions

View file

@ -26,14 +26,17 @@ package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
import reborncore.api.blockentity.IUpgrade; import reborncore.api.blockentity.IUpgrade;
import reborncore.api.blockentity.InventoryProvider; import reborncore.api.blockentity.InventoryProvider;
import reborncore.client.containerBuilder.IContainerProvider; import reborncore.client.containerBuilder.IContainerProvider;
import reborncore.client.containerBuilder.builder.BuiltContainer; import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.containerBuilder.builder.ContainerBuilder; import reborncore.client.containerBuilder.builder.ContainerBuilder;
import reborncore.common.blockentity.SlotConfiguration;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity; import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory; import reborncore.common.util.RebornInventory;
@ -42,7 +45,7 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent; import techreborn.init.TRContent;
public class RecyclerBlockEntity extends PowerAcceptorBlockEntity public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
implements IToolDrop, InventoryProvider, IContainerProvider { implements IToolDrop, InventoryProvider, IContainerProvider, SlotConfiguration.SlotFilter {
private final RebornInventory<RecyclerBlockEntity> inventory = new RebornInventory<>(3, "RecyclerBlockEntity", 64, this); private final RebornInventory<RecyclerBlockEntity> inventory = new RebornInventory<>(3, "RecyclerBlockEntity", 64, this);
private final int cost = 2; private final int cost = 2;
@ -184,17 +187,40 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
return TRContent.Machine.RECYCLER.getStack(); 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 // ItemHandlerProvider
@Override @Override
public RebornInventory<RecyclerBlockEntity> getInventory() { public RebornInventory<RecyclerBlockEntity> getInventory() {
return this.inventory; 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 // IContainerProvider
@Override @Override
public BuiltContainer createContainer(int syncID, PlayerEntity player) { public BuiltContainer createContainer(int syncID, PlayerEntity player) {
return new ContainerBuilder("recycler").player(player.inventory).inventory().hotbar().addInventory() 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() .blockEntity(this).slot(0, 55, 45, RecyclerBlockEntity::canRecycle)
.sync(this::getProgress, this::setProgress).addInventory().create(this, syncID); .outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
.sync(this::getProgress, this::setProgress).addInventory().create(this, syncID);
} }
} }

View file

@ -26,6 +26,9 @@ package techreborn.config;
import reborncore.common.config.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 //All moved into one class as its a lot easier to find the annotations when you know where they all are
public class TechRebornConfig { public class TechRebornConfig {
@ -431,6 +434,9 @@ public class TechRebornConfig {
@Config(config = "machines", category = "recycler", key = "RecyclerMaxEnergy", comment = "Recycler Max Energy (Value in EU)") @Config(config = "machines", category = "recycler", key = "RecyclerMaxEnergy", comment = "Recycler Max Energy (Value in EU)")
public static int recyclerMaxEnergy = 1000; public static int recyclerMaxEnergy = 1000;
@Config(config = "machines", category = "recycler", key = "RecyclerBlacklist", comment = "Recycler blacklist")
public static List<String> recyclerBlackList = Arrays.asList("techreborn:scrap_box", "techreborn:scrap");
@Config(config = "machines", category = "scrapboxinator", key = "ScrapboxinatorMaxInput", comment = "Scrapboxinator Max Input (Value in EU)") @Config(config = "machines", category = "scrapboxinator", key = "ScrapboxinatorMaxInput", comment = "Scrapboxinator Max Input (Value in EU)")
public static int scrapboxinatorMaxInput = 32; public static int scrapboxinatorMaxInput = 32;

View file

@ -10,11 +10,11 @@
"results": [ "results": [
{ {
"item": "techreborn:copper_small_dust", "item": "techreborn:copper_small_dust",
"count": 6 "count": 3
}, },
{ {
"item": "techreborn:tin_small_dust", "item": "techreborn:tin_small_dust",
"count": 2 "count": 1
} }
] ]
} }