diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Anvil/AnvilBase.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Anvil/AnvilBase.java index 25b4814d..029436bf 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/Anvil/AnvilBase.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/Anvil/AnvilBase.java @@ -5,6 +5,7 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; @@ -45,8 +46,26 @@ public abstract class AnvilBase extends CustomContainerFacing implements AnvilHa @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { - AnvilHandler.doDrops(world, pos); - super.breakBlock(world, pos, state); + if (!world.isRemote && world.getGameRules().getBoolean("doTileDrops")) { + TileAnvil tile = (TileAnvil) world.getTileEntity(pos); + if (tile != null) { + for (ItemStack stack : tile.getSlotList()) { + if (stack != ItemStack.EMPTY) { + float offset = 0.7F; + double offsetX = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D; + double offsetY = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D; + double offsetZ = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D; + stack.setCount(1); + ItemStack dropStack = stack.copy(); + System.out.println(dropStack); + dropStack.setCount(1); + EntityItem itemDrop = new EntityItem(world, pos.getX() + offsetX, pos.getY() + offsetY, pos.getZ() + offsetZ, dropStack); + itemDrop.setDefaultPickupDelay(); + world.spawnEntity(itemDrop); + } + } + } + } } @Override diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Forge.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Forge.java index c3ad9bbd..40df53b3 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Forge.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Forge.java @@ -95,7 +95,8 @@ public class Forge extends CustomContainerFacing implements ITileEntityProvider, { TileForge tile = (TileForge) world.getTileEntity(pos); if (tile != null) { - if (hand.equals(hand.MAIN_HAND)) { + if (hand.equals(player.getActiveHand())) { + ItemStack pItem = player.inventory.getCurrentItem().copy(); ItemStack fuelItem = tile.getSlotStack(0); @@ -163,6 +164,7 @@ public class Forge extends CustomContainerFacing implements ITileEntityProvider, doForgeInventoryManager(pItem, world, tile, pos, hitX, hitY, hitZ, state, player); } } + } return false; } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java b/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java index afa43597..230cfa0f 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/SlottedTongs.java @@ -1,10 +1,13 @@ package nmd.primal.forgecraft.items; +import com.mojang.realmsclient.gui.ChatFormatting; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.Item; @@ -15,13 +18,19 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemStackHandler; import nmd.primal.core.api.PrimalAPI; import nmd.primal.core.api.interfaces.IPickup; import nmd.primal.core.common.helper.NBTHelper; import nmd.primal.core.common.helper.PlayerHelper; +import nmd.primal.core.common.helper.RecipeHelper; import nmd.primal.core.common.tiles.AbstractTileTank; import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.blocks.Anvil.AnvilBase; @@ -37,18 +46,24 @@ import nmd.primal.forgecraft.tiles.TileNBTCrucible; import nmd.primal.forgecraft.util.AnvilHandler; import javax.annotation.Nullable; +import java.util.List; /** * Created by mminaie on 12/30/17. */ public class SlottedTongs extends Item implements IPickup, AnvilHandler{ + public SlottedTongs(String unlocalizedName) { setUnlocalizedName(unlocalizedName); this.setRegistryName(unlocalizedName); this.setMaxStackSize(1); this.setCreativeTab(ModInfo.TAB_FORGECRAFT); + @CapabilityInject(IItemHandler.class) + public static Capability ITEM_HANDLER; + + this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) @@ -271,6 +286,37 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{ } + + + @Override + public ICapabilityProvider initCapabilities(final ItemStack stack, NBTTagCompound nbt) + { + return new ICapabilityProvider() + { + final ItemStackHandler itemHandler = new ItemStackHandler(1); + + @Override + public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) + { + if (capability == ITEM_HANDLER) + return true; + return false; + } + + @SuppressWarnings("unchecked") + @Nullable + @Override + public T getCapability(Capability capability, @Nullable EnumFacing facing) + { + if (capability == ITEM_HANDLER) + return (T) itemHandler; + return null; + } + }; + } + + + public NonNullList getSlotList() { return slotList; } @@ -290,13 +336,13 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{ Block block = world.getBlockState(pos).getBlock(); ItemStack itemstack = player.getHeldItem(hand); ItemStack slotStack = slotList.get(0); - +/* if (block instanceof AnvilStone) { TileAnvil tile = (TileAnvil) world.getTileEntity(pos); doAnvilInventoryManager(itemstack, world, tile, pos, hitx, hity, hitz, state, player); return EnumActionResult.SUCCESS; } - +*/ if (slotList.get(0).isEmpty()) { if (block instanceof NBTCrucible) { ItemStack tempStack = takeBlock(world, pos, state, face, player, block).copy(); @@ -320,68 +366,6 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{ } } - - /***** - PUTS anything into the Forge - *****/ - /* - if (!slotList.get(0).isEmpty()) { - if (world.getBlockState(pos).getBlock() instanceof Forge) { - TileForge tile = (TileForge) world.getTileEntity(pos); - for (int i = 2; i < tile.getSlotListSize(); i++) { - if(tile.getSlotStack(i).isEmpty()) { - ItemStack tempStack = slotList.get(0).copy(); - tile.setSlotStack(i, tempStack); - slotList.set(0, ItemStack.EMPTY); - tile.update(); - return EnumActionResult.SUCCESS; - } - } - } - } -*/ - - /***** - TAKES anything out from the Forge - *****/ - /* - if (slotList.get(0).isEmpty()) { - if (world.getBlockState(pos).getBlock() instanceof Forge) { - TileForge tile = (TileForge) world.getTileEntity(pos); - - for (int i = 2; i < tile.getSlotListSize(); i++) { - if (tile.getSlotStack(i) != ItemStack.EMPTY) { - ItemStack tempStack = tile.getSlotStack(i).copy(); - - slotList.set(0, tempStack); - tile.setSlotStack(i, ItemStack.EMPTY); - - return EnumActionResult.SUCCESS; - } - } - } - } - //} -*/ - /***** - PUTS the ToolParts into the Forge - *****/ - - /* - if (!slotList.get(0).isEmpty()) { - if (world.getBlockState(pos).getBlock() instanceof Forge) { - TileForge tile = (TileForge) world.getTileEntity(pos); - if (slotList.get(0).getItem() instanceof ToolPart) { - if(){ - ItemStack tempStack = slotList.get(0).copy(); - tile.setSlotStack(4, tempStack); - slotList.set(0, ItemStack.EMPTY); - return EnumActionResult.SUCCESS; - } - } - } - */ - /***** DROPS the ToolParts into the World *****/ @@ -430,6 +414,32 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{ slotList.set(0, ItemStack.EMPTY); return EnumActionResult.SUCCESS; } + if (!(slotList.get(0).getItem() instanceof BaseMultiItem)) { + if (RecipeHelper.isOreName(slotList.get(0).getItem(), "ingotIron")) { + ItemStack tempStack = slotList.get(0).copy(); + PlayerHelper.spawnItemOnGround(world, pos, tempStack); + slotList.set(0, ItemStack.EMPTY); + return EnumActionResult.SUCCESS; + } + if (RecipeHelper.isOreName(slotList.get(0).getItem(), "nuggetIron")) { + ItemStack tempStack = slotList.get(0).copy(); + PlayerHelper.spawnItemOnGround(world, pos, tempStack); + slotList.set(0, ItemStack.EMPTY); + return EnumActionResult.SUCCESS; + } + if (RecipeHelper.isOreName(slotList.get(0).getItem(), "ingotSteel")) { + ItemStack tempStack = slotList.get(0).copy(); + PlayerHelper.spawnItemOnGround(world, pos, tempStack); + slotList.set(0, ItemStack.EMPTY); + return EnumActionResult.SUCCESS; + } + if (RecipeHelper.isOreName(slotList.get(0).getItem(), "nuggetSteel")) { + ItemStack tempStack = slotList.get(0).copy(); + PlayerHelper.spawnItemOnGround(world, pos, tempStack); + slotList.set(0, ItemStack.EMPTY); + return EnumActionResult.SUCCESS; + } + } } } } @@ -462,4 +472,49 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{ return ItemStack.EMPTY; } + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flagIn) + { + if(!stack.isEmpty()) + { + SlottedTongs item = (SlottedTongs) stack.getItem(); + ItemStack slotStack = item.getSlotList().get(0).copy(); + System.out.println(slotStack); + if (!slotStack.isEmpty()) + { + tooltip.add(ChatFormatting.GRAY + "Holding: " + slotStack.getItem().getUnlocalizedName()); + /* + tooltip.add(ChatFormatting.GRAY + "Upgrades: " + (3 - getModifiers(item)) ); + if (getEmerald(item) == true) { + tooltip.add(ChatFormatting.DARK_GREEN + "Emerald"); + } + if (getDiamondLevel(item) > 0) { + tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item)); + } + if (getRedstoneLevel(item) > 0) { + tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) ); + } + if (getLapisLevel(item) > 0) { + tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) ); + } + tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() ); + */ + } + } + } + + @Override + public NBTTagCompound getNBTShareTag(ItemStack stack) + { + + return stack.getTagCompound(); + } + + @Override + public void readNBTShareTag(ItemStack stack, @Nullable NBTTagCompound nbt) + { + stack.setTagCompound(nbt); + } + } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/renders/blocks/TileForgeRender.java b/kfc/src/main/java/nmd/primal/forgecraft/renders/blocks/TileForgeRender.java index d5434dab..7c73fb68 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/renders/blocks/TileForgeRender.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/renders/blocks/TileForgeRender.java @@ -85,11 +85,10 @@ public class TileForgeRender extends TileEntitySpecialRenderer GL11.glPushMatrix(); double tempScale = 1.0D; GL11.glScaled(tempScale, tempScale, tempScale); - GL11.glTranslated(tile.getNormalX(a), -0.465D, tile.getNormalZ(i)); + GL11.glTranslated(tile.getNormalX(a), 0.0D, tile.getNormalZ(i)); renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); GL11.glPopMatrix(); } - if (item instanceof BaseMultiItem) { GL11.glPushMatrix(); double tempScale = 1.0D; @@ -98,67 +97,113 @@ public class TileForgeRender extends TileEntitySpecialRenderer renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); GL11.glPopMatrix(); } + } + counter++; + } + } + } + + if (state.getValue(Forge.FACING) == EnumFacing.SOUTH) { + //float tempScale = 0.8F; + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslated(-0.3F, 0.1D, -0.7D); + int counter = 1; + for (int i = 0; i < tile.getArraySize(); i++) { + for (int a = 0; a < tile.getArraySize(); a++) { + if (!tile.getSlotStack(counter).isEmpty()) { + Item item = tile.getSlotStack(counter).getItem(); + + if (item instanceof ToolPart ) { + GL11.glPushMatrix(); + double tempScale = 1.0D; + GL11.glScaled(tempScale, tempScale, tempScale); + GL11.glTranslated(tile.getReverseX(a), 0.0D, tile.getReverseZ(i)); + renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); + GL11.glPopMatrix(); + } + if (item instanceof BaseMultiItem) { + GL11.glPushMatrix(); + double tempScale = 1.0D; + GL11.glScaled(tempScale, tempScale, tempScale); + GL11.glTranslated(tile.getReverseX(a), -0.0625D, tile.getReverseZ(i)); + renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); + GL11.glPopMatrix(); + } } counter++; } } } -/* - for (int i = 1; i < tile.getSlotListSize(); i++) { - if (!tile.getSlotStack(i).isEmpty()) { - GL11.glPushMatrix(); - float tempScale = 0.8F; - GL11.glScalef(tempScale, tempScale, tempScale); - GL11.glTranslated(0.0F, 0.1D, 0.0F); - if (i == 1) { - GL11.glTranslated(-0.3, -0.05D, -0.3D); - if (tile.getSlotStack(i).getItem() == Items.IRON_INGOT) { - GL11.glScalef(0.5f, 0.5f, 0.5f); - GL11.glRotated(90.0F, 1.0f, 0.0f, 0.0f); - } - if (tile.getSlotStack(i).getItem() instanceof ToolPart) { - GL11.glRotated(180.0F, 0.0F, 1.0F, 0.0F); - } - } - if (i == 2) { - GL11.glTranslated(-0.3, -0.05D, 0.3D); - if (tile.getSlotStack(i).getItem() == Items.IRON_INGOT) { - GL11.glScalef(0.5f, 0.5f, 0.5f); - GL11.glRotated(90.0F, 1.0f, 0.0f, 0.0f); - } - if (tile.getSlotStack(i).getItem() instanceof ToolPart) { - GL11.glRotated(180.0F, 0.0F, 1.0F, 0.0F); - } - } - if (i == 3) { - if (tile.getSlotStack(i).getItem() == Items.IRON_INGOT) { - GL11.glScalef(0.5f, 0.5f, 0.5f); - GL11.glRotated(90.0F, 1.0f, 0.0f, 0.0f); - } - //GL11.glScalef(0.6F, 0.6F, 0.6F); - if (tile.getSlotStack(i).getItem() instanceof ToolPart) { - GL11.glRotated(180.0F, 0.0F, 1.0F, 0.0F); - } - } - if (i == 4) { - GL11.glTranslated(0.3, -0.05D, -0.3D); - if (tile.getSlotStack(i).getItem() == Items.IRON_INGOT) { - GL11.glScalef(0.5f, 0.5f, 0.5f); - GL11.glRotated(90.0F, 1.0f, 0.0f, 0.0f); - } - if (tile.getSlotStack(i).getItem() instanceof ToolPart) { - GL11.glRotated(180.0F, 0.0F, 1.0F, 0.0F); - } - } + if (state.getValue(Forge.FACING) == EnumFacing.WEST) { + //float tempScale = 0.8F; + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslated(-0.3F, 0.1D, -0.7D); + int counter = 1; + for (int a = 0; a < tile.getArraySize(); a++) { + for (int i = 0; i < tile.getArraySize(); i++) { + if (!tile.getSlotStack(counter).isEmpty()) { + Item item = tile.getSlotStack(counter).getItem(); + if (item instanceof ToolPart ) { + GL11.glPushMatrix(); + double tempScale = 1.0D; + GL11.glScaled(tempScale, tempScale, tempScale); + GL11.glTranslated(tile.getNormalX(a), 0.0D, tile.getReverseZ(i)); + renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); + GL11.glPopMatrix(); + } + if (item instanceof BaseMultiItem) { + GL11.glPushMatrix(); + double tempScale = 1.0D; + GL11.glScaled(tempScale, tempScale, tempScale); + GL11.glTranslated(tile.getNormalX(a), -0.0625D, tile.getReverseZ(i)); + renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); + GL11.glPopMatrix(); + } else { - renderItem.renderItem(tile.getSlotStack(i), ItemCameraTransforms.TransformType.FIXED); - //renderItem.renderItem(tile.getSlotStack(i), renderItem.getItemModelMesher().getItemModel(tile.getSlotStack(i))); - GL11.glPopMatrix(); + } + + } + counter++; + } } } -*/ + + if (state.getValue(Forge.FACING) == EnumFacing.EAST) { + //float tempScale = 0.8F; + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslated(-0.3F, 0.1D, -0.7D); + int counter = 1; + for (int a = 0; a < tile.getArraySize(); a++) { + for (int i = 0; i < tile.getArraySize(); i++) { + if (!tile.getSlotStack(counter).isEmpty()) { + Item item = tile.getSlotStack(counter).getItem(); + if (item instanceof ToolPart ) { + GL11.glPushMatrix(); + double tempScale = 1.0D; + GL11.glScaled(tempScale, tempScale, tempScale); + GL11.glTranslated(tile.getReverseX(a), 0.0D, tile.getNormalZ(i)); + renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); + GL11.glPopMatrix(); + } + if (item instanceof BaseMultiItem) { + GL11.glPushMatrix(); + double tempScale = 1.0D; + GL11.glScaled(tempScale, tempScale, tempScale); + GL11.glTranslated(tile.getReverseX(a), -0.0625D, tile.getNormalZ(i)); + renderItem.renderItem(tile.getSlotStack(counter), ItemCameraTransforms.TransformType.FIXED); + GL11.glPopMatrix(); + } else { + + } + + } + counter++; + } + } + } + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLGTX, prevLGTY); GL11.glPopMatrix(); } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseSlot.java b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseSlot.java index 91c977ea..c9284422 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseSlot.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileBaseSlot.java @@ -36,6 +36,8 @@ public abstract class TileBaseSlot extends BaseTile { return slotList.size(); } + + public int getSlotLimit() { //return ((ShelfBasic)this.getBlockType()).getShelfSize(); diff --git a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileForge.java b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileForge.java index a11211eb..6d4d6b74 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileForge.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileForge.java @@ -39,11 +39,10 @@ public class TileForge extends TileBaseSlot implements ITickable, ToolNBT{ public double getReverseX(Integer x) { return reverseMin[x]; } - public double getReverseZ(Integer x) { - return reverseMax[x]; + public double getReverseZ(Integer x) {return reverseMax[x]; } - private NonNullList slotList = NonNullList.withSize(5, ItemStack.EMPTY); + //private NonNullList mySlotList = NonNullList.withSize(5, ItemStack.EMPTY); //private ItemStack[] inventory = new ItemStack [0]; //private String customName; private int iteration = 0; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java b/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java index c0c3e50b..7fe7d17c 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/util/AnvilHandler.java @@ -363,23 +363,13 @@ public interface AnvilHandler { TileAnvil tile = (TileAnvil) world.getTileEntity(pos); if (tile != null) { for (ItemStack stack : tile.getSlotList()) { - if (stack != null) { + if (stack != ItemStack.EMPTY) { float offset = 0.7F; double offsetX = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D; double offsetY = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D; double offsetZ = world.rand.nextFloat() * offset + (1.0F - offset) * 0.5D; - ItemStack dropStack = null; - if (stack.getItem() instanceof BaseMultiItem) { - BaseMultiItem item = (BaseMultiItem) stack.getItem(); - } else { - dropStack = stack; - } - if(dropStack.hasTagCompound()){ - if(dropStack.getItem() instanceof ToolPart){ - dropStack.getSubCompound("tags").setBoolean("hot", false); - } - } - EntityItem itemDrop = new EntityItem(world, pos.getX() + offsetX, pos.getY() + offsetY, pos.getZ() + offsetZ, dropStack); + System.out.println(stack); + EntityItem itemDrop = new EntityItem(world, pos.getX() + offsetX, pos.getY() + offsetY, pos.getZ() + offsetZ, stack); itemDrop.setDefaultPickupDelay(); world.spawnEntity(itemDrop); } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/util/ForgeHandler.java b/kfc/src/main/java/nmd/primal/forgecraft/util/ForgeHandler.java index 1493dd78..f4f5afb1 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/util/ForgeHandler.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/util/ForgeHandler.java @@ -13,6 +13,7 @@ import nmd.primal.forgecraft.init.ModItems; import nmd.primal.forgecraft.items.BaseMultiItem; import nmd.primal.forgecraft.items.ForgeHammer; import nmd.primal.forgecraft.items.SlottedTongs; +import nmd.primal.forgecraft.items.parts.ToolPart; import nmd.primal.forgecraft.tiles.TileAnvil; import nmd.primal.forgecraft.tiles.TileForge; @@ -48,10 +49,7 @@ public interface ForgeHandler { *****************************************************************************/ default boolean doForgeInventoryManager(ItemStack pItem, World world, TileForge tile, BlockPos pos, float hitx, float hity, float hitz, IBlockState state, EntityPlayer player) { - //if ((!(pItem.getItem() instanceof Gallagher)) || (!(pItem.getItem() instanceof ForgeHammer))) { - // if (pItem.getItem() instanceof BaseMultiItem) { - // return false; - // } + if (state.getValue(FACING) == EnumFacing.NORTH) { int counter = 0; for (int z = 0; z < arraySize; z++) { @@ -113,22 +111,18 @@ public interface ForgeHandler { if (pItem.getItem().equals(ModItems.slottedtongs)) { SlottedTongs tongs = (SlottedTongs) pItem.getItem(); - ItemStack tongStack = tongs.getSlotList().get(0).copy(); - - if (tongStack.isEmpty()) { + ItemStack tongsStack = tongs.getSlotList().get(0).copy(); + if (tongsStack.isEmpty()) { if (!tile.getSlotStack(counter).isEmpty()) { - System.out.println("Removing stuff"); ItemStack tempStack = tile.getSlotStack(counter).copy(); tongs.setSlotList(tempStack); tile.setSlotStack(counter, ItemStack.EMPTY); - System.out.println(tongs.getSlotList().get(0)); return true; } } - if (!tongStack.isEmpty()) { + if (!tongsStack.isEmpty()) { if (tile.getSlotStack(counter).isEmpty()) { - System.out.println("Adding stuff"); ItemStack tempStack = tongs.getSlotList().get(0).copy(); tile.setSlotStack(counter, tempStack); tongs.setSlotList(ItemStack.EMPTY); @@ -147,32 +141,42 @@ public interface ForgeHandler { } } + if (pItem.getItem() instanceof ToolPart) { + if (tile.getSlotStack(counter).isEmpty()) { + ItemStack tempItem = pItem.copy(); + tempItem.setCount(1); + tile.setSlotStack(counter,tempItem); + player.inventory.getCurrentItem().shrink(1); + return true; + } + } + if (!(pItem.getItem() instanceof BaseMultiItem)) { if (RecipeHelper.isOreName(pItem, "ingotIron")) { if (tile.getSlotStack(counter).isEmpty()) { - tile.setSlotStack(counter, new ItemStack(Items.IRON_INGOT, 1)); - pItem.shrink(1); + tile.setSlotStack(counter, new ItemStack(ModItems.ironingotball, 1)); + player.inventory.getCurrentItem().shrink(1); return true; } } if (RecipeHelper.isOreName(pItem, "nuggetIron")) { if (tile.getSlotStack(counter).isEmpty()) { tile.setSlotStack(counter, new ItemStack(ModItems.wroughtironchunk, 1)); - pItem.shrink(1); + player.inventory.getCurrentItem().shrink(1); return true; } } if (RecipeHelper.isOreName(pItem, "ingotSteel")) { if (tile.getSlotStack(counter).isEmpty()) { tile.setSlotStack(counter, new ItemStack(ModItems.steelingotball, 1)); - pItem.shrink(1); + player.inventory.getCurrentItem().shrink(1); return true; } } if (RecipeHelper.isOreName(pItem, "nuggetSteel")) { if (tile.getSlotStack(counter).isEmpty()) { tile.setSlotStack(counter, new ItemStack(ModItems.steelchunk, 1)); - pItem.shrink(1); + player.inventory.getCurrentItem().shrink(1); return true; } }