Fixed blocks activating too often in redstone pulse mode

This commit is contained in:
Ellpeck 2015-12-24 00:34:47 +01:00
parent 583d6e025e
commit 7dd939999c
2 changed files with 22 additions and 7 deletions

View file

@ -32,6 +32,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Random;
public abstract class BlockContainerBase extends BlockContainer{
@ -110,14 +111,26 @@ public abstract class BlockContainerBase extends BlockContainer{
}
public void updateRedstoneState(World world, int x, int y, int z){
TileEntity tile = world.getTileEntity(x, y, z);
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z);
if(tile instanceof TileEntityBase){
((TileEntityBase)tile).setRedstonePowered(powered);
tile.markDirty();
if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z);
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z);
if(tile instanceof TileEntityBase){
((TileEntityBase)tile).setRedstonePowered(powered);
tile.markDirty();
}
if(tile instanceof IRedstoneToggle){
if(((IRedstoneToggle)tile).isPulseMode() && powered){
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
}
}
}
if(tile instanceof IRedstoneToggle){
if(((IRedstoneToggle)tile).isPulseMode() && powered){
}
@Override
public void updateTick(World world, int x, int y, int z, Random random){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IRedstoneToggle && ((IRedstoneToggle)tile).isPulseMode()){
((IRedstoneToggle)tile).activateOnPulse();
}
}
@ -227,6 +240,7 @@ public abstract class BlockContainerBase extends BlockContainer{
if(tile instanceof IRedstoneToggle){
if(!world.isRemote){
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
tile.markDirty();
if(tile instanceof TileEntityBase){
((TileEntityBase)tile).sendUpdate();

View file

@ -162,6 +162,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
@Override
public void activateOnPulse(){
System.out.println("ACT");
this.doWork();
}
}