mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Made redstone power be determined only when something changes
This commit is contained in:
parent
5e0994fa29
commit
5993bb6e0f
16 changed files with 40 additions and 16 deletions
|
@ -10,8 +10,10 @@
|
|||
|
||||
package ellpeck.actuallyadditions.blocks;
|
||||
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityInventoryBase;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -74,4 +76,21 @@ public abstract class BlockContainerBase extends BlockContainer{
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
|
||||
this.updateRedstoneState(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z){
|
||||
this.updateRedstoneState(world, x, y, z);
|
||||
}
|
||||
|
||||
private void updateRedstoneState(World world, int x, int y, int z){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBase){
|
||||
((TileEntityBase)tile).setRedstonePowered(world.isBlockIndirectlyGettingPowered(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!this.worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.storage.getEnergyStored() >= ENERGY_USE){
|
||||
if(!this.isRedstonePowered && this.storage.getEnergyStored() >= ENERGY_USE){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
|
|
|
@ -24,7 +24,8 @@ import net.minecraft.world.World;
|
|||
|
||||
public abstract class TileEntityBase extends TileEntity{
|
||||
|
||||
private int ticksElapsed;
|
||||
protected int ticksElapsed;
|
||||
protected boolean isRedstonePowered;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Registering TileEntities...");
|
||||
|
@ -88,6 +89,10 @@ public abstract class TileEntityBase extends TileEntity{
|
|||
this.ticksElapsed++;
|
||||
}
|
||||
|
||||
public void setRedstonePowered(boolean powered){
|
||||
this.isRedstonePowered = powered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket(){
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase{
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
|
|||
|
||||
if(this.tank.getFluidAmount() > 0){
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.tank);
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, this.tank);
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, this.tank);
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, this.tank);
|
||||
|
|
|
@ -94,7 +94,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
|||
if(!worldObj.isRemote){
|
||||
this.storeCoffee();
|
||||
|
||||
if(this.brewTime > 0 || this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(this.brewTime > 0 || this.isRedstonePowered){
|
||||
this.brew();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
if(this.storage.getEnergyStored() >= ENERGY_USE*RANGE){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TileEntityDropper extends TileEntityInventoryBase{
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
|
|||
|
||||
if(this.oilTank.getFluidAmount() > 0){
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.oilTank);
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, this.oilTank);
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, this.oilTank);
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, this.oilTank);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class TileEntityFishingNet extends TileEntityBase{
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
if(worldObj.getBlock(xCoord, yCoord-1, zCoord).getMaterial() == Material.water){
|
||||
if(this.timeUntilNextDrop > 0){
|
||||
this.timeUntilNextDrop--;
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
|
@ -138,7 +138,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
|||
|
||||
if(!this.isPlacer && this.tank.getFluidAmount() > 0){
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.tank);
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, this.tank);
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, this.tank);
|
||||
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, this.tank);
|
||||
|
|
|
@ -401,7 +401,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
|||
this.initVars();
|
||||
|
||||
//Is Block not powered by Redstone?
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
if(!(this.sideToPull == this.sideToPut && this.slotToPullStart == this.slotToPutStart && this.slotToPullEnd == this.slotToPutEnd)){
|
||||
if(sideToPull != -1 && this.placeToPull instanceof IInventory){
|
||||
this.pull();
|
||||
|
|
|
@ -33,7 +33,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
|
||||
if(this.nextUseCounter >= 5){
|
||||
this.nextUseCounter = 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
super.updateEntity();
|
||||
|
||||
if(!worldObj.isRemote){
|
||||
if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.isBoundThingInRange() && this.getHandler() != null){
|
||||
if(this.isRedstonePowered && this.isBoundThingInRange() && this.getHandler() != null){
|
||||
this.pushFluid(ForgeDirection.UP);
|
||||
this.pushFluid(ForgeDirection.DOWN);
|
||||
this.pushFluid(ForgeDirection.NORTH);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
if(this.isBoundThingInRange()){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
if(!this.isRedstonePowered){
|
||||
ArrayList<EntityItem> items = (ArrayList<EntityItem>)this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(this.xCoord-RANGE, this.yCoord-RANGE, this.zCoord-RANGE, this.xCoord+RANGE, this.yCoord+RANGE, this.zCoord+RANGE));
|
||||
if(!items.isEmpty()){
|
||||
for(EntityItem item : items){
|
||||
|
|
Loading…
Reference in a new issue