mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Made the Lamp Powerer work
Still missing Textures & Localization
This commit is contained in:
parent
2b40e12eae
commit
255e357039
7 changed files with 32 additions and 10 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -27,7 +27,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
|||
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
||||
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){
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue