From 9bff016ba46fd75d7198da3eacba2e32ddf9c8ca Mon Sep 17 00:00:00 2001 From: grimmauld Date: Sat, 10 Oct 2020 17:54:17 +0200 Subject: [PATCH] Depot comparing --- .../logistics/block/depot/DepotBlock.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java index c29347c7c..fb3895718 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/DepotBlock.java @@ -9,6 +9,7 @@ import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour; +import mcp.MethodsReturnNonnullByDefault; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -28,6 +29,11 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.items.ItemStackHandler; +import javax.annotation.ParametersAreNonnullByDefault; + + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault public class DepotBlock extends Block implements ITE { public DepotBlock(Properties p_i48440_1_) { @@ -130,4 +136,18 @@ public class DepotBlock extends Block implements ITE { itemEntity.remove(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + try { + return ItemHelper.calcRedstoneFromInventory(getTileEntity(worldIn, pos).itemHandler); + } catch (TileEntityException ignored) { + } + return 0; + } + }