diff options
| author | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:52 +0800 |
|---|---|---|
| committer | Danielshe <shekwancheung0528@gmail.com> | 2019-11-03 14:44:59 +0800 |
| commit | 9f5a9eae9a7863412cc5eb433bf15e5ee71da616 (patch) | |
| tree | 0e6b0b94af061c5e9023b1ff19f339a6c30149be /src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java | |
| parent | 3e3e25855b9f6df507a7d4c8a07c64b9a502fae2 (diff) | |
| download | RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.gz RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.tar.bz2 RoughlyEnoughItems-9f5a9eae9a7863412cc5eb433bf15e5ee71da616.zip | |
3.2.1
Diffstat (limited to 'src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java | 20 |
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); |
