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 net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class BlockContainerBase extends BlockContainer{
|
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){
|
public void updateRedstoneState(World world, int x, int y, int z){
|
||||||
TileEntity tile = world.getTileEntity(x, y, z);
|
if(!world.isRemote){
|
||||||
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
if(tile instanceof TileEntityBase){
|
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||||
((TileEntityBase)tile).setRedstonePowered(powered);
|
if(tile instanceof TileEntityBase){
|
||||||
tile.markDirty();
|
((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();
|
((IRedstoneToggle)tile).activateOnPulse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,6 +240,7 @@ public abstract class BlockContainerBase extends BlockContainer{
|
||||||
if(tile instanceof IRedstoneToggle){
|
if(tile instanceof IRedstoneToggle){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
|
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
|
||||||
|
tile.markDirty();
|
||||||
|
|
||||||
if(tile instanceof TileEntityBase){
|
if(tile instanceof TileEntityBase){
|
||||||
((TileEntityBase)tile).sendUpdate();
|
((TileEntityBase)tile).sendUpdate();
|
||||||
|
|
|
@ -162,6 +162,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activateOnPulse(){
|
public void activateOnPulse(){
|
||||||
|
System.out.println("ACT");
|
||||||
this.doWork();
|
this.doWork();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue