Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemVariant> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<StockKeeperRequestMenu>
implements ScreenWithStencils {
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -762,8 +758,6 @@ protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, in

ms.popPose();
}

UIRenderHelper.swapAndBlitColor(UIRenderHelper.framebuffer, minecraft.getMainRenderTarget());
}

@Override
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down