Merge pull request #2180 from abel1502/abel-geiger-redstone

Geiger counter comparator integration
This commit is contained in:
HbmMods 2025-05-29 18:11:25 +02:00 committed by GitHub
commit 95f3bcb1f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -131,4 +131,22 @@ public class GeigerCounter extends BlockContainer {
return false;
}
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
TileEntityGeiger te = (TileEntityGeiger)world.getTileEntity(x, y, z);
if (te == null) return 0;
float rad = te.check();
// 0 at exactly 0 rads/sec
// +1 per 5 rads/sec
// 15 at 75+ rads/sec
return Math.min((int)Math.ceil(rad / 5f), 15);
}
}

View File

@ -35,6 +35,9 @@ public class TileEntityGeiger extends TileEntity implements SimpleComponent, IIn
if(timer == 10) {
timer = 0;
ticker = check();
// To update the adjacent comparators
worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
}
if(timer % 5 == 0) {
@ -65,6 +68,7 @@ public class TileEntityGeiger extends TileEntity implements SimpleComponent, IIn
public float check() {
return ChunkRadiationManager.proxy.getRadiation(worldObj, xCoord, yCoord, zCoord);
}
@Override
@Optional.Method(modid = "OpenComputers")
public String getComponentName() {