Skip to content

Commit b71d6da

Browse files
authored
Merge pull request #194 from Circulate233/master
正确的#191的需求的实现方式
2 parents c66505c + a31cae1 commit b71d6da

File tree

6 files changed

+22
-12
lines changed

6 files changed

+22
-12
lines changed

src/main/java/github/kasuminova/mmce/client/gui/GuiMEItemOutputBus.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import net.minecraft.client.resources.I18n;
1414
import net.minecraft.entity.player.EntityPlayer;
1515
import net.minecraft.util.ResourceLocation;
16+
import org.jetbrains.annotations.NotNull;
17+
1618
import java.io.IOException;
1719

1820
public class GuiMEItemOutputBus extends GuiMEItemBus {
@@ -39,7 +41,7 @@ public void initGui() {
3941
}
4042

4143
@Override
42-
protected void actionPerformed(final GuiButton btn) throws IOException {
44+
protected void actionPerformed(@NotNull final GuiButton btn) throws IOException {
4345
super.actionPerformed(btn);
4446

4547
if (btn == this.stackSizeBtn) {
@@ -69,7 +71,7 @@ public CustomStackSizeButton(int x, int y) {
6971

7072
@Override
7173
public String getMessage() {
72-
return "Configure Stack Size";
74+
return I18n.format("gui.meitembus.stack_size.config");
7375
}
7476
}
7577
}

src/main/java/github/kasuminova/mmce/client/gui/GuiMEItemOutputBusStackSize.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
import net.minecraft.client.gui.GuiButton;
1212
import net.minecraft.client.gui.GuiScreen;
1313
import net.minecraft.client.gui.GuiTextField;
14+
import net.minecraft.client.resources.I18n;
1415
import net.minecraft.entity.player.InventoryPlayer;
1516
import net.minecraft.item.ItemStack;
1617
import net.minecraft.util.ResourceLocation;
18+
import org.jetbrains.annotations.NotNull;
1719
import org.lwjgl.input.Keyboard;
1820
import org.lwjgl.input.Mouse;
1921
import java.io.IOException;
@@ -64,7 +66,7 @@ public void initGui() {
6466
this.guiLeft + 154,
6567
this.guiTop,
6668
busIcon,
67-
"ME Machinery Item Output Bus",
69+
busIcon.getDisplayName(),
6870
this.itemRender
6971
));
7072
}
@@ -87,7 +89,7 @@ public void initGui() {
8789
}
8890

8991
@Override
90-
protected void actionPerformed(final GuiButton btn) throws IOException {
92+
protected void actionPerformed(@NotNull final GuiButton btn) throws IOException {
9193
super.actionPerformed(btn);
9294

9395
if (btn == this.originalGuiBtn) {
@@ -101,7 +103,7 @@ protected void actionPerformed(final GuiButton btn) throws IOException {
101103
value = 1;
102104
}
103105
this.sendStackSizeToServer((int) value);
104-
} catch (NumberFormatException e) {
106+
} catch (NumberFormatException ignored) {
105107
}
106108
}
107109

@@ -159,7 +161,7 @@ private long parseValue(String text) {
159161
throw new NumberFormatException("Invalid expression");
160162
}
161163

162-
return (long) Math.round(result);
164+
return Math.round(result);
163165
} catch (Exception ex) {
164166
throw new NumberFormatException("Invalid number or expression");
165167
}
@@ -272,7 +274,7 @@ private void onMouseWheelEvent(int wheel) {
272274

273275
@Override
274276
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
275-
this.fontRenderer.drawString("Stack Size", 8, 6, 0x404040);
277+
this.fontRenderer.drawString(I18n.format("gui.meitembus.stack_size.name"), 8, 6, 0x404040);
276278
}
277279

278280
@Override
@@ -307,7 +309,7 @@ public void onGuiClosed() {
307309
try {
308310
ContainerMEItemOutputBusStackSize container = (ContainerMEItemOutputBusStackSize) this.inventorySlots;
309311
sendStackSizeToServer(container.getStackSize());
310-
} catch (Exception ex) {
312+
} catch (Exception ignored) {
311313
}
312314
}
313315
}

src/main/java/github/kasuminova/mmce/common/container/ContainerMEItemOutputBusStackSize.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import appeng.container.guisync.GuiSync;
66
import github.kasuminova.mmce.common.tile.MEItemOutputBus;
77
import net.minecraft.entity.player.InventoryPlayer;
8+
import org.jetbrains.annotations.NotNull;
89

910
public class ContainerMEItemOutputBusStackSize extends AEBaseContainer {
1011

1112
private final MEItemOutputBus outputBus;
1213

1314
@GuiSync(0)
14-
public int stackSize = Integer.MAX_VALUE;
15+
public int stackSize;
1516

1617
public ContainerMEItemOutputBusStackSize(final InventoryPlayer inventoryPlayer, final MEItemOutputBus outputBus) {
1718
super(inventoryPlayer, outputBus);
@@ -36,7 +37,7 @@ public void detectAndSendChanges() {
3637
}
3738

3839
@Override
39-
public void onContainerClosed(net.minecraft.entity.player.EntityPlayer playerIn) {
40+
public void onContainerClosed(@NotNull net.minecraft.entity.player.EntityPlayer playerIn) {
4041
super.onContainerClosed(playerIn);
4142

4243
if (!playerIn.world.isRemote) {

src/main/java/hellfirepvp/modularmachinery/common/util/ItemUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ public static int insertAll(@Nonnull ItemStack stack, IItemHandlerModifiable han
274274
int inserted = 0;
275275
for (int i = 0; i < handler.getSlots(); i++) {
276276
int maxStackSize = handler.getSlotLimit(i);
277+
if (maxStackSize <= 64) {
278+
maxStackSize = Math.min(maxStackSize, stack.getMaxStackSize());
279+
}
277280
ItemStack in = handler.getStackInSlot(i);
278281
int count = in.getCount();
279282
if (count >= maxStackSize) {
@@ -543,7 +546,6 @@ public static ItemStack getOredictItem(final RecipeCraftingContext context, fina
543546
}
544547

545548
@Nonnull
546-
@SuppressWarnings("unchecked")
547549
public static List<ProcessingComponent<?>> copyItemHandlerComponents(final List<ProcessingComponent<?>> components) {
548550
List<ProcessingComponent<?>> list = new ArrayList<>();
549551
for (ProcessingComponent<?> component : components) {
@@ -568,7 +570,6 @@ public static List<ProcessingComponent<?>> copyItemHandlerComponents(final List<
568570
}
569571

570572
@Nonnull
571-
@SuppressWarnings("unchecked")
572573
public static List<ProcessingComponent<?>> fastCopyItemHandlerComponents(final List<ProcessingComponent<?>> components) {
573574
List<ProcessingComponent<?>> list = new ArrayList<>();
574575
for (ProcessingComponent<?> component : components) {

src/main/resources/assets/modularmachinery/lang/en_US.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ gui.meiteminputbus.inv_action.divide=The wheel is scrolling down to halve the nu
7575
gui.meiteminputbus.items_marked=Items marked: %s
7676
gui.meitembus.item_cached=Items Cached: %s
7777
gui.meitembus.nbt_stored=Items have been stored internally.
78+
gui.meitembus.stack_size.name=Max Stack Size
79+
gui.meitembus.stack_size.config=Configure Max Stack Size
7880

7981
gui.mefluidoutputbus.title=ME Machinery Fluid Output Bus
8082
gui.mefluidinputbus.title=ME Machinery Fluid Input Bus

src/main/resources/assets/modularmachinery/lang/zh_CN.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ gui.meiteminputbus.inv_action.divide=按下 %s 组合键时,滚轮向下滚动
7575
gui.meiteminputbus.items_marked=已标记物品:%s
7676
gui.meitembus.item_cached=已缓存物品: %s
7777
gui.meitembus.nbt_stored=内部已存储物品。
78+
gui.meitembus.stack_size.name=最大堆叠数量
79+
gui.meitembus.stack_size.config=配置最大堆叠数量
7880

7981
gui.mefluidoutputbus.title=ME 机械流体输出总线
8082
gui.mefluidinputbus.title=ME 机械流体输入总线

0 commit comments

Comments
 (0)