mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-28 16:06:06 +00:00
Fixed a lot of NPE's and few duplication glitches
(cherry-pick from other fork)
This commit is contained in:
1 parent
cae72b2db6
commit
6bd68f13b1
12 files changed
+292
-162
No files matched your search
@@ -1,11 +1,17 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.tools.inventory.CraftingStationContainer;
|
||||
|
||||
@@ -93,6 +99,26 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
return new int[] {};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return isUseableByPlayer(player, this.getInventories()) && super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public static boolean isUseableByPlayer(EntityPlayer player, WeakReference[] inventories) {
|
||||
for (WeakReference<IInventory> ref : inventories)
|
||||
{
|
||||
if (ref != null)
|
||||
{
|
||||
IInventory inv = ref.get();
|
||||
if (inv != null && !inv.isUseableByPlayer(player))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
@@ -142,6 +168,11 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
|
||||
}
|
||||
|
||||
public WeakReference[] getInventories()
|
||||
{
|
||||
return new WeakReference[] { this.chest, this.doubleChest, this.patternChest, this.furnace };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,8 @@ package tconstruct.tools.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
@@ -55,13 +56,20 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if (slot == 0) {
|
||||
if(itemstack != null && StencilBuilder.isBlank(itemstack)) {
|
||||
if (itemstack != null && StencilBuilder.isBlank(itemstack))
|
||||
{
|
||||
super.setInventorySlotContents(1, selectedStack);
|
||||
} else if(itemstack!=null) {
|
||||
}
|
||||
else if (itemstack!=null)
|
||||
{
|
||||
ItemStack cpy=itemstack.copy();
|
||||
cpy.stackSize=1;
|
||||
super.setInventorySlotContents(1, cpy);
|
||||
}else super.setInventorySlotContents(1,null);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setInventorySlotContents(1,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package tconstruct.tools.logic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.crafting.*;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.inventory.ToolStationContainer;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
@@ -193,7 +193,7 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user