Add comparator output for receptacles
This commit is contained in:
@@ -206,4 +206,23 @@ public class BlockReceptacle extends BlockTorch implements ITileEntityProvider {
|
|||||||
return new TileEntityReceptacle();
|
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;
|
this.element = element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Element getElement(){
|
public Element getElement(){
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setElement(Element element){
|
public void setElement(@Nullable Element element){
|
||||||
this.element = element;
|
this.element = element;
|
||||||
world.notifyNeighborsRespectDebug(pos, blockType, true); // Update altar if connected
|
world.notifyNeighborsRespectDebug(pos, blockType, true); // Update altar if connected
|
||||||
world.checkLight(pos);
|
world.checkLight(pos);
|
||||||
|
|||||||
Reference in New Issue
Block a user