mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Fixed blocks activating too often in redstone pulse mode
This commit is contained in:
parent
583d6e025e
commit
7dd939999c
2 changed files with 22 additions and 7 deletions
|
@ -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,6 +111,7 @@ public abstract class BlockContainerBase extends BlockContainer{
|
|||
}
|
||||
|
||||
public void updateRedstoneState(World world, int x, int y, int z){
|
||||
if(!world.isRemote){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||
if(tile instanceof TileEntityBase){
|
||||
|
@ -118,6 +120,17 @@ public abstract class BlockContainerBase extends BlockContainer{
|
|||
}
|
||||
if(tile instanceof IRedstoneToggle){
|
||||
if(((IRedstoneToggle)tile).isPulseMode() && powered){
|
||||
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
|
|
|
@ -162,6 +162,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
|
||||
@Override
|
||||
public void activateOnPulse(){
|
||||
System.out.println("ACT");
|
||||
this.doWork();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue