mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 22:04:49 +00:00
Various fixes to data not loading properly (#5407)
* Cleanup redstone handling of TileEntitySidedPipe Properly mark the transmitters as dirty if the redstone mode changed during refresh * Fix not updating tank capacity when loading TEFluidTank from NBT * Make transmitters fix invalid connections on load * Address comments and call refreshConnections() directly.
This commit is contained in:
1 parent
9b70069eaf
commit
04372a6426
2 files changed
+38
-34
No files matched your search
@@ -288,9 +288,10 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
tier = FluidTankTier.values()[nbtTags.getInteger("tier")];
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")];
|
||||
//Needs to be outside the hasKey check because this is just based on the tier which is known information
|
||||
fluidTank.setCapacity(tier.getStorage());
|
||||
|
||||
if (nbtTags.hasKey("fluidTank")) {
|
||||
fluidTank.setCapacity(tier.getStorage());
|
||||
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.api.transmitters.IBlockableConnection;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.base.ITileNetwork;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.block.BlockTransmitter;
|
||||
import mekanism.common.block.property.PropertyConnection;
|
||||
import mekanism.common.block.states.BlockStateTransmitter.TransmitterType;
|
||||
@@ -25,6 +24,7 @@ import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.integration.multipart.MultipartMekanism;
|
||||
import mekanism.common.integration.multipart.MultipartTileNetworkJoiner;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MultipartUtils;
|
||||
@@ -60,13 +60,13 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
public byte currentTransmitterConnections = 0x00;
|
||||
|
||||
public boolean sendDesc = false;
|
||||
public boolean redstonePowered = false;
|
||||
private boolean redstonePowered = false;
|
||||
|
||||
public boolean redstoneReactive = false;
|
||||
private boolean redstoneReactive = false;
|
||||
|
||||
public boolean forceUpdate = true;
|
||||
|
||||
public boolean redstoneSet = false;
|
||||
private boolean redstoneSet = false;
|
||||
|
||||
public ConnectionType[] connectionTypes = {ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL,
|
||||
ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL};
|
||||
@@ -312,18 +312,20 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
|
||||
@Override
|
||||
public boolean canConnect(EnumFacing side) {
|
||||
if (!redstoneSet) {
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
if (handlesRedstone()) {
|
||||
if (!redstoneSet) {
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
}
|
||||
|
||||
redstoneSet = true;
|
||||
}
|
||||
|
||||
redstoneSet = true;
|
||||
}
|
||||
|
||||
if (handlesRedstone() && redstoneReactive && redstonePowered) {
|
||||
return false;
|
||||
if (redstoneReactive && redstonePowered) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Mekanism.hooks.MCMPLoaded) {
|
||||
@@ -401,13 +403,20 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
}
|
||||
|
||||
public void refreshConnections() {
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
}
|
||||
if (handlesRedstone()) {
|
||||
boolean previouslyPowered = redstonePowered;
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
}
|
||||
//If the redstone mode changed properly update the connection to other transmitters/networks
|
||||
if (previouslyPowered != redstonePowered) {
|
||||
notifyTileChange();
|
||||
}
|
||||
|
||||
redstoneSet = true;
|
||||
redstoneSet = true;
|
||||
}
|
||||
|
||||
if (!getWorld().isRemote) {
|
||||
byte possibleTransmitters = getPossibleTransmitterConnections();
|
||||
@@ -479,6 +488,10 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
@Override
|
||||
public void onLoad() {
|
||||
onWorldJoin();
|
||||
if (getPossibleTransmitterConnections() != currentTransmitterConnections) {
|
||||
//Mark the transmitters as invalidated if they do not match what we have stored/calculated
|
||||
refreshConnections();
|
||||
}
|
||||
super.onLoad();
|
||||
}
|
||||
|
||||
@@ -487,16 +500,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(EnumFacing side) {
|
||||
if (handlesRedstone()) {
|
||||
boolean prevPowered = redstonePowered;
|
||||
refreshConnections();
|
||||
|
||||
if (prevPowered != redstonePowered) {
|
||||
markDirtyTransmitters();
|
||||
}
|
||||
} else {
|
||||
refreshConnections();
|
||||
}
|
||||
refreshConnections();
|
||||
}
|
||||
|
||||
public void onPartChanged(IMultipart part) {
|
||||
@@ -632,8 +636,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, EnumFacing facing) {
|
||||
return capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == Capabilities.TILE_NETWORK_CAPABILITY
|
||||
||
|
||||
capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY || super.hasCapability(capability, facing);
|
||||
|| capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user