diff --git a/build.gradle.kts b/build.gradle.kts index fd4acaac..9e40cad6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { // Project properties group = "hellfirepvp.modularmachinery" -version = "2.0.2" +version = "2.0.3" // Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod java { diff --git a/src/main/java/github/kasuminova/mmce/client/gui/GuiContainerDynamic.java b/src/main/java/github/kasuminova/mmce/client/gui/GuiContainerDynamic.java index 908ee6e1..18013151 100644 --- a/src/main/java/github/kasuminova/mmce/client/gui/GuiContainerDynamic.java +++ b/src/main/java/github/kasuminova/mmce/client/gui/GuiContainerDynamic.java @@ -103,6 +103,14 @@ protected void mouseClicked(final int mouseX, final int mouseY, final int mouseB super.mouseClicked(mouseX, mouseY, mouseButton); } + @Override + protected void mouseClickMove(final int mouseX, final int mouseY, final int mouseButton, final long timeSinceLastClick) { + if (widgetController.onMouseClickMove(new MousePos(mouseX, mouseY), mouseButton)) { + return; + } + super.mouseClickMove(mouseX, mouseY, mouseButton, timeSinceLastClick); + } + @Override protected void mouseReleased(final int mouseX, final int mouseY, final int state) { if (widgetController.onMouseReleased(new MousePos(mouseX, mouseY))) { diff --git a/src/main/java/github/kasuminova/mmce/client/gui/widget/container/ScrollingColumn.java b/src/main/java/github/kasuminova/mmce/client/gui/widget/container/ScrollingColumn.java index ff886e65..a8dc39f3 100644 --- a/src/main/java/github/kasuminova/mmce/client/gui/widget/container/ScrollingColumn.java +++ b/src/main/java/github/kasuminova/mmce/client/gui/widget/container/ScrollingColumn.java @@ -119,8 +119,8 @@ public boolean onMouseClick(final MousePos mousePos, final RenderPos renderPos, return false; } RenderPos scrollbarRenderPos = new RenderPos( - width - (scrollbar.getMarginLeft() + scrollbar.getWidth() + scrollbar.getMarginRight()), - height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown())); + width - (scrollbar.getWidth() + scrollbar.getMarginRight()), + height - (scrollbar.getHeight() + scrollbar.getMarginDown())); MousePos scrollbarRelativeMousePos = mousePos.relativeTo(scrollbarRenderPos); if (scrollbar.isMouseOver(scrollbarRelativeMousePos)) { return scrollbar.onMouseClick(scrollbarRelativeMousePos, renderPos.add(scrollbarRenderPos), mouseButton); @@ -183,7 +183,7 @@ public boolean onMouseClickMove(final MousePos mousePos, final RenderPos renderP } RenderPos scrollbarRenderPos = new RenderPos( width - (scrollbar.getWidth() + scrollbar.getMarginRight()), - height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown())); + height - (scrollbar.getHeight() + scrollbar.getMarginDown())); return scrollbar.onMouseClickMove(mousePos.relativeTo(scrollbarRenderPos), renderPos.add(scrollbarRenderPos), mouseButton); } @@ -214,7 +214,7 @@ public boolean onMouseReleased(final MousePos mousePos, final RenderPos renderPo } RenderPos scrollbarRenderPos = new RenderPos( width - (scrollbar.getWidth() + scrollbar.getMarginRight()), - height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown())); + height - (scrollbar.getHeight() + scrollbar.getMarginDown())); return scrollbar.onMouseReleased(mousePos.relativeTo(scrollbarRenderPos), renderPos.add(scrollbarRenderPos)); } @@ -246,7 +246,7 @@ public boolean onMouseDWheel(final MousePos mousePos, final RenderPos renderPos, if (isMouseOver(mousePos)) { RenderPos scrollbarRenderPos = new RenderPos( width - (scrollbar.getWidth() + scrollbar.getMarginRight()), - height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown())); + height - (scrollbar.getHeight() + scrollbar.getMarginDown())); MousePos scrollbarRelativeMousePos = mousePos.relativeTo(scrollbarRenderPos); return scrollbar.onMouseDWheel(scrollbarRelativeMousePos, renderPos.add(scrollbarRenderPos), wheel); } @@ -311,7 +311,7 @@ public List getHoverTooltips(final WidgetGui widgetGui, final MousePos m RenderPos scrollbarRenderPos = new RenderPos( width - (scrollbar.getWidth() + scrollbar.getMarginRight()), - height - (scrollbar.getMarginUp() + scrollbar.getHeight() + scrollbar.getMarginDown())); + height - (scrollbar.getHeight() + scrollbar.getMarginDown())); MousePos scrollbarMousePos = mousePos.relativeTo(scrollbarRenderPos); if (scrollbar.isMouseOver(scrollbarMousePos)) { List hoverTooltips = scrollbar.getHoverTooltips(widgetGui, scrollbarMousePos); diff --git a/src/main/java/github/kasuminova/mmce/client/gui/widget/impl/preview/MachineStructurePreviewPanel.java b/src/main/java/github/kasuminova/mmce/client/gui/widget/impl/preview/MachineStructurePreviewPanel.java index ec661dbf..932dc66c 100644 --- a/src/main/java/github/kasuminova/mmce/client/gui/widget/impl/preview/MachineStructurePreviewPanel.java +++ b/src/main/java/github/kasuminova/mmce/client/gui/widget/impl/preview/MachineStructurePreviewPanel.java @@ -197,15 +197,15 @@ public MachineStructurePreviewPanel(final DynamicMachine machine) { Row bottomMenu = new Row(); if (!machine.getDynamicPatterns().isEmpty()) { bottomMenu.addWidgets( - dynamicPatternPlus.setMarginRight(2).setDisabled(true), - dynamicPatternSubtract.setMarginRight(2).setDisabled(true) + dynamicPatternPlus.setMarginRight(2), + dynamicPatternSubtract.setMarginRight(2) ); } bottomMenu.addWidgets( - placeWorldPreview.setMarginRight(2).setDisabled(true), - enableCycleReplaceableBlocks.setClicked(true).setMarginRight(2).setDisabled(true), - toggleLayerRender.setMarginRight(2).setDisabled(true), - menuBtn.setMarginRight(2) + placeWorldPreview.setMarginRight(2), + enableCycleReplaceableBlocks.setClicked(true).setMarginRight(2), + toggleLayerRender.setMarginRight(2), + menuBtn.setClicked(true).setMarginRight(2) ); bottomMenu.setAbsXY(PANEL_WIDTH - (bottomMenu.getWidth() + 6), 161); diff --git a/src/main/java/github/kasuminova/mmce/client/model/ModelBufferSize.java b/src/main/java/github/kasuminova/mmce/client/model/ModelBufferSize.java index aea7551c..e72f63c7 100644 --- a/src/main/java/github/kasuminova/mmce/client/model/ModelBufferSize.java +++ b/src/main/java/github/kasuminova/mmce/client/model/ModelBufferSize.java @@ -6,6 +6,7 @@ public class ModelBufferSize { + // 6 Faces, 4 Vertexes private static final int BYTES_PER_CUBE = MachineControllerRenderer.VERTEX_FORMAT.getSize() * (6 * 4); private int bufferSize = BYTES_PER_CUBE; // preventing last grow diff --git a/src/main/java/github/kasuminova/mmce/common/tile/MEItemInputBus.java b/src/main/java/github/kasuminova/mmce/common/tile/MEItemInputBus.java index b3d65959..80e524e2 100644 --- a/src/main/java/github/kasuminova/mmce/common/tile/MEItemInputBus.java +++ b/src/main/java/github/kasuminova/mmce/common/tile/MEItemInputBus.java @@ -23,6 +23,7 @@ import java.util.concurrent.locks.ReadWriteLock; public class MEItemInputBus extends MEItemBus { + // A simple cache for AEItemStack. private static final Map AE_STACK_CACHE = new WeakHashMap<>(); private IOInventory configInventory = buildConfigInventory(); diff --git a/src/main/java/github/kasuminova/mmce/common/tile/base/MEFluidBus.java b/src/main/java/github/kasuminova/mmce/common/tile/base/MEFluidBus.java index b25d3332..166789c7 100644 --- a/src/main/java/github/kasuminova/mmce/common/tile/base/MEFluidBus.java +++ b/src/main/java/github/kasuminova/mmce/common/tile/base/MEFluidBus.java @@ -15,8 +15,6 @@ import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; import github.kasuminova.mmce.common.util.AEFluidInventoryUpgradeable; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -49,7 +47,7 @@ public abstract class MEFluidBus extends MEMachineComponent implements protected final UpgradeInventory upgrades; protected final AEFluidInventoryUpgradeable tanks; protected boolean[] changedSlots; - protected int fullCheckCounter = 5; + protected long lastFullCheckTick = 0; protected boolean inTick = false; public MEFluidBus() { @@ -59,16 +57,12 @@ public MEFluidBus() { } protected synchronized int[] getNeedUpdateSlots() { - fullCheckCounter++; - if (fullCheckCounter >= 5) { - fullCheckCounter = 0; + long current = world.getTotalWorldTime(); + if (lastFullCheckTick + 100 < current) { + lastFullCheckTick = current; return IntStream.range(0, tanks.getSlots()).toArray(); } - IntList list = new IntArrayList(); - IntStream.range(0, changedSlots.length) - .filter(i -> changedSlots[i]) - .forEach(list::add); - return list.toIntArray(); + return IntStream.range(0, changedSlots.length).filter(i -> changedSlots[i]).toArray(); } public IAEFluidTank getTanks() { diff --git a/src/main/java/github/kasuminova/mmce/common/tile/base/MEGasBus.java b/src/main/java/github/kasuminova/mmce/common/tile/base/MEGasBus.java index 84beef24..6d235620 100644 --- a/src/main/java/github/kasuminova/mmce/common/tile/base/MEGasBus.java +++ b/src/main/java/github/kasuminova/mmce/common/tile/base/MEGasBus.java @@ -16,8 +16,6 @@ import com.mekeng.github.common.me.inventory.impl.GasInventory; import com.mekeng.github.common.me.storage.IGasStorageChannel; import github.kasuminova.mmce.common.util.GasInventoryHandler; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; import mekanism.api.gas.IGasHandler; import mekanism.common.capabilities.Capabilities; import net.minecraft.item.ItemStack; @@ -48,7 +46,7 @@ public abstract class MEGasBus extends MEMachineComponent implements protected final GasInventory tanks; protected final GasInventoryHandler handler; protected boolean[] changedSlots; - protected int fullCheckCounter = 5; + protected long lastFullCheckTick = 0; protected boolean inTick = false; @@ -60,16 +58,12 @@ public MEGasBus() { } protected synchronized int[] getNeedUpdateSlots() { - fullCheckCounter++; - if (fullCheckCounter >= 5) { - fullCheckCounter = 0; + long current = world.getTotalWorldTime(); + if (lastFullCheckTick + 100 < current) { + lastFullCheckTick = current; return IntStream.range(0, tanks.size()).toArray(); } - IntList list = new IntArrayList(); - IntStream.range(0, changedSlots.length) - .filter(i -> changedSlots[i]) - .forEach(list::add); - return list.toArray(new int[0]); + return IntStream.range(0, changedSlots.length).filter(i -> changedSlots[i]).toArray(); } public GasInventory getTanks() { diff --git a/src/main/java/github/kasuminova/mmce/common/tile/base/MEItemBus.java b/src/main/java/github/kasuminova/mmce/common/tile/base/MEItemBus.java index 31ac6916..82cdc817 100644 --- a/src/main/java/github/kasuminova/mmce/common/tile/base/MEItemBus.java +++ b/src/main/java/github/kasuminova/mmce/common/tile/base/MEItemBus.java @@ -4,8 +4,6 @@ import appeng.api.networking.ticking.IGridTickable; import appeng.api.storage.channels.IItemStorageChannel; import hellfirepvp.modularmachinery.common.util.IOInventory; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -26,22 +24,19 @@ public abstract class MEItemBus extends MEMachineComponent implements IGridTicka protected IOInventory inventory = buildInventory(); protected boolean[] changedSlots = new boolean[inventory.getSlots()]; - protected int fullCheckCounter = 5; + protected int[] failureCounter = new int[inventory.getSlots()]; + protected long lastFullCheckTick = 0; protected boolean inTick = false; public abstract IOInventory buildInventory(); protected synchronized int[] getNeedUpdateSlots() { - fullCheckCounter++; - if (fullCheckCounter >= 5) { - fullCheckCounter = 0; + long current = world.getTotalWorldTime(); + if (lastFullCheckTick + 100 < current) { + lastFullCheckTick = current; return IntStream.range(0, inventory.getSlots()).toArray(); } - IntList list = new IntArrayList(); - IntStream.range(0, changedSlots.length) - .filter(i -> changedSlots[i]) - .forEach(list::add); - return list.toIntArray(); + return IntStream.range(0, changedSlots.length).filter(i -> changedSlots[i]).toArray(); } public IOInventory getInternalInventory() { diff --git a/src/main/java/github/kasuminova/mmce/common/util/InfItemFluidHandler.java b/src/main/java/github/kasuminova/mmce/common/util/InfItemFluidHandler.java index 7d2771df..4e3d6e68 100644 --- a/src/main/java/github/kasuminova/mmce/common/util/InfItemFluidHandler.java +++ b/src/main/java/github/kasuminova/mmce/common/util/InfItemFluidHandler.java @@ -339,7 +339,9 @@ public int getSlotLimit(final int slot) { } public boolean isEmpty() { - return itemStackList.stream().allMatch(ItemStack::isEmpty) && fluidStackList.stream().allMatch(Objects::isNull); + return itemStackList.stream().allMatch(ItemStack::isEmpty) && + fluidStackList.stream().allMatch(Objects::isNull) && + gasStackList.stream().allMatch(Objects::isNull); } public List getItemStackList() { diff --git a/src/main/java/hellfirepvp/modularmachinery/common/integration/crafttweaker/RecipePrimer.java b/src/main/java/hellfirepvp/modularmachinery/common/integration/crafttweaker/RecipePrimer.java index 2179b7fc..97908d20 100644 --- a/src/main/java/hellfirepvp/modularmachinery/common/integration/crafttweaker/RecipePrimer.java +++ b/src/main/java/hellfirepvp/modularmachinery/common/integration/crafttweaker/RecipePrimer.java @@ -606,11 +606,11 @@ public RecipePrimer addGasPerTickOutputs(IGasStack... gasStacks) { @ZenMethod public RecipePrimer addItemInput(IIngredient input) { if (input instanceof IItemStack) { - requireFuel(IOType.INPUT, (IItemStack) input); + requireItem(IOType.INPUT, (IItemStack) input); } else if (input instanceof IOreDictEntry) { - requireFuel(IOType.INPUT, ((IOreDictEntry) input).getName(), 1); + requireItem(IOType.INPUT, ((IOreDictEntry) input).getName(), 1); } else if (input instanceof IngredientStack && input.getInternal() instanceof IOreDictEntry) { - requireFuel(IOType.INPUT, ((IOreDictEntry) input.getInternal()).getName(), input.getAmount()); + requireItem(IOType.INPUT, ((IOreDictEntry) input.getInternal()).getName(), input.getAmount()); } else { CraftTweakerAPI.logError(String.format("[ModularMachinery] Invalid input type %s(%s)! Ignored.", input, input.getClass())); } @@ -621,7 +621,7 @@ public RecipePrimer addItemInput(IIngredient input) { @Deprecated @ZenMethod public RecipePrimer addItemInput(IOreDictEntry oreDict, int amount) { - requireFuel(IOType.INPUT, oreDict.getName(), amount); + requireItem(IOType.INPUT, oreDict.getName(), amount); CraftTweakerAPI.logWarning(String.format("[ModularMachinery] Deprecated method " + "`addItemInput(, %s)`! Consider using `addItemInput( * %s)`", oreDict.getName(), amount, oreDict.getName(), amount) @@ -667,11 +667,11 @@ public RecipePrimer addRandomItemOutput(IngredientArrayPrimer ingredientArrayPri @ZenMethod public RecipePrimer addItemOutput(IIngredient output) { if (output instanceof IItemStack) { - requireFuel(IOType.OUTPUT, (IItemStack) output); + requireItem(IOType.OUTPUT, (IItemStack) output); } else if (output instanceof IOreDictEntry) { - requireFuel(IOType.OUTPUT, ((IOreDictEntry) output).getName(), 1); + requireItem(IOType.OUTPUT, ((IOreDictEntry) output).getName(), 1); } else if (output instanceof IngredientStack && output.getInternal() instanceof IOreDictEntry) { - requireFuel(IOType.OUTPUT, ((IOreDictEntry) output.getInternal()).getName(), output.getAmount()); + requireItem(IOType.OUTPUT, ((IOreDictEntry) output.getInternal()).getName(), output.getAmount()); } else { CraftTweakerAPI.logError(String.format("[ModularMachinery] Invalid output type %s(%s)! Ignored.", output, output.getClass())); } @@ -682,7 +682,7 @@ public RecipePrimer addItemOutput(IIngredient output) { @Deprecated @ZenMethod public RecipePrimer addItemOutput(IOreDictEntry oreDict, int amount) { - requireFuel(IOType.OUTPUT, oreDict.getName(), amount); + requireItem(IOType.OUTPUT, oreDict.getName(), amount); CraftTweakerAPI.logWarning(String.format("[ModularMachinery] Deprecated method " + "`addItemOutput(, %s)`! Consider using `addItemOutput( * %s)`", oreDict.getName(), amount, oreDict.getName(), amount) @@ -786,7 +786,7 @@ private void requireFuel(int requiredTotalBurnTime) { appendComponent(new RequirementItem(IOType.INPUT, requiredTotalBurnTime)); } - private void requireFuel(IOType ioType, IItemStack stack) { + private void requireItem(IOType ioType, IItemStack stack) { ItemStack mcStack = CraftTweakerMC.getItemStack(stack); if (mcStack.isEmpty()) { CraftTweakerAPI.logError("[ModularMachinery] ItemStack not found/unknown item: " + stack.toString()); @@ -800,7 +800,7 @@ private void requireFuel(IOType ioType, IItemStack stack) { appendComponent(ri); } - private void requireFuel(IOType ioType, String oreDictName, int amount) { + private void requireItem(IOType ioType, String oreDictName, int amount) { appendComponent(new RequirementItem(ioType, oreDictName, amount)); }