mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-12 23:37:29 +01:00
Toolbugs
- Attempt to improve handling of toolbox storage on contraptions #6940
This commit is contained in:
parent
8f5c91c195
commit
a99f05d8b0
2 changed files with 16 additions and 6 deletions
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions;
|
||||||
|
|
||||||
import com.simibubi.create.AllBlockEntityTypes;
|
import com.simibubi.create.AllBlockEntityTypes;
|
||||||
import com.simibubi.create.AllTags.AllBlockTags;
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
|
import com.simibubi.create.content.equipment.toolbox.ToolboxInventory;
|
||||||
import com.simibubi.create.content.kinetics.crafter.MechanicalCrafterBlockEntity;
|
import com.simibubi.create.content.kinetics.crafter.MechanicalCrafterBlockEntity;
|
||||||
import com.simibubi.create.content.logistics.crate.BottomlessItemHandler;
|
import com.simibubi.create.content.logistics.crate.BottomlessItemHandler;
|
||||||
import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity;
|
import com.simibubi.create.content.logistics.vault.ItemVaultBlockEntity;
|
||||||
|
@ -177,6 +178,8 @@ public class MountedStorage {
|
||||||
CompoundTag tag = handler.serializeNBT();
|
CompoundTag tag = handler.serializeNBT();
|
||||||
if (noFuel)
|
if (noFuel)
|
||||||
NBTHelper.putMarker(tag, "NoFuel");
|
NBTHelper.putMarker(tag, "NoFuel");
|
||||||
|
if (handler instanceof ToolboxInventory)
|
||||||
|
NBTHelper.putMarker(tag, "Toolbox");
|
||||||
if (!(handler instanceof BottomlessItemHandler))
|
if (!(handler instanceof BottomlessItemHandler))
|
||||||
return tag;
|
return tag;
|
||||||
|
|
||||||
|
@ -191,6 +194,9 @@ public class MountedStorage {
|
||||||
storage.handler = new ItemStackHandler();
|
storage.handler = new ItemStackHandler();
|
||||||
if (nbt == null)
|
if (nbt == null)
|
||||||
return storage;
|
return storage;
|
||||||
|
if (nbt.contains("Toolbox"))
|
||||||
|
storage.handler = new ToolboxInventory(null);
|
||||||
|
|
||||||
storage.valid = true;
|
storage.valid = true;
|
||||||
storage.noFuel = nbt.contains("NoFuel");
|
storage.noFuel = nbt.contains("NoFuel");
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class ToolboxInventory extends ItemStackHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settling = false;
|
settling = false;
|
||||||
blockEntity.sendData();
|
notifyUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,7 +109,7 @@ public class ToolboxInventory extends ItemStackHandler {
|
||||||
if (!stack.isEmpty() && filters.get(compartment)
|
if (!stack.isEmpty() && filters.get(compartment)
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1));
|
filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1));
|
||||||
blockEntity.sendData();
|
notifyUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class ToolboxInventory extends ItemStackHandler {
|
||||||
if (!stack.isEmpty() && filters.get(compartment)
|
if (!stack.isEmpty() && filters.get(compartment)
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1));
|
filters.set(compartment, ItemHandlerHelper.copyStackWithSize(stack, 1));
|
||||||
blockEntity.sendData();
|
notifyUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return insertItem;
|
return insertItem;
|
||||||
|
@ -136,10 +136,9 @@ public class ToolboxInventory extends ItemStackHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
if (!settling && !blockEntity.getLevel().isClientSide)
|
if (!settling && (blockEntity == null || !blockEntity.getLevel().isClientSide))
|
||||||
settle(slot / STACKS_PER_COMPARTMENT);
|
settle(slot / STACKS_PER_COMPARTMENT);
|
||||||
blockEntity.sendData();
|
notifyUpdate();
|
||||||
blockEntity.setChanged();
|
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,4 +207,9 @@ public class ToolboxInventory extends ItemStackHandler {
|
||||||
return ItemHandlerHelper.canItemStacksStack(stack1, stack2);
|
return ItemHandlerHelper.canItemStacksStack(stack1, stack2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyUpdate() {
|
||||||
|
if (blockEntity != null)
|
||||||
|
blockEntity.notifyUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue