Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.fejcraft.FejCraftRPG.FejRecipeTypes;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.inventory.ContainerPlayer;
- import net.minecraft.inventory.ContainerWorkbench;
- import net.minecraft.inventory.InventoryCrafting;
- import net.minecraft.inventory.SlotCrafting;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.crafting.IRecipe;
- import net.minecraft.world.World;
- public class FejRecipeShaped extends net.minecraft.item.crafting.ShapedRecipes {
- public int levelRequired;
- public FejRecipeShaped(int par1, int par2, ItemStack[] par3ArrayOfItemStack, ItemStack par4ItemStack, int levelRequired) {
- super(par1, par2, par3ArrayOfItemStack, par4ItemStack);
- this.levelRequired = levelRequired;
- }
- @Override
- public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World)
- {
- System.out.println("Trying to match crafting inventory.");
- if(super.matches(par1InventoryCrafting, par2World) && getPlayerFromInventory(par1InventoryCrafting).experienceLevel >= levelRequired) {
- return true;
- }
- else {
- return false;
- }
- }
- private static EntityPlayer getPlayerFromInventory(InventoryCrafting inventory)
- {
- if(inventory.eventHandler instanceof ContainerPlayer) {
- return ((ContainerPlayer)inventory.eventHandler).thePlayer;
- }
- else if(inventory.eventHandler instanceof ContainerWorkbench) {
- if(((ContainerWorkbench)inventory.eventHandler).getSlot(0) instanceof SlotCrafting) {
- return ((SlotCrafting)((ContainerWorkbench)inventory.eventHandler).getSlot(0)).thePlayer;
- }
- else {
- System.err.println("[FejCraftRPG] Was not able to get player from inventory (Slot not SlotCrafting)!");
- return null;
- }
- }
- else {
- System.err.println("[FejCraftRPG] Was not able to get player from inventory!");
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement