diff options
Diffstat (limited to 'src/main/java')
6 files changed, 45 insertions, 17 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java index 4640b6d24..5277321a1 100644 --- a/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java +++ b/src/main/java/me/shedaniel/rei/api/IRecipeCategory.java @@ -3,17 +3,15 @@ package me.shedaniel.rei.api; import com.mojang.blaze3d.platform.GlStateManager; 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.IMixinContainerGui; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.Drawable; -import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.GuiLighting; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexFormats; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import java.awt.*; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -34,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); + GuiLighting.disable(); + MinecraftClient.getInstance().getTextureManager().bindTexture(RecipeViewingWidget.CHEST_GUI_TEXTURE); + new Drawable() { + + }.drawTexturedRect((int) bounds.getX(), (int) bounds.getY(), 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight()); + } + } diff --git a/src/main/java/me/shedaniel/rei/client/ClientHelper.java b/src/main/java/me/shedaniel/rei/client/ClientHelper.java index fbbd4a93b..c753db7a1 100644 --- a/src/main/java/me/shedaniel/rei/client/ClientHelper.java +++ b/src/main/java/me/shedaniel/rei/client/ClientHelper.java @@ -96,13 +96,25 @@ public class ClientHelper implements ClientLoaded, ClientModInitializer { } public static boolean tryCheatingStack(ItemStack cheatedStack) { - try { - PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); - buf.writeItemStack(cheatedStack.copy()); - MinecraftClient.getInstance().getNetworkHandler().sendPacket(new CustomPayloadServerPacket(RoughlyEnoughItemsCore.CREATE_ITEMS_PACKET, buf)); + if (MinecraftClient.getInstance().isInSingleplayer()) { + try { + PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); + buf.writeItemStack(cheatedStack.copy()); + MinecraftClient.getInstance().getNetworkHandler().sendPacket(new CustomPayloadServerPacket(RoughlyEnoughItemsCore.CREATE_ITEMS_PACKET, buf)); + return true; + } catch (Exception e) { + return false; + } + } else { + Identifier location = Registry.ITEM.getId(cheatedStack.getItem()); + String tagMessage = cheatedStack.copy().getTag() != null && !cheatedStack.copy().getTag().isEmpty() ? cheatedStack.copy().getTag().asString() : ""; + String madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + MinecraftClient.getInstance().player.getEntityName() + " " + + location.toString() + tagMessage + (cheatedStack.getAmount() != 1 ? " " + cheatedStack.getAmount() : ""); + if (madeUpCommand.length() > 256) + madeUpCommand = RoughlyEnoughItemsCore.getConfigHelper().getGiveCommandPrefix() + " " + MinecraftClient.getInstance().player.getEntityName() + " " + + location.toString() + (cheatedStack.getAmount() != 1 ? " " + cheatedStack.getAmount() : ""); + MinecraftClient.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 3f1cb79c2..68af75008 100644 --- a/src/main/java/me/shedaniel/rei/client/ConfigHelper.java +++ b/src/main/java/me/shedaniel/rei/client/ConfigHelper.java @@ -91,6 +91,10 @@ public class ConfigHelper { config.enableCraftableOnlyButton = enableCraftableOnlyButton; } + public String getGiveCommandPrefix() { + return config.giveCommandPrefix; + } + public boolean sideSearchField() { return config.sideSearchField; } 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/widget/ItemListOverlay.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java index 1f4761197..d9fa00ac8 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java @@ -212,11 +212,11 @@ public class ItemListOverlay extends Drawable implements IWidget { public boolean mouseClicked(double double_1, double double_2, int int_1) { ClientPlayerEntity player = MinecraftClient.getInstance().player; if (rectangle.contains(double_1, double_2)) - if (ClientHelper.isCheating() && !player.inventory.getCursorStack().isEmpty()) { + if (ClientHelper.isCheating() && !player.inventory.getCursorStack().isEmpty() && MinecraftClient.getInstance().isInSingleplayer()) { ClientHelper.sendDeletePacket(); return true; } - if (!player.inventory.getCursorStack().isEmpty()) + if (!player.inventory.getCursorStack().isEmpty() && MinecraftClient.getInstance().isInSingleplayer()) return false; if (onMouseClick(int_1, double_1, double_2)) return true; 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 4645524dc..59708ad4b 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/RecipeViewingWidget.java @@ -30,7 +30,7 @@ import java.util.Map; public class RecipeViewingWidget extends Gui { private static final Identifier CREATIVE_INVENTORY_TABS = new Identifier("textures/gui/container/creative_inventory/tabs.png"); - private static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); + public static final Identifier CHEST_GUI_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/recipecontainer.png"); public final int guiWidth = 176; public final int guiHeight = 186; @@ -272,10 +272,14 @@ public class RecipeViewingWidget extends Gui { @Override public void drawBackground() { drawBackground(0); - GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiLighting.disable(); - this.client.getTextureManager().bindTexture(CHEST_GUI_TEXTURE); - this.drawTexturedRect((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); + GuiLighting.disable(); + this.client.getTextureManager().bindTexture(CHEST_GUI_TEXTURE); + this.drawTexturedRect((int) bounds.getX(), (int) bounds.getY(), 0, 0, (int) bounds.getWidth(), (int) bounds.getHeight()); + } } public int getTotalPages(IRecipeCategory category) { |
