mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Remove activity tracking in favor of logic in TileEntityEffectsBlock
This commit is contained in:
1 parent
ebfe103953
commit
7813d39fa6
1 file changed
+2
-67
@@ -13,7 +13,7 @@ import mekanism.common.integration.computer.IComputerIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.prefab.TileEntityNoisyBlock;
|
||||
import mekanism.common.tile.prefab.TileEntityEffectsBlock;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.generators.common.block.states.BlockStateGenerator;
|
||||
@@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class TileEntityGenerator extends TileEntityNoisyBlock implements IComputerIntegration, IActiveState,
|
||||
public abstract class TileEntityGenerator extends TileEntityEffectsBlock implements IComputerIntegration,
|
||||
IRedstoneControl, ISecurityTile {
|
||||
|
||||
/**
|
||||
@@ -33,21 +33,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
*/
|
||||
public double output;
|
||||
|
||||
/**
|
||||
* Whether or not this block is in it's active state.
|
||||
*/
|
||||
public boolean isActive;
|
||||
|
||||
/**
|
||||
* The client's current active state.
|
||||
*/
|
||||
public boolean clientActive;
|
||||
|
||||
/**
|
||||
* How many ticks must pass until this block's active state can sync with the client.
|
||||
*/
|
||||
public int updateDelay;
|
||||
|
||||
/**
|
||||
* This machine's current RedstoneControl type.
|
||||
*/
|
||||
@@ -66,7 +51,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
super("gen." + soundPath, name, maxEnergy);
|
||||
|
||||
output = out;
|
||||
isActive = false;
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
}
|
||||
|
||||
@@ -74,27 +58,7 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (world.isRemote && updateDelay > 0) {
|
||||
updateDelay--;
|
||||
|
||||
if (updateDelay == 0 && clientActive != isActive) {
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (updateDelay > 0) {
|
||||
updateDelay--;
|
||||
|
||||
if (updateDelay == 0 && clientActive != isActive) {
|
||||
clientActive = isActive;
|
||||
Mekanism.packetHandler.sendToReceivers(
|
||||
new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())),
|
||||
new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote && general.destroyDisabledBlocks) {
|
||||
GeneratorType type = BlockStateGenerator.GeneratorType.get(getBlockType(), getBlockMetadata());
|
||||
|
||||
@@ -135,25 +99,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
*/
|
||||
public abstract boolean canOperate();
|
||||
|
||||
@Override
|
||||
public boolean getActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
|
||||
if (clientActive != active && updateDelay == 0) {
|
||||
Mekanism.packetHandler
|
||||
.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())),
|
||||
new Range4D(Coord4D.get(this)));
|
||||
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetFacing(int side) {
|
||||
return side != 0 && side != 1;
|
||||
@@ -164,14 +109,7 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
clientActive = dataStream.readBoolean();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
if (updateDelay == 0 && clientActive != isActive) {
|
||||
updateDelay = general.UPDATE_DELAY;
|
||||
isActive = clientActive;
|
||||
MekanismUtils.updateBlock(world, getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +117,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
public TileNetworkList getNetworkedData(TileNetworkList data) {
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(isActive);
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
return data;
|
||||
@@ -189,7 +126,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
public void readFromNBT(NBTTagCompound nbtTags) {
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
isActive = nbtTags.getBoolean("isActive");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
}
|
||||
|
||||
@@ -198,7 +134,6 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) {
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
return nbtTags;
|
||||
|
||||
Reference in new issue
Block a user