aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-03 14:16:19 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-03 14:16:19 +0800
commit02f72e3d47b0f5133f4f984a0bd51968e0c9d8fd (patch)
tree7de3997506e738bdd3a1c4ab61a95710fb88c1b4 /src/main/java
parentd9c1ed900922605292f819a8e022b0c1dac242b5 (diff)
downloadRoughlyEnoughItems-02f72e3d47b0f5133f4f984a0bd51968e0c9d8fd.tar.gz
RoughlyEnoughItems-02f72e3d47b0f5133f4f984a0bd51968e0c9d8fd.tar.bz2
RoughlyEnoughItems-02f72e3d47b0f5133f4f984a0bd51968e0c9d8fd.zip
1.4 Bug Fixes
Diffstat (limited to 'src/main/java')
-rwxr-xr-xsrc/main/java/me/shedaniel/Core.java8
-rw-r--r--src/main/java/me/shedaniel/config/REIConfig.java1
-rw-r--r--src/main/java/me/shedaniel/gui/ConfigGui.java29
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/GuiItemList.java21
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/REIRenderHelper.java30
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/RecipeGui.java111
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/widget/REISlot.java3
-rwxr-xr-xsrc/main/java/me/shedaniel/gui/widget/TextBox.java10
-rwxr-xr-xsrc/main/java/me/shedaniel/listenerdefinitions/IMixinGuiContainer.java5
-rwxr-xr-xsrc/main/java/me/shedaniel/listeners/DrawContainerListener.java8
-rwxr-xr-xsrc/main/java/me/shedaniel/listeners/ResizeListener.java14
-rwxr-xr-xsrc/main/java/me/shedaniel/mixins/MixinGuiContainer.java10
-rw-r--r--src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java14
-rwxr-xr-xsrc/main/java/me/shedaniel/network/CheatPacket.java6
14 files changed, 189 insertions, 81 deletions
diff --git a/src/main/java/me/shedaniel/Core.java b/src/main/java/me/shedaniel/Core.java
index 695f032dc..4bfbb3990 100755
--- a/src/main/java/me/shedaniel/Core.java
+++ b/src/main/java/me/shedaniel/Core.java
@@ -8,6 +8,8 @@ import com.google.gson.stream.JsonWriter;
import me.shedaniel.config.REIConfig;
import me.shedaniel.network.CheatPacket;
import me.shedaniel.network.DeletePacket;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
import net.minecraft.network.EnumPacketDirection;
import org.dimdev.rift.listener.PacketAdder;
import org.dimdev.riftloader.RiftLoader;
@@ -42,11 +44,13 @@ public class Core implements PacketAdder, InitializationListener {
public static final File configFile = new File(RiftLoader.instance.configDir, "rei.json");
public static REIConfig config;
+ public static boolean centreSearchBox;
@Override
public void onInitialization() {
try {
loadConfig();
+ centreSearchBox = config.centreSearchBox;
} catch (IOException e) {
e.printStackTrace();
}
@@ -84,4 +88,8 @@ public class Core implements PacketAdder, InitializationListener {
}
}
+ public static void cheatItems(ItemStack cheatedStack) {
+ Minecraft.getInstance().getConnection().sendPacket(new CheatPacket(cheatedStack));
+ }
+
}
diff --git a/src/main/java/me/shedaniel/config/REIConfig.java b/src/main/java/me/shedaniel/config/REIConfig.java
index 4acaa102a..9e6b3d36f 100644
--- a/src/main/java/me/shedaniel/config/REIConfig.java
+++ b/src/main/java/me/shedaniel/config/REIConfig.java
@@ -12,5 +12,6 @@ public class REIConfig {
public int recipeKeyBind = KeyEvent.VK_R;
public int usageKeyBind = KeyEvent.VK_U;
public int hideKeyBind = KeyEvent.VK_O;
+ public boolean centreSearchBox = false;
}
diff --git a/src/main/java/me/shedaniel/gui/ConfigGui.java b/src/main/java/me/shedaniel/gui/ConfigGui.java
index f075ca903..b7426af30 100644
--- a/src/main/java/me/shedaniel/gui/ConfigGui.java
+++ b/src/main/java/me/shedaniel/gui/ConfigGui.java
@@ -4,11 +4,13 @@ import me.shedaniel.ClientListener;
import me.shedaniel.Core;
import me.shedaniel.gui.widget.KeyBindButton;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.InputMappings;
import java.io.IOException;
+import java.util.Arrays;
public class ConfigGui extends GuiScreen {
@@ -29,7 +31,7 @@ public class ConfigGui extends GuiScreen {
e.printStackTrace();
}
}));
- addButton(new KeyBindButton(997, parent.width / 2 - 20, 60, 80, 20, Core.config.usageKeyBind, key -> {
+ addButton(new KeyBindButton(998, parent.width / 2 - 20, 60, 80, 20, Core.config.usageKeyBind, key -> {
Core.config.usageKeyBind = key;
ClientListener.useKeybind.setKey(key);
try {
@@ -38,7 +40,7 @@ public class ConfigGui extends GuiScreen {
e.printStackTrace();
}
}));
- addButton(new KeyBindButton(997, parent.width / 2 - 20, 90, 80, 20, Core.config.hideKeyBind, key -> {
+ addButton(new KeyBindButton(999, parent.width / 2 - 20, 90, 80, 20, Core.config.hideKeyBind, key -> {
Core.config.hideKeyBind = key;
ClientListener.hideKeybind.setKey(key);
try {
@@ -47,6 +49,29 @@ public class ConfigGui extends GuiScreen {
e.printStackTrace();
}
}));
+ addButton(new GuiButton(1000, parent.width / 2 - 90, 120, 150, 20, "") {
+ @Override
+ public void onClick(double double_1, double double_2) {
+ Core.config.centreSearchBox = !Core.config.centreSearchBox;
+ try {
+ Core.saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void render(int int_1, int int_2, float float_1) {
+ this.displayString = I18n.format("text.rei.centre_searchbox", Core.config.centreSearchBox ? "§a" : "§c", Core.config.centreSearchBox);
+ super.render(int_1, int_2, float_1);
+ if (this.hovered)
+ drawSuggestion(int_1, int_2);
+ }
+
+ protected void drawSuggestion(int x, int y) {
+ drawHoveringText(Arrays.asList(I18n.format("text.rei.centre_searchbox.tooltip").split("\n")), x, y);
+ }
+ });
}
@Override
diff --git a/src/main/java/me/shedaniel/gui/GuiItemList.java b/src/main/java/me/shedaniel/gui/GuiItemList.java
index b3219ee29..c3917b175 100755
--- a/src/main/java/me/shedaniel/gui/GuiItemList.java
+++ b/src/main/java/me/shedaniel/gui/GuiItemList.java
@@ -1,6 +1,7 @@
package me.shedaniel.gui;
import me.shedaniel.ClientListener;
+import me.shedaniel.Core;
import me.shedaniel.gui.widget.Button;
import me.shedaniel.gui.widget.Control;
import me.shedaniel.gui.widget.REISlot;
@@ -10,6 +11,7 @@ import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -27,7 +29,7 @@ import java.util.stream.Stream;
public class GuiItemList extends Drawable {
- public static final int FOOTERSIZE = 44;
+ public final int FOOTERSIZE;
private GuiContainer overlayedGui;
private static int page = 0;
private ArrayList<REISlot> displaySlots;
@@ -42,10 +44,12 @@ public class GuiItemList extends Drawable {
private Control lastHovered;
protected boolean visible = true;
private int oldGuiLeft = 0;
- private boolean cheatMode = false;
+ private boolean cheatMode = false; private Button btnCategoryPageLeft, btnCategoryPageRight;
+ public Button btnRecipeLeft, btnRecipeRight;
public GuiItemList(GuiContainer overlayedGui) {
super(calculateRect(overlayedGui));
+ FOOTERSIZE = Core.centreSearchBox ? 18 : 44;
displaySlots = new ArrayList<>();
controls = new ArrayList<>();
this.overlayedGui = overlayedGui;
@@ -98,7 +102,7 @@ public class GuiItemList extends Drawable {
if (searchBox != null) {
savedText = searchBox.getText();
}
- searchBox = new TextBox(rect.x, rect.height - 31, rect.width - 4, 18);
+ searchBox = new TextBox(getSearchBoxArea());
searchBox.setText(savedText);
controls.add(searchBox);
buttonCheating = new Button(5, 5, 45, 20, getCheatModeText());
@@ -116,6 +120,16 @@ public class GuiItemList extends Drawable {
controls.addAll(displaySlots);
}
+ private Rectangle getSearchBoxArea() {
+ int ch = ((IMixinGuiContainer) overlayedGui).getContainerHeight(), cw = ((IMixinGuiContainer) overlayedGui).getContainerWidth();
+ if (Core.config.centreSearchBox) {
+ if (ch + 4 + 18 > rect.height) //Will be out of bounds
+ return new Rectangle(overlayedGui.width / 2 - cw / 2, rect.height + 100, cw, 18);
+ return new Rectangle(overlayedGui.width / 2 - cw / 2, rect.height - 31, cw, 18);
+ }
+ return new Rectangle(rect.x, rect.height - 31, rect.width - 4, 18);
+ }
+
private void fillSlots() {
page = MathHelper.clamp(page, 0, (int) Math.floor(view.size() / displaySlots.size()));
int firstSlot = page * displaySlots.size();
@@ -179,6 +193,7 @@ public class GuiItemList extends Drawable {
updateButtons();
controls.forEach(Control::draw);
String header = String.format("%s/%s", page + 1, ((int) Math.floor(view.size() / displaySlots.size())) + 1);
+ RenderHelper.disableStandardItemLighting();
Minecraft.getInstance().fontRenderer.drawStringWithShadow(header, rect.x + (rect.width / 2) - (Minecraft.getInstance().fontRenderer.getStringWidth(header) / 2), rect.y + 10, -1);
GlStateManager.popMatrix();
}
diff --git a/src/main/java/me/shedaniel/gui/REIRenderHelper.java b/src/main/java/me/shedaniel/gui/REIRenderHelper.java
index 08f937234..a6c4cdac3 100755
--- a/src/main/java/me/shedaniel/gui/REIRenderHelper.java
+++ b/src/main/java/me/shedaniel/gui/REIRenderHelper.java
@@ -17,8 +17,10 @@ import org.dimdev.riftloader.RiftLoader;
import java.awt.*;
import java.util.ArrayList;
+import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
@@ -124,7 +126,12 @@ public class REIRenderHelper {
}
}
if (overlayedGui instanceof RecipeGui) {
- List<Control> controls = ((RecipeGui) overlayedGui).controls;
+ List<Control> controls = new LinkedList<>(((RecipeGui) overlayedGui).controls);
+ if (((RecipeGui) overlayedGui).slots != null)
+ controls.addAll(((RecipeGui) overlayedGui).slots);
+ controls.addAll(reiGui.controls.stream().filter(control -> {
+ return control instanceof REISlot;
+ }).collect(Collectors.toList()));
Optional<Control> ctrl = controls.stream().filter(Control::isHighlighted).filter(Control::isEnabled).findFirst();
if (ctrl.isPresent()) {
try {
@@ -178,6 +185,27 @@ public class REIRenderHelper {
public static boolean mouseScrolled(double direction) {
if (!reiGui.visible)
return false;
+ if (Minecraft.getInstance().currentScreen instanceof RecipeGui) {
+ MainWindow window = REIRenderHelper.getResolution();
+ Point mouse = new Point((int) Minecraft.getInstance().mouseHelper.getMouseX(), (int) Minecraft.getInstance().mouseHelper.getMouseY());
+ int mouseX = (int) (mouse.x * (double) window.getScaledWidth() / (double) window.getWidth());
+ int mouseY = (int) (mouse.y * (double) window.getScaledHeight() / (double) window.getHeight());
+ mouse = new Point(mouseX, mouseY);
+
+ RecipeGui recipeGui = (RecipeGui) Minecraft.getInstance().currentScreen;
+ if (mouse.getX() < window.getScaledWidth() / 2 + recipeGui.guiWidth / 2 && mouse.getX() > window.getScaledWidth() / 2 - recipeGui.guiWidth / 2 &&
+ mouse.getY() < window.getScaledHeight() / 2 + recipeGui.guiHeight / 2 && mouse.getY() > window.getScaledHeight() / 2 - recipeGui.guiHeight / 2 &&
+ recipeGui.recipes.get(recipeGui.selectedCategory).size() > 2) {
+ boolean failed = false;
+ if (direction > 0 && recipeGui.btnRecipeLeft.isEnabled())
+ recipeGui.btnRecipeLeft.onClick.apply(0);
+ else if (direction < 0 && recipeGui.btnRecipeRight.isEnabled())
+ recipeGui.btnRecipeRight.onClick.apply(0);
+ else failed = true;
+ if (!failed)
+ return true;
+ }
+ }
if (direction > 0 && reiGui.buttonLeft.isEnabled())
reiGui.buttonLeft.onClick.apply(0);
else if (direction < 0 && reiGui.buttonRight.isEnabled())
diff --git a/src/main/java/me/shedaniel/gui/RecipeGui.java b/src/main/java/me/shedaniel/gui/RecipeGui.java
index 467a1ee86..dcd247906 100755
--- a/src/main/java/me/shedaniel/gui/RecipeGui.java
+++ b/src/main/java/me/shedaniel/gui/RecipeGui.java
@@ -17,10 +17,7 @@ import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
public class RecipeGui extends GuiContainer {
@@ -29,19 +26,19 @@ public class RecipeGui extends GuiContainer {
private final MainWindow mainWindow;
private final Container container;
private final GuiScreen prevScreen;
- private final Map<IDisplayCategory, List<IRecipe>> recipes;
- private int guiWidth = 176;
- private int guiHeight = 222;
+ public final Map<IDisplayCategory, List<IRecipe>> recipes;
+ public int guiWidth = 176;
+ public int guiHeight = 222;
ArrayList<IDisplayCategory> categories = new ArrayList<>();
private int categoryTabPage = 0;
- private IDisplayCategory selectedCategory;
+ public IDisplayCategory selectedCategory;
private int recipePointer = 0;
- private List<REISlot> slots;
- private int cycleCounter = 0;
- private int[] itemPointer;
+ public List<REISlot> slots;
List<Control> controls = new LinkedList<>();
private List<Tab> tabs;
private boolean tabsEnabled = false;
+ private Button btnCategoryPageLeft, btnCategoryPageRight;
+ public Button btnRecipeLeft, btnRecipeRight;
public RecipeGui(Container p_i1072_1_, GuiScreen prevScreen, Map<IDisplayCategory, List<IRecipe>> recipes) {
super(new RecipeContainer());
@@ -66,7 +63,12 @@ public class RecipeGui extends GuiContainer {
for(int i = 0; i < 6; i++)
tabs.add(new Tab(i, 0, 0, 0, 28, 32));
tabs.forEach(tab -> tab.setOnClick(i -> {
- return onClickTab(tab.getId());
+ if (tab.getId() + categoryTabPage * 6 == categories.indexOf(selectedCategory))
+ return false;
+ selectedCategory = categories.get(tab.getId() + categoryTabPage * 6);
+ recipePointer = 0;
+ updateRecipe();
+ return true;
}));
updateRecipe();
}
@@ -102,14 +104,15 @@ public class RecipeGui extends GuiContainer {
private void updateRecipe() {
int categoryPointer = categories.indexOf(selectedCategory);
- IRecipe recipe = recipes.get(categories.get(categoryPointer)).get(recipePointer);
- categories.get(categoryPointer).resetRecipes();
- categories.get(categoryPointer).addRecipe(recipe);
- slots = categories.get(categoryPointer).setupDisplay(0);
- if (recipes.get(categories.get(categoryPointer)).size() >= categoryPointer + 2) {
- IRecipe recipe2 = recipes.get(categories.get(categoryPointer)).get(recipePointer + 1);
- categories.get(categoryPointer).addRecipe(recipe2);
- slots.addAll(categories.get(categoryPointer).setupDisplay(1));
+
+ IRecipe recipe = recipes.get(selectedCategory).get(recipePointer);
+ selectedCategory.resetRecipes();
+ selectedCategory.addRecipe(recipe);
+ slots = selectedCategory.setupDisplay(0);
+ if (recipes.get(selectedCategory).size() >= recipePointer + 2) {
+ IRecipe recipe2 = recipes.get(selectedCategory).get(recipePointer + 1);
+ selectedCategory.addRecipe(recipe2);
+ slots.addAll(selectedCategory.setupDisplay(1));
}
guiLeft = (int) ((mainWindow.getScaledWidth() / 2 - this.guiWidth / 2));
@@ -122,10 +125,10 @@ public class RecipeGui extends GuiContainer {
btnCategoryRight.onClick = this::btnCategoryRight;
btnCategoryLeft.onClick = this::btnCategoryLeft;
- Button btnRecipeLeft = new Button(guiLeft + 10, guiTop + 28, 15, 20, "<");
- Button btnRecipeRight = new Button(guiLeft + guiWidth - 25, guiTop + 28, 15, 20, ">");
- btnRecipeLeft.setEnabled(recipes.get(categories.get(categoryPointer)).size() > 1 && recipePointer > 0);
- btnRecipeRight.setEnabled(recipes.get(categories.get(categoryPointer)).size() > 1 && getCurrentPage() + 1 < getTotalPages());
+ btnRecipeLeft = new Button(guiLeft + 10, guiTop + 28, 15, 20, "<");
+ btnRecipeRight = new Button(guiLeft + guiWidth - 25, guiTop + 28, 15, 20, ">");
+ btnRecipeLeft.setEnabled(recipes.get(selectedCategory).size() > 2);
+ btnRecipeRight.setEnabled(recipes.get(selectedCategory).size() > 2);
btnRecipeRight.onClick = this::btnRecipeRight;
btnRecipeLeft.onClick = this::btnRecipeLeft;
@@ -135,20 +138,34 @@ public class RecipeGui extends GuiContainer {
if (categories.size() <= 1) {
btnCategoryLeft.setEnabled(false);
btnCategoryRight.setEnabled(false);
+ } else if (categories.size() > 6) {
+ btnCategoryPageLeft = new Button(guiLeft, guiTop - 52, 20, 20, "<");
+ btnCategoryPageRight = new Button(guiLeft + guiWidth - 20, guiTop - 52, 20, 20, ">");
+ btnCategoryPageLeft.setOnClick(i -> {
+ categoryTabPage--;
+ if (categoryTabPage <= 0)
+ categoryTabPage = MathHelper.ceil(categories.size() / 6d);
+ updateRecipe();
+ return true;
+ });
+ btnCategoryPageRight.setOnClick(i -> {
+ categoryTabPage++;
+ if (categoryTabPage >= MathHelper.ceil(categories.size() / 6d))
+ categoryTabPage = 0;
+ updateRecipe();
+ return true;
+ });
+ if (guiTop - 52 >= 2)
+ controls.addAll(Arrays.asList(btnCategoryPageLeft, btnCategoryPageRight));
}
controls.add(btnRecipeLeft);
controls.add(btnRecipeRight);
- itemPointer = new int[9];
- for(int i = 0; i < itemPointer.length; i++) {
- itemPointer[i] = 0;
- }
-
List<Control> newControls = new LinkedList<>();
- categories.get(categoryPointer).addWidget(newControls, 0);
- if (recipes.get(categories.get(categoryPointer)).size() >= categoryPointer + 2)
- categories.get(categoryPointer).addWidget(newControls, 1);
+ selectedCategory.addWidget(newControls, 0);
+ if (recipes.get(selectedCategory).size() >= recipePointer + 2)
+ selectedCategory.addWidget(newControls, 1);
newControls.forEach(f -> f.move(guiLeft, guiTop));
controls.addAll(newControls);
@@ -169,14 +186,6 @@ public class RecipeGui extends GuiContainer {
}
}
- private boolean onClickTab(int index) {
- if (index + categoryTabPage * 6 == categories.indexOf(selectedCategory))
- return false;
- selectedCategory = categories.get(index + categoryTabPage * 6);
- updateRecipe();
- return true;
- }
-
@Override
protected void drawGuiContainerBackgroundLayer(float v, int i, int i1) {
//Tabs
@@ -189,13 +198,18 @@ public class RecipeGui extends GuiContainer {
drawDefaultBackground();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ RenderHelper.disableStandardItemLighting();
this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
int lvt_4_1_ = (int) ((mainWindow.getScaledWidth() / 2 - this.guiWidth / 2));
int lvt_5_1_ = (int) ((mainWindow.getScaledHeight() / 2 - this.guiHeight / 2));
this.drawTexturedModalRect(lvt_4_1_, lvt_5_1_, 0, 0, this.guiWidth, this.guiHeight);
- slots.forEach(REISlot::draw);
+ slots.forEach(reiSlot -> {
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ RenderHelper.disableStandardItemLighting();
+ reiSlot.draw();
+ });
if (tabsEnabled)
tabs.stream().filter(tab -> tab.getId() + categoryTabPage * 6 != categories.indexOf(selectedCategory)).forEach(tab -> {
@@ -212,7 +226,6 @@ public class RecipeGui extends GuiContainer {
Minecraft.getInstance().displayGuiScreen(prevScreen);
return true;
}
-
return super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_);
}
@@ -225,7 +238,7 @@ public class RecipeGui extends GuiContainer {
recipePointer = 0;
int categoryPointer = categories.indexOf(selectedCategory);
categoryPointer--;
- if (categoryPointer < 0)
+ if (categoryPointer <= 0)
categoryPointer = categories.size() - 1;
selectedCategory = categories.get(categoryPointer);
categoryTabPage = categoryPointer / 6;
@@ -247,27 +260,25 @@ public class RecipeGui extends GuiContainer {
private boolean btnRecipeLeft(int button) {
recipePointer -= 2;
- if (recipePointer < 0) {
- recipePointer = (getTotalPages() - 1) * 2;
- }
+ if (recipePointer <= 0)
+ recipePointer = MathHelper.floor((recipes.get(selectedCategory).size() - 1) / 2d) * 2;
updateRecipe();
return true;
}
private boolean btnRecipeRight(int button) {
recipePointer += 2;
- if (recipePointer >= recipes.get(selectedCategory).size()) {
+ if (recipePointer >= recipes.get(selectedCategory).size())
recipePointer = 0;
- }
updateRecipe();
return true;
}
private int riseDoublesToInt(double i) {
- return (int) (i + (i % 1 == 0 ? 0 : 1));
+ return MathHelper.ceil(i);
}
private int getTotalPages() {
- return MathHelper.clamp(riseDoublesToInt(recipes.get(selectedCategory).size() / 2), 1, Integer.MAX_VALUE);
+ return MathHelper.clamp(riseDoublesToInt(recipes.get(selectedCategory).size() / 2d), 1, Integer.MAX_VALUE);
}
}
diff --git a/src/main/java/me/shedaniel/gui/widget/REISlot.java b/src/main/java/me/shedaniel/gui/widget/REISlot.java
index 1dc21b158..d815b1d91 100755
--- a/src/main/java/me/shedaniel/gui/widget/REISlot.java
+++ b/src/main/java/me/shedaniel/gui/widget/REISlot.java
@@ -1,6 +1,7 @@
package me.shedaniel.gui.widget;
import com.google.common.collect.Lists;
+import me.shedaniel.Core;
import me.shedaniel.gui.REIRenderHelper;
import me.shedaniel.listenerdefinitions.IMixinGuiContainer;
import me.shedaniel.network.CheatPacket;
@@ -121,7 +122,7 @@ public class REISlot extends Control {
if (button == 1) {
cheatedStack.setCount(cheatedStack.getMaxStackSize());
}
- Minecraft.getInstance().getConnection().sendPacket(new CheatPacket(cheatedStack));
+ Core.cheatItems(cheatedStack.copy());
return true;
}
} else {
diff --git a/src/main/java/me/shedaniel/gui/widget/TextBox.java b/src/main/java/me/shedaniel/gui/widget/TextBox.java
index 3798fa5fc..5355b1895 100755
--- a/src/main/java/me/shedaniel/gui/widget/TextBox.java
+++ b/src/main/java/me/shedaniel/gui/widget/TextBox.java
@@ -2,6 +2,7 @@ package me.shedaniel.gui.widget;
import me.shedaniel.gui.REIRenderHelper;
import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.renderer.RenderHelper;
import java.awt.*;
@@ -20,8 +21,17 @@ public class TextBox extends Control implements IFocusable {
this.charPressed = this::charTyped;
}
+ public TextBox(Rectangle rectangle) {
+ super(rectangle);
+ textField = new GuiTextField(-1, REIRenderHelper.getFontRenderer(), rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+ this.onClick = this::doMouseClick;
+ this.onKeyDown = this::onKeyPressed;
+ this.charPressed = this::charTyped;
+ }
+
@Override
public void draw() {
+ RenderHelper.disableStandardItemLighting();
textField.drawTextField(0, 0, 0);
}
diff --git a/src/main/java/me/shedaniel/listenerdefinitions/IMixinGuiContainer.java b/src/main/java/me/shedaniel/listenerdefinitions/IMixinGuiContainer.java
index 58d1ed75e..b486c8e8e 100755
--- a/src/main/java/me/shedaniel/listenerdefinitions/IMixinGuiContainer.java
+++ b/src/main/java/me/shedaniel/listenerdefinitions/IMixinGuiContainer.java
@@ -11,4 +11,9 @@ public interface IMixinGuiContainer {
public int getXSize();
public Slot getHoveredSlot();
+
+ public int getContainerHeight();
+
+ public int getContainerWidth();
+
}
diff --git a/src/main/java/me/shedaniel/listeners/DrawContainerListener.java b/src/main/java/me/shedaniel/listeners/DrawContainerListener.java
index c02ea9379..8b1c19698 100755
--- a/src/main/java/me/shedaniel/listeners/DrawContainerListener.java
+++ b/src/main/java/me/shedaniel/listeners/DrawContainerListener.java
@@ -12,7 +12,7 @@ import org.dimdev.rift.listener.client.ClientTickable;
/**
* Created by James on 7/27/2018.
*/
-public class DrawContainerListener implements DrawContainer, GuiCickListener, GuiKeyDown, CharInput, ClientTickable, MouseScrollListener {
+public class DrawContainerListener implements MinecraftResize, DrawContainer, GuiCickListener, GuiKeyDown, CharInput, ClientTickable, MouseScrollListener {
@Override
public void draw(int x, int y, float dunno, GuiContainer gui) {
if (!(gui instanceof GuiContainerCreative) || ((GuiContainerCreative) gui).getSelectedTabIndex() == ItemGroup.INVENTORY.getIndex()) {
@@ -57,4 +57,10 @@ public class DrawContainerListener implements DrawContainer, GuiCickListener, Gu
return REIRenderHelper.mouseScrolled(direction);
return false;
}
+
+ @Override
+ public void resize(int scaledWidth, int scaledHeight) {
+ REIRenderHelper.resize(scaledWidth, scaledHeight);
+ }
+
}
diff --git a/src/main/java/me/shedaniel/listeners/ResizeListener.java b/src/main/java/me/shedaniel/listeners/ResizeListener.java
deleted file mode 100755
index 2d16e1ad1..000000000
--- a/src/main/java/me/shedaniel/listeners/ResizeListener.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package me.shedaniel.listeners;
-
-import me.shedaniel.gui.REIRenderHelper;
-import me.shedaniel.listenerdefinitions.MinecraftResize;
-
-/**
- * Created by James on 7/28/2018.
- */
-public class ResizeListener implements MinecraftResize {
- @Override
- public void resize(int scaledWidth, int scaledHeight) {
- REIRenderHelper.resize(scaledWidth, scaledHeight);
- }
-}
diff --git a/src/main/java/me/shedaniel/mixins/MixinGuiContainer.java b/src/main/java/me/shedaniel/mixins/MixinGuiContainer.java
index 10f9d6e3f..2719e0e45 100755
--- a/src/main/java/me/shedaniel/mixins/MixinGuiContainer.java
+++ b/src/main/java/me/shedaniel/mixins/MixinGuiContainer.java
@@ -94,4 +94,14 @@ public abstract class MixinGuiContainer implements IGuiEventListenerDeferred, IM
public Slot getHoveredSlot() {
return hoveredSlot;
}
+
+ @Override
+ public int getContainerHeight() {
+ return ySize;
+ }
+
+ @Override
+ public int getContainerWidth() {
+ return xSize;
+ }
}
diff --git a/src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java b/src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java
index 948a5a274..dab238487 100644
--- a/src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java
+++ b/src/main/java/me/shedaniel/mixins/MixinGuiContainerCreative.java
@@ -29,14 +29,12 @@ public abstract class MixinGuiContainerCreative extends InventoryEffectRenderer
@Inject(method = "keyPressed(III)Z", at = @At("HEAD"), cancellable = true)
public void keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_, CallbackInfoReturnable<Boolean> ci) {
boolean handled = false;
- if (getSelectedTabIndex() != ItemGroup.SEARCH.getIndex()) {
- if (getSelectedTabIndex() == ItemGroup.INVENTORY.getIndex()) {
- for(GuiKeyDown listener : RiftLoader.instance.getListeners(GuiKeyDown.class))
- if (listener.keyDown(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_)) {
- ci.setReturnValue(true);
- handled = true;
- }
- }
+ if (getSelectedTabIndex() == ItemGroup.INVENTORY.getIndex()) {
+ for(GuiKeyDown listener : RiftLoader.instance.getListeners(GuiKeyDown.class))
+ if (listener.keyDown(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_)) {
+ ci.setReturnValue(true);
+ handled = true;
+ }
}
if (handled)
ci.cancel();
diff --git a/src/main/java/me/shedaniel/network/CheatPacket.java b/src/main/java/me/shedaniel/network/CheatPacket.java
index 8a8582686..55dc6f606 100755
--- a/src/main/java/me/shedaniel/network/CheatPacket.java
+++ b/src/main/java/me/shedaniel/network/CheatPacket.java
@@ -7,6 +7,8 @@ import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.Packet;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.INetHandlerPlayServer;
+import net.minecraft.util.text.ChatType;
+import net.minecraft.util.text.TextComponentTranslation;
import java.io.IOException;
@@ -40,6 +42,8 @@ public class CheatPacket implements Packet<INetHandlerPlayServer> {
public void processPacket(INetHandlerPlayServer iNetHandlerPlayServer) {
NetHandlerPlayServer server = (NetHandlerPlayServer) iNetHandlerPlayServer;
EntityPlayerMP player = server.player;
- player.inventory.addItemStackToInventory(stack);
+ if (player.inventory.addItemStackToInventory(stack.copy()))
+ player.sendMessage(new TextComponentTranslation("text.rei.cheat_items", stack.getDisplayName().getFormattedText(), stack.getCount(), player.getScoreboardName()), ChatType.SYSTEM);
+ else player.sendMessage(new TextComponentTranslation("text.rei.failed_cheat_items"), ChatType.SYSTEM);
}
}