Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double patterns cribs #3461

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions src/main/java/gregtech/api/gui/modularui/GTUITextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ public static FallbackableUITexture fallbackableProgressbar(String name, UITextu
.fullImage(GregTech.ID, "gui/overlay_button/hourglass");
public static final UITexture OVERLAY_BUTTON_PATTERN_OPTIMIZE = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/pattern_optimize");
public static final UITexture OVERLAY_BUTTON_X2 = UITexture.fullImage(GregTech.ID, "gui/overlay_button/x2");

public static final UITexture OVERLAY_BUTTON_LIQUIDMODE = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/LiquidMode");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
Expand All @@ -39,6 +40,8 @@

import org.apache.commons.lang3.ArrayUtils;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

import com.glodblock.github.common.item.ItemFluidPacket;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -75,9 +78,11 @@
import appeng.items.misc.ItemEncodedPattern;
import appeng.items.tools.quartz.ToolQuartzCuttingKnife;
import appeng.me.GridAccessException;
import appeng.me.cache.CraftingGridCache;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
import appeng.util.IWideReadableNumberConverter;
import appeng.util.PatternMultiplierHelper;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import gregtech.GTMod;
Expand Down Expand Up @@ -745,7 +750,17 @@ protected ItemStack getItemStackForRendering(Slot slotIn) {
.addTooltip(0, "Pattern Optimization:\n§7Allowed")
.addTooltip(1, "Pattern Optimization:\n§7Disabled")
.setPos(170, 10)
.setSize(16, 16));
.setSize(16, 16))
.widget(new ButtonWidget().setOnClick((clickData, widget) -> {
int val = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? 1 : 0;
if (Mouse.isButtonDown(1)) val |= 0b10;
doublePatterns(val);
})
.setPlayClickSound(true)
.setBackground(GTUITextures.BUTTON_STANDARD, GTUITextures.OVERLAY_BUTTON_X2)
.addTooltip(StatCollector.translateToLocal("gui.tooltips.appliedenergistics2.DoublePatterns"))
.setSize(16, 5)
.setPos(170, 4));;
}

@Override
Expand Down Expand Up @@ -1054,4 +1069,31 @@ public List<ItemStack> getItemsForHoloGlasses() {
}
return list;
}

public void doublePatterns(int val) {
Alexdoru marked this conversation as resolved.
Show resolved Hide resolved
boolean fast = (val & 1) != 0;
boolean backwards = (val & 2) != 0;
CraftingGridCache.pauseRebuilds();
try {
IInventory patterns = this.getPatterns();
TileEntity te = this.getTileEntity();
for (int i = 0; i < patterns.getSizeInventory(); i++) {
Alexdoru marked this conversation as resolved.
Show resolved Hide resolved
ItemStack stack = patterns.getStackInSlot(i);
if (stack != null && stack.getItem() instanceof ICraftingPatternItem cpi) {
ICraftingPatternDetails details = cpi.getPatternForItem(stack, te.getWorldObj());
if (details != null && !details.isCraftable()) {
int max = backwards ? PatternMultiplierHelper.getMaxBitDivider(details)
: PatternMultiplierHelper.getMaxBitMultiplier(details);
if (max > 0) {
ItemStack copy = stack.copy();
PatternMultiplierHelper
.applyModification(copy, (fast ? Math.min(3, max) : 1) * (backwards ? -1 : 1));
patterns.setInventorySlotContents(i, copy);
}
}
}
}
} catch (Throwable ignored) {}
CraftingGridCache.unpauseRebuilds();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading