diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java index 939dcb360c8..40c75e173c9 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltBlock.java @@ -217,19 +217,21 @@ public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity e if (BeltTunnelInteractionHandler.getTunnelOnPosition(worldIn, pos) != null) return; withBlockEntityDo(worldIn, pos, be -> { - ItemEntity itemEntity = (ItemEntity) entityIn; Storage handler = be.getItemStorage(null); if (handler == null) return; - ItemStack inEntity = itemEntity.getItem(); + + long toInsert = asItem.getCount(); + long inserted; + try (Transaction t = TransferUtil.openNestedOrOuter()) { - long inserted = handler.insert(ItemVariant.of(inEntity), inEntity.getCount(), t); + inserted = handler.insert(ItemVariant.of(asItem), asItem.getCount(), t); if (inserted == 0) return; - if (inEntity.getCount() == inserted) { - itemEntity.discard(); - } else { - inEntity.shrink((int) inserted); + if (inserted == toInsert) { + entityIn.discard(); + } else if (entityIn instanceof ItemEntity itemEntity) { + itemEntity.getItem().shrink((int) inserted); } t.commit(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/stockTicker/StockKeeperRequestScreen.java b/src/main/java/com/simibubi/create/content/logistics/stockTicker/StockKeeperRequestScreen.java index 9e1403301c0..5b210476488 100644 --- a/src/main/java/com/simibubi/create/content/logistics/stockTicker/StockKeeperRequestScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/stockTicker/StockKeeperRequestScreen.java @@ -77,7 +77,6 @@ import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.phys.AABB; -import com.simibubi.create.infrastructure.fabric.transfer.item.ItemStackHandler; public class StockKeeperRequestScreen extends AbstractSimiContainerScreen implements ScreenWithStencils { @@ -104,7 +103,8 @@ public CategoryEntry(int targetBECategory, String name, int y) { private static final AllGuiTextures FOOTER = AllGuiTextures.STOCK_KEEPER_REQUEST_FOOTER; StockTickerBlockEntity blockEntity; - public LerpedFloat itemScroll; + public LerpedFloat itemScroll = LerpedFloat.linear() + .startWithValue(0); final int rows = 9; final int cols = 9; @@ -120,7 +120,7 @@ public CategoryEntry(int targetBECategory, String name, int y) { int windowHeight; public EditBox searchBox; - AddressEditBox addressBox; + public AddressEditBox addressBox; int emptyTicks = 0; int successTicks = 0; @@ -164,8 +164,6 @@ public StockKeeperRequestScreen(StockKeeperRequestMenu container, Inventory inv, blockEntity.ticksSinceLastUpdate = 15; emptyTicks = 0; successTicks = 0; - itemScroll = LerpedFloat.linear() - .startWithValue(0); stockKeeper = new WeakReference<>(null); blaze = new WeakReference<>(null); refreshSearchNextTick = false; @@ -490,7 +488,7 @@ protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, in // Render text input hints if (addressBox.getValue() .isBlank() && !addressBox.isFocused()) { - graphics.drawString(Minecraft.getInstance().font, CreateLang.translate("gui.stock_keeper.package_adress") + graphics.drawString(Minecraft.getInstance().font, CreateLang.translate("gui.stock_keeper.package_address") .style(ChatFormatting.ITALIC) .component(), addressBox.getX(), addressBox.getY(), 0xff_CDBCA8, false); } @@ -624,9 +622,7 @@ protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, in int itemWindowY = y + 17; int itemWindowY2 = y + windowHeight - 80; - UIRenderHelper.swapAndBlitColor(minecraft.getMainRenderTarget(), UIRenderHelper.framebuffer); - startStencil(graphics, itemWindowX - 5, itemWindowY, itemWindowX2 - itemWindowX + 10, - itemWindowY2 - itemWindowY); + graphics.enableScissor(itemWindowX - 5, itemWindowY, itemWindowX2 + 10, itemWindowY2); ms.pushPose(); ms.translate(0, -currentScroll * rowHeight, 0); @@ -715,7 +711,7 @@ protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, in .render(graphics, lockX, lockY); ms.popPose(); - endStencil(); + graphics.disableScissor(); // Scroll bar int windowH = windowHeight - 92; @@ -762,8 +758,6 @@ protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, in ms.popPose(); } - - UIRenderHelper.swapAndBlitColor(UIRenderHelper.framebuffer, minecraft.getMainRenderTarget()); } @Override @@ -831,10 +825,12 @@ private void renderItemEntry(GuiGraphics graphics, float scale, BigItemStack ent boolean isRenderingOrders) { int customCount = entry.count; + ItemStack stackWithCount = entry.stack.copyWithCount(customCount); + if (!isRenderingOrders) { - BigItemStack order = getOrderForItem(entry.stack); + BigItemStack order = getOrderForItem(stackWithCount); if (entry.count < BigItemStack.INF) { - int forcedCount = forcedEntries.getCountOf(entry.stack); + int forcedCount = forcedEntries.getCountOf(stackWithCount); if (forcedCount != 0) customCount = Math.min(customCount, -forcedCount - 1); if (order != null) @@ -858,14 +854,14 @@ private void renderItemEntry(GuiGraphics graphics, float scale, BigItemStack ent ms.scale(scaleFromHover, scaleFromHover, scaleFromHover); ms.translate(-18 / 2.0, -18 / 2.0, 0); if (customCount != 0 || craftable) - GuiGameElement.of(entry.stack) + GuiGameElement.of(stackWithCount) .render(graphics); ms.popPose(); ms.pushPose(); ms.translate(0, 0, 190); if (customCount != 0 || craftable) - graphics.renderItemDecorations(font, entry.stack, 1, 1, ""); + graphics.renderItemDecorations(font, stackWithCount, 1, 1, ""); ms.translate(0, 0, 10); if (customCount > 1 || craftable) drawItemCount(graphics, entry.count, customCount);