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.ShapedRecipes;
- import net.minecraft.world.World;
- import java.lang.reflect.Field;
- public class CustomShapedRecipie extends ShapedRecipes {
- // private IRecipe recipe;
- private ItemStack output;
- public CustomShapedRecipie(int width, int height, ItemStack[] items, ItemStack output) {
- super(width, height, items, output);
- this.output = output;
- }
- /* public CustomRecipie(IRecipe recipie) {
- this.recipe = recipie;
- }*/
- @Override
- public boolean matches(InventoryCrafting inv, World world) {
- // Check the player first
- /* EntityPlayer player = findPlayer(inv);
- if(RecipieHandler.isDisabled(output.getItem(), player)){
- return false;
- }
- return super.matches(inv, world);*/
- return false;
- }
- @Override
- public ItemStack getCraftingResult(InventoryCrafting inv) {
- return super.getCraftingResult(inv);
- }
- @Override
- public int getRecipeSize() {
- return super.getRecipeSize();
- }
- @Override
- public ItemStack getRecipeOutput() {
- return super.getRecipeOutput();
- }
- // 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