Skip to content

Commit f7716a1

Browse files
committed
- Structure Preview now expands the menu by default.
- Fixed the problem of incorrectly judging space for scrollbars. - Optimised performance of MEItemBus / MEFluidBus / MEGasBus. - Added gas judgement to InfItemFluidHandler#isEmpty. - Fix typos.
1 parent bd41c13 commit f7716a1

File tree

11 files changed

+52
-57
lines changed

11 files changed

+52
-57
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212

1313
// Project properties
1414
group = "hellfirepvp.modularmachinery"
15-
version = "2.0.2"
15+
version = "2.0.3"
1616

1717
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
1818
java {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ protected void mouseClicked(final int mouseX, final int mouseY, final int mouseB
103103
super.mouseClicked(mouseX, mouseY, mouseButton);
104104
}
105105

106+
@Override
107+
protected void mouseClickMove(final int mouseX, final int mouseY, final int mouseButton, final long timeSinceLastClick) {
108+
if (widgetController.onMouseClickMove(new MousePos(mouseX, mouseY), mouseButton)) {
109+
return;
110+
}
111+
super.mouseClickMove(mouseX, mouseY, mouseButton, timeSinceLastClick);
112+
}
113+
106114
@Override
107115
protected void mouseReleased(final int mouseX, final int mouseY, final int state) {
108116
if (widgetController.onMouseReleased(new MousePos(mouseX, mouseY))) {

src/main/java/github/kasuminova/mmce/client/gui/widget/container/ScrollingColumn.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public boolean onMouseClick(final MousePos mousePos, final RenderPos renderPos,
119119
return false;
120120
}
121121
RenderPos scrollbarRenderPos = new RenderPos(
122-
width - (scrollbar.getMarginLeft() + scrollbar.getWidth() + scrollbar.getMarginRight()),
123-
height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown()));
122+
width - (scrollbar.getWidth() + scrollbar.getMarginRight()),
123+
height - (scrollbar.getHeight() + scrollbar.getMarginDown()));
124124
MousePos scrollbarRelativeMousePos = mousePos.relativeTo(scrollbarRenderPos);
125125
if (scrollbar.isMouseOver(scrollbarRelativeMousePos)) {
126126
return scrollbar.onMouseClick(scrollbarRelativeMousePos, renderPos.add(scrollbarRenderPos), mouseButton);
@@ -183,7 +183,7 @@ public boolean onMouseClickMove(final MousePos mousePos, final RenderPos renderP
183183
}
184184
RenderPos scrollbarRenderPos = new RenderPos(
185185
width - (scrollbar.getWidth() + scrollbar.getMarginRight()),
186-
height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown()));
186+
height - (scrollbar.getHeight() + scrollbar.getMarginDown()));
187187
return scrollbar.onMouseClickMove(mousePos.relativeTo(scrollbarRenderPos), renderPos.add(scrollbarRenderPos), mouseButton);
188188
}
189189

@@ -214,7 +214,7 @@ public boolean onMouseReleased(final MousePos mousePos, final RenderPos renderPo
214214
}
215215
RenderPos scrollbarRenderPos = new RenderPos(
216216
width - (scrollbar.getWidth() + scrollbar.getMarginRight()),
217-
height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown()));
217+
height - (scrollbar.getHeight() + scrollbar.getMarginDown()));
218218
return scrollbar.onMouseReleased(mousePos.relativeTo(scrollbarRenderPos), renderPos.add(scrollbarRenderPos));
219219
}
220220

@@ -246,7 +246,7 @@ public boolean onMouseDWheel(final MousePos mousePos, final RenderPos renderPos,
246246
if (isMouseOver(mousePos)) {
247247
RenderPos scrollbarRenderPos = new RenderPos(
248248
width - (scrollbar.getWidth() + scrollbar.getMarginRight()),
249-
height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown()));
249+
height - (scrollbar.getHeight() + scrollbar.getMarginDown()));
250250
MousePos scrollbarRelativeMousePos = mousePos.relativeTo(scrollbarRenderPos);
251251
return scrollbar.onMouseDWheel(scrollbarRelativeMousePos, renderPos.add(scrollbarRenderPos), wheel);
252252
}
@@ -311,7 +311,7 @@ public List<String> getHoverTooltips(final WidgetGui widgetGui, final MousePos m
311311

312312
RenderPos scrollbarRenderPos = new RenderPos(
313313
width - (scrollbar.getWidth() + scrollbar.getMarginRight()),
314-
height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown()));
314+
height - (scrollbar.getHeight() + scrollbar.getMarginDown()));
315315
MousePos scrollbarMousePos = mousePos.relativeTo(scrollbarRenderPos);
316316
if (scrollbar.isMouseOver(scrollbarMousePos)) {
317317
List<String> hoverTooltips = scrollbar.getHoverTooltips(widgetGui, scrollbarMousePos);

src/main/java/github/kasuminova/mmce/client/gui/widget/impl/preview/MachineStructurePreviewPanel.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ public MachineStructurePreviewPanel(final DynamicMachine machine) {
197197
Row bottomMenu = new Row();
198198
if (!machine.getDynamicPatterns().isEmpty()) {
199199
bottomMenu.addWidgets(
200-
dynamicPatternPlus.setMarginRight(2).setDisabled(true),
201-
dynamicPatternSubtract.setMarginRight(2).setDisabled(true)
200+
dynamicPatternPlus.setMarginRight(2),
201+
dynamicPatternSubtract.setMarginRight(2)
202202
);
203203
}
204204
bottomMenu.addWidgets(
205-
placeWorldPreview.setMarginRight(2).setDisabled(true),
206-
enableCycleReplaceableBlocks.setClicked(true).setMarginRight(2).setDisabled(true),
207-
toggleLayerRender.setMarginRight(2).setDisabled(true),
208-
menuBtn.setMarginRight(2)
205+
placeWorldPreview.setMarginRight(2),
206+
enableCycleReplaceableBlocks.setClicked(true).setMarginRight(2),
207+
toggleLayerRender.setMarginRight(2),
208+
menuBtn.setClicked(true).setMarginRight(2)
209209
);
210210
bottomMenu.setAbsXY(PANEL_WIDTH - (bottomMenu.getWidth() + 6), 161);
211211

src/main/java/github/kasuminova/mmce/client/model/ModelBufferSize.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
public class ModelBufferSize {
88

9+
// 6 Faces, 4 Vertexes
910
private static final int BYTES_PER_CUBE = MachineControllerRenderer.VERTEX_FORMAT.getSize() * (6 * 4);
1011

1112
private int bufferSize = BYTES_PER_CUBE; // preventing last grow

src/main/java/github/kasuminova/mmce/common/tile/MEItemInputBus.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.concurrent.locks.ReadWriteLock;
2424

2525
public class MEItemInputBus extends MEItemBus {
26+
// A simple cache for AEItemStack.
2627
private static final Map<ItemStack, IAEItemStack> AE_STACK_CACHE = new WeakHashMap<>();
2728
private IOInventory configInventory = buildConfigInventory();
2829

src/main/java/github/kasuminova/mmce/common/tile/base/MEFluidBus.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import appeng.util.inv.IAEAppEngInventory;
1616
import appeng.util.inv.InvOperation;
1717
import github.kasuminova.mmce.common.util.AEFluidInventoryUpgradeable;
18-
import it.unimi.dsi.fastutil.ints.IntArrayList;
19-
import it.unimi.dsi.fastutil.ints.IntList;
2018
import net.minecraft.item.ItemStack;
2119
import net.minecraft.nbt.NBTTagCompound;
2220
import net.minecraft.tileentity.TileEntity;
@@ -49,7 +47,7 @@ public abstract class MEFluidBus extends MEMachineComponent implements
4947
protected final UpgradeInventory upgrades;
5048
protected final AEFluidInventoryUpgradeable tanks;
5149
protected boolean[] changedSlots;
52-
protected int fullCheckCounter = 5;
50+
protected long lastFullCheckTick = 0;
5351
protected boolean inTick = false;
5452

5553
public MEFluidBus() {
@@ -59,16 +57,12 @@ public MEFluidBus() {
5957
}
6058

6159
protected synchronized int[] getNeedUpdateSlots() {
62-
fullCheckCounter++;
63-
if (fullCheckCounter >= 5) {
64-
fullCheckCounter = 0;
60+
long current = world.getTotalWorldTime();
61+
if (lastFullCheckTick + 100 < current) {
62+
lastFullCheckTick = current;
6563
return IntStream.range(0, tanks.getSlots()).toArray();
6664
}
67-
IntList list = new IntArrayList();
68-
IntStream.range(0, changedSlots.length)
69-
.filter(i -> changedSlots[i])
70-
.forEach(list::add);
71-
return list.toIntArray();
65+
return IntStream.range(0, changedSlots.length).filter(i -> changedSlots[i]).toArray();
7266
}
7367

7468
public IAEFluidTank getTanks() {

src/main/java/github/kasuminova/mmce/common/tile/base/MEGasBus.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import com.mekeng.github.common.me.inventory.impl.GasInventory;
1717
import com.mekeng.github.common.me.storage.IGasStorageChannel;
1818
import github.kasuminova.mmce.common.util.GasInventoryHandler;
19-
import it.unimi.dsi.fastutil.ints.IntArrayList;
20-
import it.unimi.dsi.fastutil.ints.IntList;
2119
import mekanism.api.gas.IGasHandler;
2220
import mekanism.common.capabilities.Capabilities;
2321
import net.minecraft.item.ItemStack;
@@ -48,7 +46,7 @@ public abstract class MEGasBus extends MEMachineComponent implements
4846
protected final GasInventory tanks;
4947
protected final GasInventoryHandler handler;
5048
protected boolean[] changedSlots;
51-
protected int fullCheckCounter = 5;
49+
protected long lastFullCheckTick = 0;
5250

5351
protected boolean inTick = false;
5452

@@ -60,16 +58,12 @@ public MEGasBus() {
6058
}
6159

6260
protected synchronized int[] getNeedUpdateSlots() {
63-
fullCheckCounter++;
64-
if (fullCheckCounter >= 5) {
65-
fullCheckCounter = 0;
61+
long current = world.getTotalWorldTime();
62+
if (lastFullCheckTick + 100 < current) {
63+
lastFullCheckTick = current;
6664
return IntStream.range(0, tanks.size()).toArray();
6765
}
68-
IntList list = new IntArrayList();
69-
IntStream.range(0, changedSlots.length)
70-
.filter(i -> changedSlots[i])
71-
.forEach(list::add);
72-
return list.toArray(new int[0]);
66+
return IntStream.range(0, changedSlots.length).filter(i -> changedSlots[i]).toArray();
7367
}
7468

7569
public GasInventory getTanks() {

src/main/java/github/kasuminova/mmce/common/tile/base/MEItemBus.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import appeng.api.networking.ticking.IGridTickable;
55
import appeng.api.storage.channels.IItemStorageChannel;
66
import hellfirepvp.modularmachinery.common.util.IOInventory;
7-
import it.unimi.dsi.fastutil.ints.IntArrayList;
8-
import it.unimi.dsi.fastutil.ints.IntList;
97
import net.minecraft.item.ItemStack;
108
import net.minecraft.nbt.NBTTagCompound;
119
import net.minecraft.util.EnumFacing;
@@ -26,22 +24,19 @@ public abstract class MEItemBus extends MEMachineComponent implements IGridTicka
2624

2725
protected IOInventory inventory = buildInventory();
2826
protected boolean[] changedSlots = new boolean[inventory.getSlots()];
29-
protected int fullCheckCounter = 5;
27+
protected int[] failureCounter = new int[inventory.getSlots()];
28+
protected long lastFullCheckTick = 0;
3029
protected boolean inTick = false;
3130

3231
public abstract IOInventory buildInventory();
3332

3433
protected synchronized int[] getNeedUpdateSlots() {
35-
fullCheckCounter++;
36-
if (fullCheckCounter >= 5) {
37-
fullCheckCounter = 0;
34+
long current = world.getTotalWorldTime();
35+
if (lastFullCheckTick + 100 < current) {
36+
lastFullCheckTick = current;
3837
return IntStream.range(0, inventory.getSlots()).toArray();
3938
}
40-
IntList list = new IntArrayList();
41-
IntStream.range(0, changedSlots.length)
42-
.filter(i -> changedSlots[i])
43-
.forEach(list::add);
44-
return list.toIntArray();
39+
return IntStream.range(0, changedSlots.length).filter(i -> changedSlots[i]).toArray();
4540
}
4641

4742
public IOInventory getInternalInventory() {

src/main/java/github/kasuminova/mmce/common/util/InfItemFluidHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ public int getSlotLimit(final int slot) {
339339
}
340340

341341
public boolean isEmpty() {
342-
return itemStackList.stream().allMatch(ItemStack::isEmpty) && fluidStackList.stream().allMatch(Objects::isNull);
342+
return itemStackList.stream().allMatch(ItemStack::isEmpty) &&
343+
fluidStackList.stream().allMatch(Objects::isNull) &&
344+
gasStackList.stream().allMatch(Objects::isNull);
343345
}
344346

345347
public List<ItemStack> getItemStackList() {

0 commit comments

Comments
 (0)