Fixed slight performance issue with loading Crafters from disk. Fixes #2106

This commit is contained in:
raoulvdberge
2018-11-28 21:02:21 +01:00
parent 168c3c6a6b
commit 3fb53378ca
2 changed files with 17 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
### 1.6.12 ### 1.6.12
- Increased the speed of autocrafting (raoulvdberge) - Increased the speed of autocrafting (raoulvdberge)
- Fixed External Storage sending storage updates when it is disabled (raoulvdberge) - Fixed External Storage sending storage updates when it is disabled (raoulvdberge)
- Fixed slight performance issue with loading Crafters from disk (raoulvdberge)
- Added a completion percentage to the Crafting Monitor (raoulvdberge) - Added a completion percentage to the Crafting Monitor (raoulvdberge)
- Updated Russian translation (kellixon) - Updated Russian translation (kellixon)

View File

@@ -61,6 +61,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
protected void onContentsChanged(int slot) { protected void onContentsChanged(int slot) {
super.onContentsChanged(slot); super.onContentsChanged(slot);
if (!reading) {
if (!world.isRemote) { if (!world.isRemote) {
invalidate(); invalidate();
} }
@@ -69,6 +70,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
network.getCraftingManager().rebuild(); network.getCraftingManager().rebuild();
} }
} }
}
@Override @Override
public int getSlotLimit(int slot) { public int getSlotLimit(int slot) {
@@ -91,6 +93,8 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
private boolean locked = false; private boolean locked = false;
private boolean wasPowered; private boolean wasPowered;
private boolean reading;
@Nullable @Nullable
private String displayName; private String displayName;
@@ -171,12 +175,19 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
public void read(NBTTagCompound tag) { public void read(NBTTagCompound tag) {
super.read(tag); super.read(tag);
// Fix cascading crafter invalidates while reading patterns
this.reading = true;
StackUtils.readItems(patternsInventory, 0, tag); StackUtils.readItems(patternsInventory, 0, tag);
if (API.instance().getOneSixMigrationHelper().migratePatternInventory(patternsInventory)) { if (API.instance().getOneSixMigrationHelper().migratePatternInventory(patternsInventory)) {
markDirty(); markDirty();
} }
this.invalidate();
this.reading = false;
StackUtils.readItems(upgrades, 1, tag); StackUtils.readItems(upgrades, 1, tag);
if (tag.hasKey(NBT_DISPLAY_NAME)) { if (tag.hasKey(NBT_DISPLAY_NAME)) {