Skip to content

Commit 82a833d

Browse files
fix: dont call setChanged() in read as it caused a crash with contraptions
1 parent 5b2e5d5 commit 82a833d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

common/src/main/java/net/createcobblestone/blocks/MechanicalGeneratorBlockEntity.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ protected void read(CompoundTag compound, boolean clientPacket) {
5151
super.read(compound, clientPacket);
5252

5353
try {
54-
updateType(GeneratorType.fromId(compound.getString("type")));
54+
// dont call setChanged() in read as it caused a crash with contraptions
55+
changeType(GeneratorType.fromId(compound.getString("type")));
5556
} catch (IllegalArgumentException e) {
5657
CreateCobblestoneMod.LOGGER.error("Invalid generator type \"{}\", setting type to NONE", compound.getString("type"));
5758
type = GeneratorType.NONE;
58-
setChanged();
5959
}
6060
}
6161

@@ -160,7 +160,12 @@ public float calculateStressApplied() {
160160
}
161161

162162
public void updateType(GeneratorType newType) {
163+
changeType(newType);
163164

165+
this.setChanged();
166+
}
167+
168+
public void changeType(GeneratorType newType) {
164169
if (newType == null) {
165170
if (Config.common().enableDebugLogging.get()) {
166171
CreateCobblestoneMod.LOGGER.error("Attempted to update generator type to null");
@@ -190,7 +195,5 @@ public void updateType(GeneratorType newType) {
190195
// Make sure no items get ghosted to the new generator to avoid generator rate issues
191196
this.available = 0;
192197
this.items.clear();
193-
194-
this.setChanged();
195198
}
196199
}

0 commit comments

Comments
 (0)