aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorUnknown <shekwancheung0528@gmail.com>2019-01-21 22:16:38 +0800
committerUnknown <shekwancheung0528@gmail.com>2019-01-21 22:16:38 +0800
commitbbb92072372d8ceab79bb86186637af02cae6779 (patch)
tree9a50fce070b6fb9506ef904e82d8772247ab84ac /src/main/java
parent855f72d9f730ce54be6167259f33bf1785b140fb (diff)
downloadRoughlyEnoughItems-2.1.0.12.tar.gz
RoughlyEnoughItems-2.1.0.12.tar.bz2
RoughlyEnoughItems-2.1.0.12.zip
v2.1.0.12v2.1.0.12
- Cheating in servers / realms - New Plugin loader - Better language files - Resizable Recipe Base
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/shedaniel/rei/api/IRecipeCategory.java14
-rw-r--r--src/main/java/me/shedaniel/rei/api/REIPluginInfo.java34
-rw-r--r--src/main/java/me/shedaniel/rei/api/RoughlyEnoughItemsPlugin.java75
-rw-r--r--src/main/java/me/shedaniel/rei/client/ClientHelper.java30
-rw-r--r--src/main/java/me/shedaniel/rei/client/ConfigHelper.java4
-rw-r--r--src/main/java/me/shedaniel/rei/client/REIConfig.java1
-rw-r--r--src/main/java/me/shedaniel/rei/gui/ContainerGuiOverlay.java13
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java8
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java12
-rw-r--r--src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java22
-rw-r--r--src/main/java/me/shedaniel/rei/network/CreateItemsPacket.java13
11 files changed, 190 insertions, 36 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java
index 44fb1ad4d..dbc4a7204 100644
--- a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java
+++ b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java
@@ -2,7 +2,12 @@ package me.shedaniel.rei.api;
import me.shedaniel.rei.gui.widget.IWidget;
import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
+import me.shedaniel.rei.gui.widget.RecipeViewingWidget;
import me.shedaniel.rei.listeners.IMixinGuiContainer;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -27,4 +32,13 @@ public interface IRecipeCategory<T extends IRecipeDisplay> {
return Arrays.asList(new RecipeBaseWidget(bounds));
}
+ default public void drawCategoryBackground(Rectangle bounds) {
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ RenderHelper.disableStandardItemLighting();
+ Minecraft.getInstance().getTextureManager().bindTexture(RecipeViewingWidget.CHEST_GUI_TEXTURE);
+ new Gui() {
+
+ }.drawTexturedModalRect((int) bounds.getX(), (int) bounds.getY(), 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight());
+ }
+
}
diff --git a/src/main/java/me/shedaniel/rei/api/REIPluginInfo.java b/src/main/java/me/shedaniel/rei/api/REIPluginInfo.java
new file mode 100644
index 000000000..38519f743
--- /dev/null
+++ b/src/main/java/me/shedaniel/rei/api/REIPluginInfo.java
@@ -0,0 +1,34 @@
+package me.shedaniel.rei.api;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.List;
+
+public class REIPluginInfo {
+
+ public static Gson GSON = new GsonBuilder().create();
+
+ private List<REIPlugin> plugins;
+
+ public List<REIPlugin> getPlugins() {
+ return plugins;
+ }
+
+ public static class REIPlugin {
+ private String identifier;
+ @SerializedName("class") private String pluginClass;
+
+ public String getIdentifier() {
+ if (identifier == null)
+ return "null:null";
+ return identifier;
+ }
+
+ public String getPluginClass() {
+ return pluginClass;
+ }
+ }
+
+}
diff --git a/src/main/java/me/shedaniel/rei/api/RoughlyEnoughItemsPlugin.java b/src/main/java/me/shedaniel/rei/api/RoughlyEnoughItemsPlugin.java
index 9930ca63f..d1db0cc3f 100644
--- a/src/main/java/me/shedaniel/rei/api/RoughlyEnoughItemsPlugin.java
+++ b/src/main/java/me/shedaniel/rei/api/RoughlyEnoughItemsPlugin.java
@@ -1,19 +1,33 @@
package me.shedaniel.rei.api;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
-import me.shedaniel.rei.plugin.DefaultPlugin;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
import net.minecraft.util.ResourceLocation;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.dimdev.riftloader.ModInfo;
+import org.dimdev.riftloader.RiftLoader;
import org.dimdev.riftloader.listener.InitializationListener;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
public class RoughlyEnoughItemsPlugin implements InitializationListener {
+ public static final Logger LOGGER = LogManager.getFormatterLogger("REI");
private static final Map<ResourceLocation, IRecipePlugin> plugins = Maps.newHashMap();
- public static final ResourceLocation DEFAULT_PLUGIN = new ResourceLocation("roughlyenoughitems", "default_plugin");
public static IRecipePlugin registerPlugin(ResourceLocation ResourceLocation, IRecipePlugin plugin) {
plugins.put(ResourceLocation, plugin);
@@ -33,7 +47,60 @@ public class RoughlyEnoughItemsPlugin implements InitializationListener {
@Override
public void onInitialization() {
- RoughlyEnoughItemsPlugin.registerPlugin(RoughlyEnoughItemsPlugin.DEFAULT_PLUGIN, new DefaultPlugin());
+ discoverPlugins();
+ }
+
+ private void discoverPlugins() {
+ Collection<ModInfo> modInfoCollection = RiftLoader.instance.getMods();
+ List<REIPluginInfo> pluginInfoList = Lists.newArrayList();
+ JsonParser parser = new JsonParser();
+ modInfoCollection.forEach(modContainer -> {
+ JsonElement jsonElement = null;
+ if (modContainer.source.isFile())
+ try (JarFile file = new JarFile(modContainer.source)) {
+ ZipEntry entry = file.getEntry("plugins" + File.separatorChar + "rei.plugin.json");
+ if (entry != null) {
+ Reader reader = new InputStreamReader(file.getInputStream(entry));
+ jsonElement = parser.parse(reader);
+ reader.close();
+ }
+ } catch (Exception e) {
+ RoughlyEnoughItemsPlugin.LOGGER.error("REI: Failed to load plugin file from " + modContainer.id + ". (" + e.getLocalizedMessage() + ")");
+ }
+ else if (modContainer.source.isDirectory()) {
+ File modInfo = new File(modContainer.source, "plugins" + File.separatorChar + "rei.plugin.json");
+ if (modInfo.exists())
+ try {
+ Reader reader = new InputStreamReader(Files.newInputStream(modInfo.toPath(), StandardOpenOption.READ));
+ jsonElement = parser.parse(reader);
+ reader.close();
+ } catch (Exception e) {
+ RoughlyEnoughItemsPlugin.LOGGER.error("REI: Failed to load plugin file from " + modContainer.id + ". (" + e.getLocalizedMessage() + ")");
+ }
+ }
+ if (jsonElement != null && jsonElement.isJsonObject()) {
+ try {
+ REIPluginInfo info = REIPluginInfo.GSON.fromJson(jsonElement, REIPluginInfo.class);
+ if (info != null)
+ pluginInfoList.add(info);
+ } catch (Exception e) {
+ RoughlyEnoughItemsPlugin.LOGGER.error("REI: Failed to load REI plugin info from " + modContainer.id + ". (" + e.getLocalizedMessage() + ")");
+ }
+ }
+ });
+ pluginInfoList.stream().forEachOrdered(reiPluginInfo -> {
+ reiPluginInfo.getPlugins().forEach(reiPlugin -> {
+ try {
+ ResourceLocation identifier = new ResourceLocation(reiPlugin.getIdentifier());
+ Class<?> aClass = Class.forName(reiPlugin.getPluginClass());
+ IRecipePlugin plugin = IRecipePlugin.class.cast(aClass.newInstance());
+ RoughlyEnoughItemsPlugin.registerPlugin(identifier, plugin);
+ RoughlyEnoughItemsPlugin.LOGGER.info("REI: Registered REI plugin: " + reiPlugin.getIdentifier());
+ } catch (Exception e) {
+ RoughlyEnoughItemsPlugin.LOGGER.error("REI: Failed to register REI plugin: " + reiPlugin.getIdentifier() + ". (" + e.getLocalizedMessage() + ")");
+ }
+ });
+ });
}
}
diff --git a/src/main/java/me/shedaniel/rei/client/ClientHelper.java b/src/main/java/me/shedaniel/rei/client/ClientHelper.java
index 7023a4627..4e7155a7e 100644
--- a/src/main/java/me/shedaniel/rei/client/ClientHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/ClientHelper.java
@@ -2,6 +2,8 @@ package me.shedaniel.rei.client;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import io.netty.buffer.Unpooled;
+import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.IRecipeCategory;
import me.shedaniel.rei.api.IRecipeDisplay;
import me.shedaniel.rei.gui.ContainerGuiOverlay;
@@ -70,8 +72,6 @@ public class ClientHelper implements ClientLoaded {
}
public static boolean isCheating() {
- if (!Minecraft.getInstance().isSingleplayer())
- cheating = false;
return cheating;
}
@@ -80,17 +80,33 @@ public class ClientHelper implements ClientLoaded {
}
public static void sendDeletePacket() {
+ if (Minecraft.getInstance().playerController.isInCreativeMode()) {
+ Minecraft.getInstance().player.inventory.setItemStack(ItemStack.EMPTY);
+ return;
+ }
DeleteItemsPacket message = new DeleteItemsPacket();
Minecraft.getInstance().getConnection().sendPacket(message);
}
public static boolean tryCheatingStack(ItemStack cheatedStack) {
- try {
- CreateItemsPacket message = new CreateItemsPacket(cheatedStack.copy());
- Minecraft.getInstance().getConnection().sendPacket(message);
+ if (Minecraft.getInstance().isSingleplayer()) {
+ try {
+ CreateItemsPacket message = new CreateItemsPacket(cheatedStack.copy());
+ Minecraft.getInstance().getConnection().sendPacket(message);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ } else {
+ ResourceLocation location = IRegistry.ITEM.getKey(cheatedStack.getItem());
+ String tagMessage = cheatedStack.copy().getTag() != null && !cheatedStack.copy().getTag().isEmpty() ? cheatedStack.copy().getTag().toString() : "";
+ String madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + Minecraft.getInstance().player.getScoreboardName() + " " +
+ location.toString() + tagMessage + (cheatedStack.getCount() != 1 ? " " + cheatedStack.getCount() : "");
+ if (madeUpCommand.length() > 256)
+ madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + Minecraft.getInstance().player.getScoreboardName() + " " +
+ location.toString() + (cheatedStack.getCount() != 1 ? " " + cheatedStack.getCount() : "");
+ Minecraft.getInstance().player.sendChatMessage(madeUpCommand);
return true;
- } catch (Exception e) {
- return false;
}
}
diff --git a/src/main/java/me/shedaniel/rei/client/ConfigHelper.java b/src/main/java/me/shedaniel/rei/client/ConfigHelper.java
index 1d3a7e4e4..d0e5de001 100644
--- a/src/main/java/me/shedaniel/rei/client/ConfigHelper.java
+++ b/src/main/java/me/shedaniel/rei/client/ConfigHelper.java
@@ -61,6 +61,10 @@ public class ConfigHelper {
saveConfig();
}
+ public String getGiveCommandPrefix() {
+ return config.giveCommandPrefix;
+ }
+
public REIItemListOrdering getItemListOrdering() {
return config.itemListOrdering;
}
diff --git a/src/main/java/me/shedaniel/rei/client/REIConfig.java b/src/main/java/me/shedaniel/rei/client/REIConfig.java
index 7c9079245..db14b282f 100644
--- a/src/main/java/me/shedaniel/rei/client/REIConfig.java
+++ b/src/main/java/me/shedaniel/rei/client/REIConfig.java
@@ -15,5 +15,6 @@ public class REIConfig {
public boolean isAscending = true;
public boolean enableCraftableOnlyButton = true;
public boolean sideSearchField = false;
+ public String giveCommandPrefix = "/give";
}
diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerGuiOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerGuiOverlay.java
index fe9a96422..b840a473d 100644
--- a/src/main/java/me/shedaniel/rei/gui/ContainerGuiOverlay.java
+++ b/src/main/java/me/shedaniel/rei/gui/ContainerGuiOverlay.java
@@ -18,7 +18,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import java.awt.*;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
@@ -76,15 +78,11 @@ public class ContainerGuiOverlay extends GuiScreen {
public void draw(int int_1, int int_2, float float_1) {
this.text = getCheatModeText();
super.draw(int_1, int_2, float_1);
- if (getBounds().contains(int_1, int_2) && !Minecraft.getInstance().isSingleplayer())
- ContainerGuiOverlay.this.addTooltip(new QueuedTooltip(ClientHelper.getMouseLocation(),
- Arrays.asList(I18n.format("text.rei.nocheating_in_servers").split("\n"))));
}
@Override
public void onPressed(int button, double mouseX, double mouseY) {
- if (Minecraft.getInstance().isSingleplayer())
- ClientHelper.setCheating(!ClientHelper.isCheating());
+ ClientHelper.setCheating(!ClientHelper.isCheating());
}
});
widgets.add(new ButtonWidget(10, 35, 40, 20, I18n.format("text.rei.config")) {
@@ -245,7 +243,8 @@ public class ContainerGuiOverlay extends GuiScreen {
buttonLeft.onPressed(0, 0, 0);
else if (amount < 0 && buttonRight.enabled)
buttonRight.onPressed(0, 0, 0);
- else return false;
+ else
+ return false;
return true;
}
for(IWidget widget : widgets)
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
index 0ca3aab2b..a6302be7a 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java
@@ -45,7 +45,7 @@ public class ItemListOverlay extends Gui implements IWidget {
public void draw(int int_1, int int_2, float float_1) {
widgets.forEach(widget -> widget.draw(int_1, int_2, float_1));
EntityPlayerSP player = Minecraft.getInstance().player;
- if (rectangle.contains(ClientHelper.getMouseLocation()) && ClientHelper.isCheating() && !player.inventory.getItemStack().isEmpty())
+ if (rectangle.contains(ClientHelper.getMouseLocation()) && ClientHelper.isCheating() && !player.inventory.getItemStack().isEmpty() && Minecraft.getInstance().isSingleplayer())
GuiHelper.getOverlay(containerGui.getContainerGui()).addTooltip(new QueuedTooltip(ClientHelper.getMouseLocation(), Arrays.asList(I18n.format("text.rei.delete_items"))));
}
@@ -72,7 +72,7 @@ public class ItemListOverlay extends Gui implements IWidget {
@Override
protected void drawToolTip(ItemStack itemStack) {
EntityPlayerSP player = Minecraft.getInstance().player;
- if (!ClientHelper.isCheating() || player.inventory.getItemStack().isEmpty())
+ if (!ClientHelper.isCheating() || player.inventory.getItemStack().isEmpty() || !Minecraft.getInstance().isSingleplayer())
super.drawToolTip(itemStack);
}
@@ -211,11 +211,11 @@ public class ItemListOverlay extends Gui implements IWidget {
public boolean mouseClicked(double double_1, double double_2, int int_1) {
EntityPlayerSP player = Minecraft.getInstance().player;
if (rectangle.contains(double_1, double_2))
- if (ClientHelper.isCheating() && !player.inventory.getItemStack().isEmpty()) {
+ if (ClientHelper.isCheating() && !player.inventory.getItemStack().isEmpty() && Minecraft.getInstance().isSingleplayer()) {
ClientHelper.sendDeletePacket();
return true;
}
- if (!player.inventory.getItemStack().isEmpty())
+ if (!player.inventory.getItemStack().isEmpty() && Minecraft.getInstance().isSingleplayer())
return false;
if (onMouseClick(int_1, double_1, double_2))
return true;
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
index 6b480e8c2..604603bfe 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeBaseWidget.java
@@ -5,6 +5,7 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.math.MathHelper;
import java.awt.*;
import java.util.ArrayList;
@@ -30,7 +31,16 @@ public class RecipeBaseWidget extends Gui implements IWidget {
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderHelper.disableStandardItemLighting();
Minecraft.getInstance().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
- drawTexturedModalRect(bounds.x, bounds.y, 106, 190, bounds.width, bounds.height);
+ drawTexturedModalRect(bounds.x, bounds.y, 106, 190, bounds.width / 2, bounds.height / 2);
+ drawTexturedModalRect(bounds.x + bounds.width / 2, bounds.y, 256 - bounds.width / 2, 190, bounds.width / 2, bounds.height / 2);
+ drawTexturedModalRect(bounds.x, bounds.y + bounds.height / 2, 106, 190 + 66 - bounds.height / 2, bounds.width / 2, bounds.height / 2);
+ drawTexturedModalRect(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2, 256 - bounds.width / 2, 190 + 66 - bounds.height / 2, bounds.width / 2, bounds.height / 2);
+ if (bounds.height > 40)
+ for(int i = 20; i < bounds.height - 20; i += MathHelper.clamp(20, 0, bounds.height - 20 - i)) {
+ int height = MathHelper.clamp(20, 0, bounds.height - 20 - i);
+ drawTexturedModalRect(bounds.x, bounds.y + i, 106, 230, bounds.width / 2, height);
+ drawTexturedModalRect(bounds.x + bounds.width / 2, bounds.y + i, 256 - bounds.width / 2, 210, bounds.width / 2, height);
+ }
}
}
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java
index 7cbd416b8..5e6d6225a 100644
--- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java
+++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java
@@ -29,8 +29,8 @@ import java.util.Map;
public class RecipeViewingWidget extends GuiScreen {
+ public static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png");
private static final ResourceLocation CREATIVE_INVENTORY_TABS = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
- private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png");
public final int guiWidth = 176;
public final int guiHeight = 186;
@@ -190,10 +190,10 @@ public class RecipeViewingWidget extends GuiScreen {
final SpeedCraftFunctional functional = functional0[0];
if (page * getRecipesPerPage() < categoriesMap.get(selectedCategory).size()) {
IRecipeDisplay topDisplay = categoriesMap.get(selectedCategory).get(page * getRecipesPerPage());
- widgets.addAll(selectedCategory.setupDisplay(getParent(), topDisplay, new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 40, 150, selectedCategory.usesFullPage() ? 118 : 66)));
+ widgets.addAll(selectedCategory.setupDisplay(getParent(), topDisplay, new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 40, 150, selectedCategory.usesFullPage() ? 140 : 66)));
if (supplier != null) {
ButtonWidget btn;
- widgets.add(btn = new ButtonWidget(supplier.get(new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 40, 150, selectedCategory.usesFullPage() ? 118 : 66)), "+") {
+ widgets.add(btn = new ButtonWidget(supplier.get(new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 40, 150, selectedCategory.usesFullPage() ? 140 : 66)), "+") {
@Override
public void onPressed(int button, double mouseX, double mouseY) {
Minecraft.getInstance().displayGuiScreen(parent.getContainerGui());
@@ -214,10 +214,10 @@ public class RecipeViewingWidget extends GuiScreen {
}
if (!selectedCategory.usesFullPage() && page * getRecipesPerPage() + 1 < categoriesMap.get(selectedCategory).size()) {
IRecipeDisplay middleDisplay = categoriesMap.get(selectedCategory).get(page * getRecipesPerPage() + 1);
- widgets.addAll(selectedCategory.setupDisplay(getParent(), middleDisplay, new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 108, 150, 66)));
+ widgets.addAll(selectedCategory.setupDisplay(getParent(), middleDisplay, new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 113, 150, 66)));
if (supplier != null) {
ButtonWidget btn;
- widgets.add(btn = new ButtonWidget(supplier.get(new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 108, 150, 66)), "+") {
+ widgets.add(btn = new ButtonWidget(supplier.get(new Rectangle((int) getBounds().getCenterX() - 75, getBounds().y + 113, 150, 66)), "+") {
@Override
public void onPressed(int button, double mouseX, double mouseY) {
Minecraft.getInstance().displayGuiScreen(parent.getContainerGui());
@@ -272,10 +272,14 @@ public class RecipeViewingWidget extends GuiScreen {
@Override
public void drawDefaultBackground() {
drawWorldBackground(0);
- GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
- RenderHelper.disableStandardItemLighting();
- this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
- this.drawTexturedModalRect((int) bounds.getX(), (int) bounds.getY(), 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight());
+ if (selectedCategory != null)
+ selectedCategory.drawCategoryBackground(bounds);
+ else {
+ GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ RenderHelper.disableStandardItemLighting();
+ this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
+ this.drawTexturedModalRect((int) bounds.getX(), (int) bounds.getY(), 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight());
+ }
}
public int getTotalPages(IRecipeCategory category) {
diff --git a/src/main/java/me/shedaniel/rei/network/CreateItemsPacket.java b/src/main/java/me/shedaniel/rei/network/CreateItemsPacket.java
index 003ea09fe..88f9a1425 100644
--- a/src/main/java/me/shedaniel/rei/network/CreateItemsPacket.java
+++ b/src/main/java/me/shedaniel/rei/network/CreateItemsPacket.java
@@ -1,5 +1,6 @@
package me.shedaniel.rei.network;
+import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -8,9 +9,8 @@ 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.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
-import org.dimdev.rift.network.Message;
-import org.dimdev.rift.network.ServerMessageContext;
import java.io.IOException;
@@ -42,8 +42,13 @@ public class CreateItemsPacket implements Packet<INetHandlerPlayServer> {
NetHandlerPlayServer server = (NetHandlerPlayServer) iNetHandlerPlayServer;
EntityPlayerMP player = server.player;
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);
+ player.sendMessage(new TextComponentString(I18n.format("text.rei.cheat_items")
+ .replaceAll("\\{item_name}", stack.copy().getDisplayName().getFormattedText())
+ .replaceAll("\\{item_count}", stack.copy().getCount() + "")
+ .replaceAll("\\{player_name}", player.getScoreboardName())
+ ), ChatType.SYSTEM);
+ else
+ player.sendMessage(new TextComponentTranslation("text.rei.failed_cheat_items"), ChatType.SYSTEM);
}
}