diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockColoredLamp.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockColoredLamp.java index a74b825a1..dbf9d193d 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockColoredLamp.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockColoredLamp.java @@ -30,7 +30,7 @@ public class BlockColoredLamp extends Block implements INameableItem{ private IIcon[] textures = new IIcon[allLampTypes.length]; - private boolean isOn; + public boolean isOn; public BlockColoredLamp(boolean isOn){ super(Material.redstoneLight); diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockLampPowerer.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockLampPowerer.java index 70e3aeb55..8963bf60e 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockLampPowerer.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockLampPowerer.java @@ -70,7 +70,19 @@ public class BlockLampPowerer extends Block implements INameableItem{ private void updateLamp(World world, int x, int y, int z){ if(!world.isRemote){ - WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), x, y, z); + WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), world, x, y, z); + if(coords != null && coords.getBlock() instanceof BlockColoredLamp){ + if(world.isBlockIndirectlyGettingPowered(x, y, z)){ + if(!((BlockColoredLamp)coords.getBlock()).isOn){ + world.setBlock(coords.getX(), coords.getY(), coords.getZ(), InitBlocks.blockColoredLampOn, world.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()), 2); + } + } + else{ + if(((BlockColoredLamp)coords.getBlock()).isOn){ + world.setBlock(coords.getX(), coords.getY(), coords.getZ(), InitBlocks.blockColoredLamp, world.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()), 2); + } + } + } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java index a47c3b413..81f61f57b 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java @@ -45,7 +45,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ if(this.currentTime <= 0){ ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); - WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord); + WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); if(coordsBlock != null){ Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()); if(!this.isPlacer && blockToBreak != null && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){ diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java index 1a512d1e4..5bc8a5a7c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java @@ -110,7 +110,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements if(this.currentTime <= 0){ ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); - WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord); + WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); if(coordsBlock != null){ Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()); if(!this.isPlacer && blockToBreak != null && worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) == 0){ diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java index 17b8d7c2e..5f1a86261 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java @@ -27,7 +27,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr ArrayList blocksAround = new ArrayList(); if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ for(int i = 1; i <= 5; i++){ - WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByRotatingSide(i), xCoord, yCoord, zCoord); + WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByRotatingSide(i), worldObj, xCoord, yCoord, zCoord); if(coords != null){ Block block = worldObj.getBlock(coords.getX(), coords.getY(), coords.getZ()); if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()) == 0){ diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldPos.java b/src/main/java/ellpeck/actuallyadditions/util/WorldPos.java index 2c008f140..b554ea00d 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldPos.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldPos.java @@ -1,5 +1,7 @@ package ellpeck.actuallyadditions.util; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class WorldPos{ @@ -31,4 +33,12 @@ public class WorldPos{ public World getWorld(){ return this.world; } + + public Block getBlock(){ + return this.world != null ? this.world.getBlock(this.x, this.y, this.z) : null; + } + + public TileEntity getTileEntity(){ + return this.world != null ? this.world.getTileEntity(this.x, this.y, this.z) : null; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java index b99df9478..9e25657d8 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java @@ -19,9 +19,9 @@ import java.util.ArrayList; public class WorldUtil{ - public static WorldPos getCoordsFromSide(ForgeDirection side, int x, int y, int z){ + public static WorldPos getCoordsFromSide(ForgeDirection side, World world, int x, int y, int z){ if(side == ForgeDirection.UNKNOWN) return null; - return new WorldPos(null, x+side.offsetX, y+side.offsetY, z+side.offsetZ); + return new WorldPos(world, x+side.offsetX, y+side.offsetY, z+side.offsetZ); } public static void breakBlockAtSide(ForgeDirection side, World world, int x, int y, int z){ @@ -29,7 +29,7 @@ public class WorldUtil{ world.setBlockToAir(x, y, z); return; } - WorldPos c = getCoordsFromSide(side, x, y, z); + WorldPos c = getCoordsFromSide(side, world, x, y, z); if(c != null){ world.setBlockToAir(c.getX(), c.getY(), c.getZ()); } @@ -103,7 +103,7 @@ public class WorldUtil{ public static boolean dropItemAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){ if(side != ForgeDirection.UNKNOWN){ - WorldPos coords = getCoordsFromSide(side, x, y, z); + WorldPos coords = getCoordsFromSide(side, world, x, y, z); if(coords != null){ EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+0.5, stack); item.motionX = 0; @@ -116,7 +116,7 @@ public class WorldUtil{ } public static TileEntity getTileEntityFromSide(ForgeDirection side, World world, int x, int y, int z){ - WorldPos c = getCoordsFromSide(side, x, y, z); + WorldPos c = getCoordsFromSide(side, world, x, y, z); if(c != null){ return world.getTileEntity(c.getX(), c.getY(), c.getZ()); }