Disabled Hopper interaction due to bugs
I can't explain what is going on between the crate and hopper. As far as i can see the crate works fine with pipes, and other things. However the hopper creates new bugs that i can't solve at the moment. It will keep trying to input items into the crate after the crate is full. It will then after world load trash a crates inv that its pulling from. Since i believe that the hopper is the root cause i'm going to just disable it use with crates.
This commit is contained in:
parent
3b379c0a9d
commit
e6a35a6a72
3 changed files with 43 additions and 32 deletions
|
@ -389,7 +389,7 @@ public class BlockCrate extends BlockALMachine
|
||||||
{
|
{
|
||||||
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
|
TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z);
|
||||||
ItemStack containingStack = tileEntity.getSampleStack();
|
ItemStack containingStack = tileEntity.getSampleStack();
|
||||||
tileEntity.buildSampleStack();
|
tileEntity.buildSampleStack(false);
|
||||||
|
|
||||||
if (containingStack != null)
|
if (containingStack != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class ItemBlockCrate extends ItemBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
tileEntity.buildSampleStack();
|
tileEntity.buildSampleStack(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,11 @@ import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.INetworkManager;
|
import net.minecraft.network.INetworkManager;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityHopper;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import universalelectricity.core.vector.Vector3;
|
||||||
|
import universalelectricity.core.vector.VectorHelper;
|
||||||
import universalelectricity.prefab.implement.ITier;
|
import universalelectricity.prefab.implement.ITier;
|
||||||
import universalelectricity.prefab.network.IPacketReceiver;
|
import universalelectricity.prefab.network.IPacketReceiver;
|
||||||
import universalelectricity.prefab.network.PacketManager;
|
import universalelectricity.prefab.network.PacketManager;
|
||||||
|
@ -31,7 +36,7 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
|
|
||||||
public long prevClickTime = -1000;
|
public long prevClickTime = -1000;
|
||||||
|
|
||||||
public void buildSampleStack()
|
public void buildSampleStack(boolean force)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
@ -41,15 +46,7 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
/* Similar to Init but checks so often just in case something does break */
|
/* Similar to Init but checks so often just in case something does break */
|
||||||
if (worldObj != null)
|
if (worldObj != null)
|
||||||
{
|
{
|
||||||
if (slots == null || slots != null && slots.length != this.getSlotCount())
|
if (this.items != null && this.items.length > this.getSlotCount())
|
||||||
{
|
|
||||||
slots = new int[this.getSlotCount()];
|
|
||||||
for (int i = 0; i < slots.length; i++)
|
|
||||||
{
|
|
||||||
slots[i] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.items != null && this.items.length != this.getSlotCount())
|
|
||||||
{
|
{
|
||||||
ItemStack[] itemSet = this.items.clone();
|
ItemStack[] itemSet = this.items.clone();
|
||||||
this.items = new ItemStack[this.getSlotCount()];
|
this.items = new ItemStack[this.getSlotCount()];
|
||||||
|
@ -89,9 +86,9 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
this.sampleStack = new ItemStack(id, count, meta);
|
this.sampleStack = new ItemStack(id, count, meta);
|
||||||
}
|
}
|
||||||
/* if one stack is over sized this rebuilds the inv to redistribute the items in the slots */
|
/* if one stack is over sized this rebuilds the inv to redistribute the items in the slots */
|
||||||
if (rebuildBase && this.getSampleStack() != null)
|
if ((rebuildBase || force) && this.sampleStack != null)
|
||||||
{
|
{
|
||||||
ItemStack baseStack = this.getSampleStack().copy();
|
ItemStack baseStack = this.sampleStack.copy();
|
||||||
this.items = new ItemStack[this.getSlotCount()];
|
this.items = new ItemStack[this.getSlotCount()];
|
||||||
for (int slot = 0; slot < this.items.length; slot++)
|
for (int slot = 0; slot < this.items.length; slot++)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +108,7 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
{
|
{
|
||||||
if (this.sampleStack == null)
|
if (this.sampleStack == null)
|
||||||
{
|
{
|
||||||
this.buildSampleStack();
|
this.buildSampleStack(false);
|
||||||
}
|
}
|
||||||
return this.sampleStack;
|
return this.sampleStack;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +173,7 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
@Override
|
@Override
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
this.buildSampleStack();
|
this.buildSampleStack(false);
|
||||||
ItemStack stack = this.getSampleStack();
|
ItemStack stack = this.getSampleStack();
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +232,7 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
{
|
{
|
||||||
if (this.items[slot] != null)
|
if (this.items[slot] != null)
|
||||||
{
|
{
|
||||||
ItemStack var2 = this.items[slot];
|
ItemStack var2 = this.items[slot].copy();
|
||||||
this.items[slot] = null;
|
this.items[slot] = null;
|
||||||
return var2;
|
return var2;
|
||||||
}
|
}
|
||||||
|
@ -248,20 +245,13 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack != null)
|
this.items[slot] = stack;
|
||||||
{
|
|
||||||
this.items[slot] = stack;
|
|
||||||
|
|
||||||
if (stack.stackSize > this.getInventoryStackLimit())
|
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
|
||||||
{
|
|
||||||
stack.stackSize = this.getInventoryStackLimit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.items[slot] = null;
|
stack.stackSize = this.getInventoryStackLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
|
||||||
{
|
{
|
||||||
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj);
|
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj);
|
||||||
|
@ -328,7 +318,7 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
this.buildSampleStack();
|
this.buildSampleStack(false);
|
||||||
ItemStack stack = this.getSampleStack();
|
ItemStack stack = this.getSampleStack();
|
||||||
if (stack != null)
|
if (stack != null)
|
||||||
{
|
{
|
||||||
|
@ -381,11 +371,11 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
@Override
|
@Override
|
||||||
public boolean isStackValidForSlot(int slot, ItemStack itemstack)
|
public boolean isStackValidForSlot(int slot, ItemStack itemstack)
|
||||||
{
|
{
|
||||||
if (this.sampleStack == null)
|
if(slot >= this.getSlotCount())
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
else if (itemstack != null && itemstack.equals(this.sampleStack))
|
if (this.sampleStack == null || itemstack != null && itemstack.isItemEqual(this.sampleStack))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -395,18 +385,39 @@ public class TileEntityCrate extends TileEntityAdvanced implements ITier, IInven
|
||||||
@Override
|
@Override
|
||||||
public int[] getAccessibleSlotsFromSide(int side)
|
public int[] getAccessibleSlotsFromSide(int side)
|
||||||
{
|
{
|
||||||
|
if (slots == null || slots != null && slots.length != this.getSlotCount())
|
||||||
|
{
|
||||||
|
slots = new int[this.getSlotCount()];
|
||||||
|
for (int i = 0; i < slots.length; i++)
|
||||||
|
{
|
||||||
|
slots[i] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.slots;
|
return this.slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
|
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
|
||||||
{
|
{
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(side);
|
||||||
|
TileEntity ent = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), dir);
|
||||||
|
if(ent instanceof TileEntityHopper)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.isStackValidForSlot(slot, itemstack);
|
return this.isStackValidForSlot(slot, itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
|
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
|
||||||
{
|
{
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(side);
|
||||||
|
TileEntity ent = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), dir);
|
||||||
|
if(ent instanceof TileEntityHopper)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue