workign through issues in the ForgeHandler
This commit is contained in:
@@ -102,7 +102,6 @@ public class Forge extends CustomContainerFacing implements ITileEntityProvider,
|
|||||||
ItemStack pItem = player.inventory.getCurrentItem().copy();
|
ItemStack pItem = player.inventory.getCurrentItem().copy();
|
||||||
ItemStack fuelItem = tile.getSlotStack(0);
|
ItemStack fuelItem = tile.getSlotStack(0);
|
||||||
|
|
||||||
if (!world.isRemote) {
|
|
||||||
/***********************
|
/***********************
|
||||||
FUEL SLOT CODE
|
FUEL SLOT CODE
|
||||||
***********************/
|
***********************/
|
||||||
@@ -166,8 +165,6 @@ public class Forge extends CustomContainerFacing implements ITileEntityProvider,
|
|||||||
doForgeInventoryManager(pItem, world, tile, pos, hitX, hitY, hitZ, state, player);
|
doForgeInventoryManager(pItem, world, tile, pos, hitX, hitY, hitZ, state, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -325,15 +325,14 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{
|
|||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
Block block = world.getBlockState(pos).getBlock();
|
Block block = world.getBlockState(pos).getBlock();
|
||||||
ItemStack itemstack = player.getHeldItem(hand);
|
ItemStack itemstack = player.getHeldItem(hand);
|
||||||
|
|
||||||
IItemHandler inventory = itemstack.getCapability(ITEM_HANDLER, null);
|
IItemHandler inventory = itemstack.getCapability(ITEM_HANDLER, null);
|
||||||
ItemStack slotStack = inventory.getStackInSlot(0).copy();
|
ItemStack slotStack = inventory.getStackInSlot(0).copy();
|
||||||
/*
|
|
||||||
if (block instanceof AnvilStone) {
|
|
||||||
TileAnvil tile = (TileAnvil) world.getTileEntity(pos);
|
if (!(block instanceof AnvilBase)) {
|
||||||
doAnvilInventoryManager(itemstack, world, tile, pos, hitx, hity, hitz, state, player);
|
if (!(block instanceof Forge)) {
|
||||||
return EnumActionResult.SUCCESS;
|
System.out.println(inventory.getStackInSlot(0));
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (slotStack.isEmpty()) {
|
if (slotStack.isEmpty()) {
|
||||||
if (block instanceof NBTCrucible) {
|
if (block instanceof NBTCrucible) {
|
||||||
ItemStack tempStack = takeBlock(world, pos, state, face, player, block).copy();
|
ItemStack tempStack = takeBlock(world, pos, state, face, player, block).copy();
|
||||||
@@ -361,14 +360,14 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{
|
|||||||
DROPS the ToolParts into the World
|
DROPS the ToolParts into the World
|
||||||
*****/
|
*****/
|
||||||
if (!slotStack.isEmpty()) {
|
if (!slotStack.isEmpty()) {
|
||||||
if (!(block instanceof AnvilBase)) {
|
|
||||||
if (slotStack.getItem() instanceof ToolPart) {
|
if (slotStack.getItem() instanceof ToolPart) {
|
||||||
ItemStack tempStack = slotStack;
|
ItemStack tempStack = slotStack;
|
||||||
PlayerHelper.spawnItemOnGround(world, pos, tempStack);
|
PlayerHelper.spawnItemOnGround(world, pos, tempStack);
|
||||||
inventory.extractItem(0, 1, false);
|
inventory.extractItem(0, 1, false);
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****
|
/*****
|
||||||
@@ -396,12 +395,12 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{
|
|||||||
DROPS the Ingots into the World
|
DROPS the Ingots into the World
|
||||||
*****/
|
*****/
|
||||||
if (!slotStack.isEmpty()) {
|
if (!slotStack.isEmpty()) {
|
||||||
if (!(block instanceof AnvilBase)) {
|
System.out.println("Tongs isn't empty");
|
||||||
if (!(block instanceof Forge)) {
|
|
||||||
if (slotStack.getItem() instanceof BaseMultiItem) {
|
if (slotStack.getItem() instanceof BaseMultiItem) {
|
||||||
ItemStack tempStack = slotStack.copy();
|
ItemStack tempStack = slotStack.copy();
|
||||||
PlayerHelper.spawnItemOnGround(world, pos, tempStack);
|
PlayerHelper.spawnItemOnGround(world, pos, tempStack);
|
||||||
inventory.extractItem(0, 1, false);
|
inventory.extractItem(0, 1, false);
|
||||||
|
System.out.println(inventory.getStackInSlot(0));
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
if (!(slotStack.getItem() instanceof BaseMultiItem)) {
|
if (!(slotStack.getItem() instanceof BaseMultiItem)) {
|
||||||
@@ -434,9 +433,7 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EnumActionResult.FAIL;
|
|
||||||
}
|
}
|
||||||
return EnumActionResult.FAIL;
|
|
||||||
}
|
}
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
}
|
}
|
||||||
@@ -500,11 +497,11 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{
|
|||||||
@Override
|
@Override
|
||||||
public NBTTagCompound getNBTShareTag(ItemStack stack)
|
public NBTTagCompound getNBTShareTag(ItemStack stack)
|
||||||
{
|
{
|
||||||
super.getNBTShareTag(stack);
|
return super.getNBTShareTag(stack);
|
||||||
IItemHandler inventory = stack.getCapability(ITEM_HANDLER, null);
|
//IItemHandler inventory = stack.getCapability(ITEM_HANDLER, null);
|
||||||
NonNullList<ItemStack> setList = NonNullList.<ItemStack>withSize(1, ItemStack.EMPTY);
|
//NonNullList<ItemStack> setList = NonNullList.<ItemStack>withSize(1, ItemStack.EMPTY);
|
||||||
ItemStackHelper.saveAllItems(stack.getTagCompound(), setList);
|
//ItemStackHelper.saveAllItems(stack.getTagCompound(), setList);
|
||||||
return stack.getTagCompound();
|
//return stack.getTagCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -512,11 +509,11 @@ public class SlottedTongs extends Item implements IPickup, AnvilHandler{
|
|||||||
{
|
{
|
||||||
super.readNBTShareTag(stack, nbt);
|
super.readNBTShareTag(stack, nbt);
|
||||||
|
|
||||||
stack.deserializeNBT(nbt);
|
//stack.deserializeNBT(nbt);
|
||||||
IItemHandler inventory = stack.getCapability(ITEM_HANDLER, null);
|
//IItemHandler inventory = stack.getCapability(ITEM_HANDLER, null);
|
||||||
NonNullList<ItemStack> setList = NonNullList.<ItemStack>withSize(1, ItemStack.EMPTY);
|
//NonNullList<ItemStack> setList = NonNullList.<ItemStack>withSize(1, ItemStack.EMPTY);
|
||||||
ItemStackHelper.loadAllItems(nbt, setList);
|
//ItemStackHelper.loadAllItems(nbt, setList);
|
||||||
inventory.insertItem(0, setList.get(0), false);
|
//inventory.insertItem(0, setList.get(0), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ public interface AnvilHandler {
|
|||||||
|
|
||||||
static boolean doWork(ItemStack pItem, Integer counter, TileAnvil tile, World world, BlockPos pos, EntityPlayer player) {
|
static boolean doWork(ItemStack pItem, Integer counter, TileAnvil tile, World world, BlockPos pos, EntityPlayer player) {
|
||||||
|
|
||||||
|
if (!world.isRemote) {
|
||||||
if (pItem.getItem().equals(ModItems.slottedtongs)) {
|
if (pItem.getItem().equals(ModItems.slottedtongs)) {
|
||||||
|
|
||||||
IItemHandler inventory = pItem.getCapability(ITEM_HANDLER, null);
|
IItemHandler inventory = pItem.getCapability(ITEM_HANDLER, null);
|
||||||
@@ -259,7 +260,7 @@ public interface AnvilHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!world.isRemote) {
|
|
||||||
|
|
||||||
if (pItem.getItem().equals(Items.AIR) && player.isSneaking()) {
|
if (pItem.getItem().equals(Items.AIR) && player.isSneaking()) {
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.util.EnumFacing;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import nmd.primal.core.common.helper.RecipeHelper;
|
import nmd.primal.core.common.helper.RecipeHelper;
|
||||||
import nmd.primal.core.common.items.tools.Gallagher;
|
import nmd.primal.core.common.items.tools.Gallagher;
|
||||||
import nmd.primal.forgecraft.init.ModItems;
|
import nmd.primal.forgecraft.init.ModItems;
|
||||||
@@ -53,6 +54,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) {
|
default boolean doForgeInventoryManager(ItemStack pItem, World world, TileForge tile, BlockPos pos, float hitx, float hity, float hitz, IBlockState state, EntityPlayer player) {
|
||||||
|
|
||||||
if (state.getValue(FACING) == EnumFacing.NORTH) {
|
if (state.getValue(FACING) == EnumFacing.NORTH) {
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int z = 0; z < arraySize; z++) {
|
for (int z = 0; z < arraySize; z++) {
|
||||||
for (int x = 0; x < arraySize; x++) {
|
for (int x = 0; x < arraySize; x++) {
|
||||||
@@ -109,16 +111,15 @@ public interface ForgeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean doWork(ItemStack pItem, Integer counter, TileForge tile, World world, BlockPos pos, EntityPlayer player) {
|
static boolean doWork(ItemStack pItem, Integer counter, TileForge tile, World world, BlockPos pos, EntityPlayer player) {
|
||||||
|
|
||||||
if (pItem.getItem().equals(ModItems.slottedtongs)) {
|
if (pItem.getItem().equals(ModItems.slottedtongs)) {
|
||||||
IItemHandler inventory = pItem.getCapability(ITEM_HANDLER, null);
|
IItemHandler inventory = (IItemHandlerModifiable) pItem.getCapability(ITEM_HANDLER, null);
|
||||||
ItemStack tongsStack = inventory.getStackInSlot(0).copy();
|
ItemStack tongsStack = inventory.getStackInSlot(0).copy();
|
||||||
|
|
||||||
if (tongsStack.isEmpty()) {
|
if (tongsStack.isEmpty()) {
|
||||||
if (!tile.getSlotStack(counter).isEmpty()) {
|
if (!tile.getSlotStack(counter).isEmpty()) {
|
||||||
ItemStack tempStack = tile.getSlotStack(counter).copy();
|
ItemStack tempStack = tile.getSlotStack(counter).copy();
|
||||||
inventory.insertItem(0, tempStack, false);
|
|
||||||
tile.setSlotStack(counter, ItemStack.EMPTY);
|
tile.setSlotStack(counter, ItemStack.EMPTY);
|
||||||
|
inventory.insertItem(0, tempStack, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user