Fix the "other" RS controller not keeping its IO state across world reloads

Fix P:R wires showing as a too low signal strength
This commit is contained in:
malte0811 2019-01-04 20:49:46 +01:00
parent 961b325111
commit 2f02fc5044
4 changed files with 25 additions and 8 deletions

View File

@ -71,8 +71,8 @@ public abstract class TileEntityRSPanel extends TileEntityGeneralCP implements I
protected void markRSDirty() {
dirty = true;
}
protected void inputUpdate(byte[] newIn) {
protected void onInputChanged(byte[] newIn) {
if (!Arrays.equals(currInput, newIn)) {
ControlPanelNetwork.RSChannelState[] newStates = new ControlPanelNetwork.RSChannelState[16];
for (byte i = 0; i < 16; i++) {
@ -90,7 +90,7 @@ public abstract class TileEntityRSPanel extends TileEntityGeneralCP implements I
@Override
public void setNetworkAndInit(ControlPanelNetwork newNet) {
super.setNetworkAndInit(newNet);
inputUpdate(currInput);
onInputChanged(currInput);
Consumer<ControlPanelNetwork.RSChannelState> listener = state -> {
if (out[state.getColor()] != state.getStrength()) {
out[state.getColor()] = state.getStrength();
@ -118,4 +118,15 @@ public abstract class TileEntityRSPanel extends TileEntityGeneralCP implements I
protected abstract void updateOutput();
protected abstract void updateInput();
@Override
public void onLoad() {
super.onLoad();
if (!world.isRemote) {
updateInput();
updateOutput();
}
}
}

View File

@ -38,7 +38,7 @@ import javax.annotation.Nullable;
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
public class TileEntityRSPanelIE extends TileEntityRSPanel//TODO what parts of TEIIC do I need?
public class TileEntityRSPanelIE extends TileEntityRSPanel
implements IRedstoneConnector, IEBlockInterfaces.IDirectionalTile, IBlockBoundsIW {
private EnumFacing facing = EnumFacing.NORTH;
@Nonnull
@ -65,6 +65,11 @@ public class TileEntityRSPanelIE extends TileEntityRSPanel//TODO what parts of T
wireNetwork.updateValues();
}
@Override
protected void updateInput() {
updateInput(wireNetwork.channelValues);
}
@Override
public void setNetwork(@Nonnull RedstoneWireNetwork net) {
wireNetwork = net;
@ -78,7 +83,7 @@ public class TileEntityRSPanelIE extends TileEntityRSPanel//TODO what parts of T
@Override
public void onChange() {
inputUpdate(wireNetwork.channelValues);
onInputChanged(wireNetwork.channelValues);
}
@Override

View File

@ -44,19 +44,20 @@ public class TileEntityRSPanelOthers extends TileEntityRSPanel implements IBundl
return ret;
}
@Override
public void updateInput() {
byte[] data = new byte[16];
for (EnumFacing f:EnumFacing.VALUES) {
byte[] tmp = Compat.getBundledRS.run(world, pos, f);
if (tmp!=null) {
for (int i = 0;i<16;i++) {
for (int i = 0; i<16; i++) {
if (tmp[i]>data[i]) {
data[i] = tmp[i];
}
}
}
}
inputUpdate(data);
onInputChanged(data);
}
@Override

View File

@ -191,7 +191,7 @@ public class Compat {
byte[] prIn = ProjectRedAPI.transmissionAPI.getBundledInput(w, p, f);
if (prIn!=null) {
for (int i = 0; i < 16; i++) {
oldIn[i] = (byte)((prIn[i]&255)/17);
oldIn[i] = (byte) Math.ceil((prIn[i] & 255) / 17.0);
}
}
return oldIn;