Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.mrkirby153.KCNerfer;
- import com.google.common.base.Throwables;
- import cpw.mods.fml.relauncher.ReflectionHelper;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.*;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.crafting.IRecipe;
- import net.minecraft.world.World;
- import java.lang.reflect.Field;
- public class RecipieRemover implements IRecipe {
- @Override
- public boolean matches(InventoryCrafting inv, World world) {
- return false;
- }
- @Override
- public ItemStack getCraftingResult(InventoryCrafting inv) {
- return null;
- }
- @Override
- public int getRecipeSize() {
- return 0;
- }
- @Override
- public ItemStack getRecipeOutput() {
- return null;
- }
- // TODO: SRG names for non-dev env
- private static final String eventHandlerFieldName = (KCNerfer.isDev) ? "eventHandler" : "field_70465_c";
- private static final String containerThePlayerName = (KCNerfer.isDev) ? "thePlayer" : "field_82862_h";
- private static final String slotCraftingThePlayerName = (KCNerfer.isDev) ? "thePlayer" : "field_75238_b";
- private static final Field eventHandlerField = ReflectionHelper.findField(InventoryCrafting.class, eventHandlerFieldName);
- private static final Field containerPlayerPlayerField = ReflectionHelper.findField(ContainerPlayer.class, containerThePlayerName);
- private static final Field slotCraftingPlayerField = ReflectionHelper.findField(SlotCrafting.class, slotCraftingThePlayerName);
- private static EntityPlayer findPlayer(InventoryCrafting inv) {
- try {
- Container container = (Container) eventHandlerField.get(inv);
- if (container instanceof ContainerPlayer) {
- return (EntityPlayer) containerPlayerPlayerField.get(container);
- } else if (container instanceof ContainerWorkbench) {
- return (EntityPlayer) slotCraftingPlayerField.get(container.getSlot(0));
- } else {
- // don't know the player
- return null;
- }
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment