Relax, IHandler it

- Fixed belts not invalidating/initialising their item handler correctly
- Fixed restocker gauges crashing when moved by contraption
This commit is contained in:
simibubi 2025-02-11 14:46:01 +01:00
parent f4baa9bc77
commit 1955417333
4 changed files with 15 additions and 1 deletions

View file

@ -177,6 +177,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
if (inventory == null) if (inventory == null)
return; return;
itemHandler = new ItemHandlerBeltSegment(inventory, index); itemHandler = new ItemHandlerBeltSegment(inventory, index);
invalidateCapabilities();
} }
@Override @Override
@ -553,6 +554,7 @@ public class BeltBlockEntity extends KineticBlockEntity {
public void invalidateItemHandler() { public void invalidateItemHandler() {
invalidateCapabilities(); invalidateCapabilities();
itemHandler = null;
} }
public boolean shouldRenderNormally() { public boolean shouldRenderNormally() {

View file

@ -356,6 +356,13 @@ public class BeltSlicer {
player.getInventory().placeItemBackInInventory(AllItems.BELT_CONNECTOR.asStack()); player.getInventory().placeItemBackInInventory(AllItems.BELT_CONNECTOR.asStack());
} }
for (BlockPos blockPos : BeltBlock.getBeltChain(world, controllerBE.getBlockPos())) {
BeltBlockEntity belt = BeltHelper.getSegmentBE(world, blockPos);
if (belt == null)
continue;
belt.invalidateItemHandler();
}
// Transfer items to other controller // Transfer items to other controller
BlockPos search = controllerBE.getBlockPos(); BlockPos search = controllerBE.getBlockPos();
for (int i = 0; i < 10000; i++) { for (int i = 0; i < 10000; i++) {

View file

@ -752,11 +752,16 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro
CompoundTag panelTag = new CompoundTag(); CompoundTag panelTag = new CompoundTag();
panelTag.put("Filter", getFilter().saveOptional(registries)); panelTag.put("Filter", getFilter().saveOptional(registries));
panelTag.putBoolean("UpTo", upTo);
panelTag.putInt("FilterAmount", count); panelTag.putInt("FilterAmount", count);
panelTag.putUUID("Freq", network); panelTag.putUUID("Freq", network);
panelTag.putString("RecipeAddress", recipeAddress); panelTag.putString("RecipeAddress", recipeAddress);
panelTag.putInt("PromiseClearingInterval", -1); panelTag.putInt("PromiseClearingInterval", -1);
panelTag.putInt("RecipeOutput", 1); panelTag.putInt("RecipeOutput", 1);
if (panelBE().restocker)
panelTag.put("Promises", restockerPromises.write());
nbt.put(CreateLang.asId(slot.name()), panelTag); nbt.put(CreateLang.asId(slot.name()), panelTag);
} }

View file

@ -113,7 +113,7 @@ public class RequestPromiseQueue {
public static RequestPromiseQueue read(CompoundTag tag, Runnable onChanged) { public static RequestPromiseQueue read(CompoundTag tag, Runnable onChanged) {
RequestPromiseQueue queue = new RequestPromiseQueue(onChanged); RequestPromiseQueue queue = new RequestPromiseQueue(onChanged);
List<RequestPromise> promises = CatnipCodecUtils.decode(Codec.list(RequestPromise.CODEC), tag.get("List")).orElseThrow(); List<RequestPromise> promises = CatnipCodecUtils.decode(Codec.list(RequestPromise.CODEC), tag.get("List")).orElse(List.of());
for (RequestPromise promise : promises) { for (RequestPromise promise : promises) {
queue.add(promise); queue.add(promise);
} }