Add comparator output for receptacles

This commit is contained in:
Electroblob77
2020-06-24 16:01:56 +01:00
parent 93b0aa948f
commit e6696a1758
2 changed files with 21 additions and 1 deletions
@@ -206,4 +206,23 @@ public class BlockReceptacle extends BlockTorch implements ITileEntityProvider {
return new TileEntityReceptacle();
}
@Override
public boolean hasComparatorInputOverride(IBlockState state){
return true;
}
@Override
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos){
TileEntity tileEntity = world.getTileEntity(pos);
if(tileEntity instanceof TileEntityReceptacle){
Element element = ((TileEntityReceptacle)tileEntity).getElement();
return element == null ? 0 : element.ordinal() + 1;
}
return super.getComparatorInputOverride(state, world, pos);
}
}
@@ -20,11 +20,12 @@ public class TileEntityReceptacle extends TileEntity {
this.element = element;
}
@Nullable
public Element getElement(){
return element;
}
public void setElement(Element element){
public void setElement(@Nullable Element element){
this.element = element;
world.notifyNeighborsRespectDebug(pos, blockType, true); // Update altar if connected
world.checkLight(pos);