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

Made the pasteGUI use the current offset when changing it again. #566

Merged
Merged
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 @@ -15,7 +15,7 @@

public enum GuiMod {
COPY(GadgetCopyPaste::getGadget, stack -> () -> new CopyGUI(stack)),
PASTE(GadgetCopyPaste::getGadget, stack -> () -> new PasteGUI()),
PASTE(GadgetCopyPaste::getGadget, stack -> () -> new PasteGUI(stack)),
DESTRUCTION(GadgetDestruction::getGadget, stack -> () -> new DestructionGUI(stack)),
MATERIAL_LIST(TemplateItem::getTemplateItem, stack -> () -> new MaterialListGUI(stack));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void init() {
if (GadgetCopyPaste.getToolMode(tool) == GadgetCopyPaste.ToolMode.COPY)
getMinecraft().displayGuiScreen(new CopyGUI(tool));
else
getMinecraft().displayGuiScreen(new PasteGUI());
getMinecraft().displayGuiScreen(new PasteGUI(tool));
return true;
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.direwolf20.buildinggadgets.client.screen;

import com.direwolf20.buildinggadgets.client.screen.components.GuiIncrementer;
import com.direwolf20.buildinggadgets.common.items.GadgetCopyPaste;
import com.direwolf20.buildinggadgets.common.network.PacketHandler;
import com.direwolf20.buildinggadgets.common.network.packets.PacketPasteGUI;
import com.direwolf20.buildinggadgets.common.util.lang.GuiTranslation;
Expand All @@ -14,6 +15,8 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.AbstractButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.StringTextComponent;

import java.util.ArrayList;
Expand All @@ -22,9 +25,11 @@
public class PasteGUI extends Screen {
private GuiIncrementer X, Y, Z;
private List<GuiIncrementer> fields = new ArrayList<>();
private ItemStack copyPasteTool;

PasteGUI() {
PasteGUI(ItemStack tool) {
super(new StringTextComponent(""));
this.copyPasteTool = tool;
}

@Override
Expand All @@ -38,6 +43,11 @@ public void init() {
fields.add(Y = new GuiIncrementer(x - GuiIncrementer.WIDTH / 2, y - 10, -16, 16, this::onChange));
fields.add(Z = new GuiIncrementer(x + (GuiIncrementer.WIDTH / 2) + 10, y - 10, -16, 16, this::onChange));

BlockPos currentOffset = GadgetCopyPaste.getRelativeVector(this.copyPasteTool);
X.setValue(currentOffset.getX());
Y.setValue(currentOffset.getY());
Z.setValue(currentOffset.getZ());

List<AbstractButton> buttons = new ArrayList<AbstractButton>() {{
add(new CopyGUI.CenteredButton(y + 20, 70, GuiTranslation.SINGLE_CONFIRM.componentTranslation(), (button) -> {
PacketHandler.sendToServer(new PacketPasteGUI(X.getValue(), Y.getValue(), Z.getValue()));
Expand Down