mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Fix #53; add support for comparators on bins
This commit is contained in:
1 parent
ccd7ed019a
commit
a4e453e7d5
2 files changed
+36
-1
No files matched your search
@@ -818,4 +818,23 @@ public abstract class BlockBasic extends Block {
|
||||
public boolean isBeaconBase(IBlockAccess world, BlockPos pos, BlockPos beacon) {
|
||||
return BasicBlockType.get(world.getBlockState(pos)).isBeaconBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState blockState) {
|
||||
return BasicBlockType.get(blockState).hasRedstoneOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
if (BasicBlockType.get(blockState).hasRedstoneOutput) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityBin) {
|
||||
TileEntityBin binTile = (TileEntityBin)tile;
|
||||
float percentFull = binTile.getItemCount() / (binTile.getMaxStoredCount() * 1.0f);
|
||||
return (int)(percentFull * 15);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public class BlockStateBasic extends ExtendedBlockState {
|
||||
new IUnlistedProperty[]{});
|
||||
}
|
||||
|
||||
|
||||
public enum BasicBlock {
|
||||
BASIC_BLOCK_1,
|
||||
BASIC_BLOCK_2;
|
||||
@@ -91,7 +92,7 @@ public class BlockStateBasic extends ExtendedBlockState {
|
||||
false, true),
|
||||
STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false, Predicates.alwaysFalse(), false, false,
|
||||
true),
|
||||
BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, true, Plane.HORIZONTAL, true, true, false),
|
||||
BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, true, Plane.HORIZONTAL, true, true, false, true),
|
||||
TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, true, Predicates.alwaysFalse(), false,
|
||||
false, false),
|
||||
STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true, Predicates.alwaysFalse(), false, false,
|
||||
@@ -140,6 +141,7 @@ public class BlockStateBasic extends ExtendedBlockState {
|
||||
public boolean activable;
|
||||
public boolean tiers;
|
||||
public boolean isBeaconBase;
|
||||
public boolean hasRedstoneOutput = false;
|
||||
|
||||
BasicBlockType(BasicBlock block, int metadata, String s, Class<? extends TileEntity> tileClass, boolean hasDesc,
|
||||
Predicate<EnumFacing> facingAllowed, boolean activeState, boolean t, boolean beaconBase) {
|
||||
@@ -154,6 +156,20 @@ public class BlockStateBasic extends ExtendedBlockState {
|
||||
isBeaconBase = beaconBase;
|
||||
}
|
||||
|
||||
BasicBlockType(BasicBlock block, int metadata, String s, Class<? extends TileEntity> tileClass, boolean hasDesc,
|
||||
Predicate<EnumFacing> facingAllowed, boolean activeState, boolean t, boolean beaconBase, boolean hasRedstoneOutput) {
|
||||
blockType = block;
|
||||
meta = metadata;
|
||||
name = s;
|
||||
tileEntityClass = tileClass;
|
||||
hasDescription = hasDesc;
|
||||
facingPredicate = facingAllowed;
|
||||
activable = activeState;
|
||||
tiers = t;
|
||||
isBeaconBase = beaconBase;
|
||||
this.hasRedstoneOutput = hasRedstoneOutput;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static BasicBlockType get(IBlockState state) {
|
||||
if (state.getBlock() instanceof BlockBasic) {
|
||||
|
||||
Reference in new issue
Block a user