Fixed crashes with 2-channel components where the second id is selected, but not the channel

This commit is contained in:
malte0811 2017-10-27 21:08:17 +02:00
parent a35150f8e7
commit 543368ad7c
5 changed files with 23 additions and 17 deletions

View file

@ -30,7 +30,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "14.22.1.2479"
version = "14.23.0.2512"
runDir = "run"
replace '${version}', project.version

View file

@ -18,7 +18,6 @@
package malte0811.industrialWires.blocks.controlpanel;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.controlpanel.PropertyComponents;
import malte0811.industrialWires.items.ItemPanelComponent;
@ -51,8 +50,10 @@ public class TileEntityComponentPanel extends TileEntityPanel {
PanelComponent pc = components.get(0);
pc.registerRSOutput(-1, (channel, value, pcTmp)->{
rsOut = value;
markBlockForUpdate(pos);
markBlockForUpdate(pos.offset(components.getTop(), -1));
if (!isInvalid()) {
markBlockForUpdate(pos);
markBlockForUpdate(pos.offset(components.getTop(), -1));
}
});
rsIn = pc.getRSInputHandler(-1, this);
updateRS();

View file

@ -41,7 +41,6 @@ import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
@ -72,11 +71,8 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
nbt.setInteger(RS_ID, rsInputId);
nbt.setByte(RS_CHANNEL, rsInputChannel);
nbt.setBoolean(HAS_SECOND_CHANNEL, hasSecond);
if (hasSecond) {
nbt.setInteger(RS_ID2, rsInputId2);
nbt.setByte(RS_CHANNEL2, rsInputChannel2);
}
nbt.setInteger(RS_ID2, rsInputId2);
nbt.setByte(RS_CHANNEL2, rsInputChannel2);
nbt.setBoolean(WIDE, wide);
if (!toItem) {
nbt.setInteger("rsInput", rsInput);
@ -89,11 +85,14 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
rsInputChannel = nbt.getByte(RS_CHANNEL);
rsInput = nbt.getInteger("rsInput");
wide = nbt.getBoolean(WIDE);
hasSecond = nbt.getBoolean(HAS_SECOND_CHANNEL);
if (hasSecond) {
if (nbt.hasKey(RS_ID2)) {
rsInputId2 = nbt.getInteger(RS_ID2);
rsInputChannel2 = nbt.getByte(RS_CHANNEL2);
hasSecond = rsInputId2>=0&&rsInputChannel2>=0;
} else {
hasSecond = false;
}
if (!hasSecond) {
rsInputId2 = -1;
rsInputChannel2 = -1;
}

View file

@ -78,7 +78,6 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
nbt.setInteger(RS_ID, rsId);
nbt.setByte(RS_CHANNEL2, rsChannel2);
nbt.setInteger(RS_ID2, rsId2);
nbt.setBoolean(HAS_SECOND_CHANNEL, hasSecond);
nbt.setBoolean(HORIZONTAL, horizontal);
}
@ -86,13 +85,17 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
protected void readCustomNBT(NBTTagCompound nbt) {
color = nbt.getInteger(COLOR);
length = nbt.getFloat(LENGTH);
horizontal = nbt.getBoolean(HORIZONTAL);
out = nbt.getInteger("output");
rsChannel = nbt.getByte(RS_CHANNEL);
rsId = nbt.getInteger(RS_ID);
rsChannel2 = nbt.getByte(RS_CHANNEL2);
rsId2 = nbt.getInteger(RS_ID2);
hasSecond = nbt.getBoolean(HAS_SECOND_CHANNEL);
horizontal = nbt.getBoolean(HORIZONTAL);
hasSecond = rsId2>=0&&rsChannel2>=0;
if (!hasSecond) {
rsChannel2 = -1;
rsId2 = -1;
}
}
@Override

View file

@ -83,7 +83,6 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
nbt.setInteger(RS_ID, rsId);
nbt.setByte(RS_CHANNEL2, rsChannel2);
nbt.setInteger(RS_ID2, rsId2);
nbt.setBoolean(HAS_SECOND_CHANNEL, hasSecond);
}
@Override
@ -93,7 +92,11 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
rsId = nbt.getInteger(RS_ID);
rsChannel2 = nbt.getByte(RS_CHANNEL2);
rsId2 = nbt.getInteger(RS_ID2);
hasSecond = nbt.getBoolean(HAS_SECOND_CHANNEL);
hasSecond = rsChannel2>=0&&rsId2>=0;
if (!hasSecond) {
rsChannel2 = -1;
rsId2 = -1;
}
}
@Override