aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java')
-rw-r--r--src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java
index 748869a3c..0115104fb 100644
--- a/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java
+++ b/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java
@@ -10,10 +10,7 @@ import com.google.common.collect.Maps;
import io.netty.buffer.Unpooled;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.RoughlyEnoughItemsNetwork;
-import me.shedaniel.rei.api.ClientHelper;
-import me.shedaniel.rei.api.RecipeCategory;
-import me.shedaniel.rei.api.RecipeDisplay;
-import me.shedaniel.rei.api.RecipeHelper;
+import me.shedaniel.rei.api.*;
import me.shedaniel.rei.gui.PreRecipeViewingScreen;
import me.shedaniel.rei.gui.RecipeViewingScreen;
import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
@@ -155,16 +152,21 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
}
@Override
- public boolean tryCheatingStack(ItemStack cheatedStack) {
+ public boolean tryCheatingEntry(EntryStack entry) {
+ if (entry.getType() != EntryStack.Type.ITEM)
+ return false;
+ ItemStack cheatedStack = entry.getItemStack().copy();
if (RoughlyEnoughItemsCore.canUsePackets()) {
try {
- ClientSidePacketRegistry.INSTANCE.sendToServer(RoughlyEnoughItemsNetwork.CREATE_ITEMS_PACKET, new PacketByteBuf(Unpooled.buffer()).writeItemStack(cheatedStack.copy()));
+ ClientSidePacketRegistry.INSTANCE.sendToServer(RoughlyEnoughItemsNetwork.CREATE_ITEMS_PACKET, new PacketByteBuf(Unpooled.buffer()).writeItemStack(cheatedStack));
return true;
} catch (Exception e) {
return false;
}
} else {
- Identifier identifier = Registry.ITEM.getId(cheatedStack.getItem());
+ Identifier identifier = entry.getIdentifier().orElse(null);
+ if (identifier == null)
+ return false;
String tagMessage = cheatedStack.copy().getTag() != null && !cheatedStack.copy().getTag().isEmpty() ? cheatedStack.copy().getTag().asString() : "";
String og = cheatedStack.getCount() == 1 ? RoughlyEnoughItemsCore.getConfigManager().getConfig().getGiveCommand().replaceAll(" \\{count}", "") : RoughlyEnoughItemsCore.getConfigManager().getConfig().getGiveCommand();
String madeUpCommand = og.replaceAll("\\{player_name}", MinecraftClient.getInstance().player.getEntityName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", tagMessage).replaceAll("\\{count}", String.valueOf(cheatedStack.getCount()));
@@ -178,7 +180,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
}
@Override
- public boolean executeRecipeKeyBind(ItemStack stack) {
+ public boolean executeRecipeKeyBind(EntryStack stack) {
Map<RecipeCategory<?>, List<RecipeDisplay>> map = RecipeHelper.getInstance().getRecipesFor(stack);
if (map.keySet().size() > 0)
openRecipeViewingScreen(map);
@@ -186,7 +188,7 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
}
@Override
- public boolean executeUsageKeyBind(ItemStack stack) {
+ public boolean executeUsageKeyBind(EntryStack stack) {
Map<RecipeCategory<?>, List<RecipeDisplay>> map = RecipeHelper.getInstance().getUsagesFor(stack);
if (map.keySet().size() > 0)
openRecipeViewingScreen(map);