Finished drawing labels over filter-supporting machines
Also cleaned up some packet code and modularized filters
This commit is contained in:
parent
46c59251fc
commit
2a732328a1
10 changed files with 360 additions and 456 deletions
|
@ -10,6 +10,7 @@ import assemblyline.client.gui.GuiStamper;
|
||||||
import assemblyline.client.render.BlockRenderingHandler;
|
import assemblyline.client.render.BlockRenderingHandler;
|
||||||
import assemblyline.client.render.RenderConveyorBelt;
|
import assemblyline.client.render.RenderConveyorBelt;
|
||||||
import assemblyline.client.render.RenderCrate;
|
import assemblyline.client.render.RenderCrate;
|
||||||
|
import assemblyline.client.render.RenderDetector;
|
||||||
import assemblyline.client.render.RenderManipulator;
|
import assemblyline.client.render.RenderManipulator;
|
||||||
import assemblyline.client.render.RenderSorter;
|
import assemblyline.client.render.RenderSorter;
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
|
@ -18,6 +19,7 @@ import assemblyline.common.block.TileEntityCrate;
|
||||||
import assemblyline.common.machine.TileEntityManipulator;
|
import assemblyline.common.machine.TileEntityManipulator;
|
||||||
import assemblyline.common.machine.TileEntityRejector;
|
import assemblyline.common.machine.TileEntityRejector;
|
||||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
|
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
|
||||||
|
import assemblyline.common.machine.detector.TileEntityDetector;
|
||||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
|
|
||||||
|
@ -37,6 +39,7 @@ public class ClientProxy extends CommonProxy
|
||||||
super.init();
|
super.init();
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConveyorBelt.class, new RenderConveyorBelt());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConveyorBelt.class, new RenderConveyorBelt());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderSorter());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderSorter());
|
||||||
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDetector.class, new RenderDetector());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,16 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderDetector extends TileEntitySpecialRenderer
|
public class RenderDetector extends RenderFilterable
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof TileEntityDetector)
|
if (tileEntity instanceof TileEntityDetector)
|
||||||
{
|
{
|
||||||
this.render(((TileEntityDetector) tileEntity).isInverted(), new Vector3(x, y, z));
|
//this.render(((TileEntityDetector) tileEntity).isInverted(), new Vector3(x, y, z));
|
||||||
}
|
}
|
||||||
|
super.renderTileEntityAt(tileEntity, x, y, z, var8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void render(boolean isInverted, Vector3 position)
|
public static void render(boolean isInverted, Vector3 position)
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package assemblyline.client.render;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import assemblyline.common.machine.TileEntityFilterable;
|
||||||
|
import assemblyline.common.machine.filter.ItemFilter;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
public abstract class RenderFilterable extends TileEntitySpecialRenderer
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||||
|
{
|
||||||
|
if (tileEntity instanceof TileEntityFilterable)
|
||||||
|
{
|
||||||
|
TileEntityFilterable filterable = (TileEntityFilterable) tileEntity;
|
||||||
|
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||||
|
double dist = p.getDistance(filterable.xCoord, filterable.yCoord, filterable.zCoord);
|
||||||
|
if (dist < 5)
|
||||||
|
{
|
||||||
|
ItemStack filter = filterable.getFilter();
|
||||||
|
if (filter != null)
|
||||||
|
{
|
||||||
|
ArrayList<ItemStack> filters = ItemFilter.getFilters(filter);
|
||||||
|
for (int i = 0; i < filters.size(); i++)
|
||||||
|
{
|
||||||
|
RenderHelper.renderFloatingText(filters.get(i).getTooltip(p, Minecraft.getMinecraft().gameSettings.advancedItemTooltips).get(0).toString(), (float) x + 0.5f, ((float) y + (i * 0.25f)) - 1f, (float) z + 0.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ public class RenderHelper
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
int stringMiddle = fontRenderer.getStringWidth(text) / 2;
|
int stringMiddle = fontRenderer.getStringWidth(text) / 2;
|
||||||
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
|
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.5F);
|
||||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (-1 + yOffset), 0.0D);
|
tessellator.addVertex((double) (-stringMiddle - 1), (double) (-1 + yOffset), 0.0D);
|
||||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (8 + yOffset), 0.0D);
|
tessellator.addVertex((double) (-stringMiddle - 1), (double) (8 + yOffset), 0.0D);
|
||||||
tessellator.addVertex((double) (stringMiddle + 1), (double) (8 + yOffset), 0.0D);
|
tessellator.addVertex((double) (stringMiddle + 1), (double) (8 + yOffset), 0.0D);
|
||||||
|
|
|
@ -15,7 +15,7 @@ import assemblyline.common.AssemblyLine;
|
||||||
import assemblyline.common.machine.TileEntityRejector;
|
import assemblyline.common.machine.TileEntityRejector;
|
||||||
import assemblyline.common.machine.filter.ItemFilter;
|
import assemblyline.common.machine.filter.ItemFilter;
|
||||||
|
|
||||||
public class RenderSorter extends TileEntitySpecialRenderer
|
public class RenderSorter extends RenderFilterable
|
||||||
{
|
{
|
||||||
private ModelSorter model = new ModelSorter();
|
private ModelSorter model = new ModelSorter();
|
||||||
|
|
||||||
|
@ -52,28 +52,13 @@ public class RenderSorter extends TileEntitySpecialRenderer
|
||||||
model.renderMain(0.0625F);
|
model.renderMain(0.0625F);
|
||||||
model.renderPiston(0.0625F, pos);
|
model.renderPiston(0.0625F, pos);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
|
||||||
double dist = p.getDistance(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
|
||||||
System.out.println(dist);
|
|
||||||
if (dist < 5)
|
|
||||||
{
|
|
||||||
ItemStack filter = tileEntity.getFilter();
|
|
||||||
if (filter != null)
|
|
||||||
{
|
|
||||||
ArrayList<ItemStack> filters = ItemFilter.getFilters(filter);
|
|
||||||
for (int i = 0; i < filters.size(); i++)
|
|
||||||
{
|
|
||||||
RenderHelper.renderFloatingText(filters.get(i).getDisplayName(), (float) x + 0.5f, ((float) y + (i * 0.25f)) - 1f, (float) z + 0.5f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||||
{
|
{
|
||||||
this.renderAModelAt((TileEntityRejector) tileEntity, var2, var4, var6, var8);
|
this.renderAModelAt((TileEntityRejector) tileEntity, var2, var4, var6, var8);
|
||||||
|
super.renderTileEntityAt(tileEntity, var2, var4, var6, var8);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,222 @@
|
||||||
|
package assemblyline.common.machine;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.INetworkManager;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
|
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import universalelectricity.prefab.implement.IRotatable;
|
||||||
|
import universalelectricity.prefab.network.IPacketReceiver;
|
||||||
|
import universalelectricity.prefab.network.PacketManager;
|
||||||
|
import universalelectricity.prefab.network.PacketManager.PacketType;
|
||||||
|
import assemblyline.api.IFilterable;
|
||||||
|
import assemblyline.common.AssemblyLine;
|
||||||
|
|
||||||
|
public abstract class TileEntityFilterable extends TileEntityAssemblyNetwork implements IRotatable, IFilterable, IPacketReceiver, IInventory
|
||||||
|
{
|
||||||
|
private ItemStack filterItem;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSizeInventory()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot)
|
||||||
|
{
|
||||||
|
if (slot == 0)
|
||||||
|
return filterItem;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int slot, int amount)
|
||||||
|
{
|
||||||
|
if (filterItem != null)
|
||||||
|
{
|
||||||
|
ItemStack stack;
|
||||||
|
|
||||||
|
if (filterItem.stackSize <= amount)
|
||||||
|
{
|
||||||
|
stack = filterItem;
|
||||||
|
filterItem = null;
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack = filterItem.splitStack(amount);
|
||||||
|
|
||||||
|
if (filterItem.stackSize == 0)
|
||||||
|
{
|
||||||
|
filterItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlotOnClosing(int slot)
|
||||||
|
{
|
||||||
|
if (filterItem != null)
|
||||||
|
{
|
||||||
|
ItemStack stack = filterItem;
|
||||||
|
filterItem = null;
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||||
|
{
|
||||||
|
filterItem = stack;
|
||||||
|
|
||||||
|
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
|
||||||
|
{
|
||||||
|
stack.stackSize = this.getInventoryStackLimit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||||
|
{
|
||||||
|
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openChest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeChest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFilter(ItemStack filter)
|
||||||
|
{
|
||||||
|
this.setInventorySlotContents(0, filter);
|
||||||
|
PacketManager.sendPacketToClients(getDescriptionPacket());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getFilter()
|
||||||
|
{
|
||||||
|
return this.getStackInSlot(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ForgeDirection getDirection()
|
||||||
|
{
|
||||||
|
return ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDirection(ForgeDirection facingDirection)
|
||||||
|
{
|
||||||
|
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, facingDirection.ordinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract String getInvName();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventoryStackLimit()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket()
|
||||||
|
{
|
||||||
|
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||||
|
packet.channel = AssemblyLine.CHANNEL;
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream dos = new DataOutputStream(bos);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dos.writeInt(PacketType.TILEENTITY.ordinal());
|
||||||
|
dos.writeInt(xCoord);
|
||||||
|
dos.writeInt(yCoord);
|
||||||
|
dos.writeInt(zCoord);
|
||||||
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
|
writeToNBT(tag);
|
||||||
|
PacketManager.writeNBTTagCompound(tag, dos);
|
||||||
|
packet.data = bos.toByteArray();
|
||||||
|
packet.length = bos.size();
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||||
|
{
|
||||||
|
ByteArrayInputStream bis = new ByteArrayInputStream(packet.data);
|
||||||
|
DataInputStream dis = new DataInputStream(bis);
|
||||||
|
int id, x, y, z;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
id = dis.readInt();
|
||||||
|
x = dis.readInt();
|
||||||
|
y = dis.readInt();
|
||||||
|
z = dis.readInt();
|
||||||
|
NBTTagCompound tag = Packet.readNBTTagCompound(dis);
|
||||||
|
readFromNBT(tag);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
|
NBTTagCompound filter = new NBTTagCompound();
|
||||||
|
if (getFilter() != null)
|
||||||
|
getFilter().writeToNBT(filter);
|
||||||
|
nbt.setTag("filter", filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
NBTTagCompound filter = nbt.getCompoundTag("filter");
|
||||||
|
setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(filter));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -44,12 +44,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
* @author Darkguardsman
|
* @author Darkguardsman
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRotatable, IFilterable, IPacketReceiver, IInventory
|
public class TileEntityRejector extends TileEntityFilterable
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The items this container contains.
|
|
||||||
*/
|
|
||||||
protected ItemStack[] containingItems = new ItemStack[1];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to id the packet types
|
* Used to id the packet types
|
||||||
|
@ -165,9 +161,9 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
||||||
EntityItem entityItem = (EntityItem) entity;
|
EntityItem entityItem = (EntityItem) entity;
|
||||||
ItemStack itemStack = entityItem.func_92014_d();
|
ItemStack itemStack = entityItem.func_92014_d();
|
||||||
|
|
||||||
if (this.containingItems[0] != null)
|
if (getFilter() != null)
|
||||||
{
|
{
|
||||||
ArrayList<ItemStack> checkStacks = ItemFilter.getFilters(this.containingItems[0]);
|
ArrayList<ItemStack> checkStacks = ItemFilter.getFilters(getFilter());
|
||||||
|
|
||||||
// Reject matching items
|
// Reject matching items
|
||||||
for (int i = 0; i < checkStacks.size(); i++)
|
for (int i = 0; i < checkStacks.size(); i++)
|
||||||
|
@ -243,12 +239,6 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
||||||
return TranslationHelper.getLocal("tile.rejector.name");
|
return TranslationHelper.getLocal("tile.rejector.name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSizeInventory()
|
|
||||||
{
|
|
||||||
return this.containingItems.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UE methods
|
* UE methods
|
||||||
*/
|
*/
|
||||||
|
@ -258,90 +248,6 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
||||||
return 120;
|
return 120;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Inventory functions.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int par1)
|
|
||||||
{
|
|
||||||
return this.containingItems[par1];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack decrStackSize(int par1, int par2)
|
|
||||||
{
|
|
||||||
if (this.containingItems[par1] != null)
|
|
||||||
{
|
|
||||||
ItemStack var3;
|
|
||||||
|
|
||||||
if (this.containingItems[par1].stackSize <= par2)
|
|
||||||
{
|
|
||||||
var3 = this.containingItems[par1];
|
|
||||||
this.containingItems[par1] = null;
|
|
||||||
return var3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var3 = this.containingItems[par1].splitStack(par2);
|
|
||||||
|
|
||||||
if (this.containingItems[par1].stackSize == 0)
|
|
||||||
{
|
|
||||||
this.containingItems[par1] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return var3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlotOnClosing(int par1)
|
|
||||||
{
|
|
||||||
if (this.containingItems[par1] != null)
|
|
||||||
{
|
|
||||||
ItemStack var2 = this.containingItems[par1];
|
|
||||||
this.containingItems[par1] = null;
|
|
||||||
return var2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
|
||||||
{
|
|
||||||
this.containingItems[par1] = par2ItemStack;
|
|
||||||
|
|
||||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
|
||||||
{
|
|
||||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
|
||||||
{
|
|
||||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openChest()
|
|
||||||
{
|
|
||||||
this.playerUsing++;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeChest()
|
|
||||||
{
|
|
||||||
this.playerUsing--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NBT Data
|
* NBT Data
|
||||||
*/
|
*/
|
||||||
|
@ -350,27 +256,6 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
/*for (int i = 0; i < this.guiButtons.length; i++)
|
|
||||||
{
|
|
||||||
this.guiButtons[i] = nbt.getBoolean("guiButton" + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
NBTTagList var2 = nbt.getTagList("Items");
|
|
||||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
|
||||||
|
|
||||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
|
|
||||||
{
|
|
||||||
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
|
|
||||||
byte var5 = var4.getByte("Slot");
|
|
||||||
|
|
||||||
if (var5 >= 0 && var5 < this.containingItems.length)
|
|
||||||
{
|
|
||||||
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
NBTTagCompound filter = nbt.getCompoundTag("filter");
|
|
||||||
setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(filter));
|
|
||||||
firePiston = nbt.getBoolean("piston");
|
firePiston = nbt.getBoolean("piston");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,106 +267,6 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
/*for (int i = 0; i < this.guiButtons.length; i++)
|
|
||||||
{
|
|
||||||
nbt.setBoolean("guiButton" + i, this.guiButtons[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
NBTTagList var2 = new NBTTagList();
|
|
||||||
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
|
|
||||||
{
|
|
||||||
if (this.containingItems[var3] != null)
|
|
||||||
{
|
|
||||||
NBTTagCompound var4 = new NBTTagCompound();
|
|
||||||
var4.setByte("Slot", (byte) var3);
|
|
||||||
this.containingItems[var3].writeToNBT(var4);
|
|
||||||
var2.appendTag(var4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nbt.setTag("Items", var2);*/
|
|
||||||
NBTTagCompound filter = new NBTTagCompound();
|
|
||||||
if (getStackInSlot(0) != null)
|
|
||||||
getStackInSlot(0).writeToNBT(filter);
|
|
||||||
nbt.setCompoundTag("filter", filter);
|
|
||||||
nbt.setBoolean("piston", firePiston);
|
nbt.setBoolean("piston", firePiston);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFilter(ItemStack filter)
|
|
||||||
{
|
|
||||||
this.setInventorySlotContents(0, filter);
|
|
||||||
PacketManager.sendPacketToClients(getDescriptionPacket());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getFilter()
|
|
||||||
{
|
|
||||||
return this.getStackInSlot(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ForgeDirection getDirection()
|
|
||||||
{
|
|
||||||
return ForgeDirection.getOrientation(this.getBlockMetadata());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDirection(ForgeDirection facingDirection)
|
|
||||||
{
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, facingDirection.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet getDescriptionPacket()
|
|
||||||
{
|
|
||||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
|
||||||
packet.channel = AssemblyLine.CHANNEL;
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(bos);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
dos.writeInt(PacketType.TILEENTITY.ordinal());
|
|
||||||
dos.writeInt(xCoord);
|
|
||||||
dos.writeInt(yCoord);
|
|
||||||
dos.writeInt(zCoord);
|
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
|
||||||
writeToNBT(tag);
|
|
||||||
PacketManager.writeNBTTagCompound(tag, dos);
|
|
||||||
packet.data = bos.toByteArray();
|
|
||||||
packet.length = bos.size();
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
|
||||||
{
|
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(packet.data);
|
|
||||||
DataInputStream dis = new DataInputStream(bis);
|
|
||||||
int id, x, y, z;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
id = dis.readInt();
|
|
||||||
x = dis.readInt();
|
|
||||||
y = dis.readInt();
|
|
||||||
z = dis.readInt();
|
|
||||||
NBTTagCompound tag = Packet.readNBTTagCompound(dis);
|
|
||||||
readFromNBT(tag);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,30 @@ public class BlockDetector extends BlockFilterable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBlockNormalCube(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBlockSolid(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean renderAsNormalBlock()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Override public boolean renderAsNormalBlock() { return false; }
|
* @Override public boolean renderAsNormalBlock() { return false; }
|
||||||
*
|
*
|
||||||
|
@ -95,13 +119,13 @@ public class BlockDetector extends BlockFilterable
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction)
|
public boolean isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction)
|
||||||
{
|
|
||||||
if (direction == ForgeDirection.DOWN.ordinal())
|
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
if (tileEntity != null)
|
if (tileEntity != null)
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof TileEntityDetector) { return ((TileEntityDetector) tileEntity).isPoweringTo(ForgeDirection.getOrientation(direction)); }
|
if (tileEntity instanceof TileEntityDetector)
|
||||||
|
{
|
||||||
|
return ((TileEntityDetector) tileEntity).isPoweringTo(ForgeDirection.getOrientation(direction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,17 +135,17 @@ public class BlockDetector extends BlockFilterable
|
||||||
@Override
|
@Override
|
||||||
public boolean isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction)
|
public boolean isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int direction)
|
||||||
{
|
{
|
||||||
if (direction != ForgeDirection.DOWN.ordinal() && direction != ForgeDirection.UP.ordinal())
|
return isProvidingStrongPower(world, x, y, z, direction);
|
||||||
{
|
/*
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
* if (direction != ForgeDirection.DOWN.ordinal() && direction !=
|
||||||
|
* ForgeDirection.UP.ordinal()) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
if (tileEntity != null)
|
*
|
||||||
{
|
* if (tileEntity != null) { if (tileEntity instanceof TileEntityDetector) { return
|
||||||
if (tileEntity instanceof TileEntityDetector) { return ((TileEntityDetector) tileEntity).isPoweringTo(ForgeDirection.getOrientation(direction)); }
|
* ((TileEntityDetector) tileEntity).isPoweringTo(ForgeDirection.getOrientation(direction));
|
||||||
}
|
* } } }
|
||||||
}
|
*
|
||||||
|
* return false;
|
||||||
return false;
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package assemblyline.common.machine.detector;
|
package assemblyline.common.machine.detector;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
@ -15,43 +19,34 @@ import net.minecraft.network.packet.Packet250CustomPayload;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.prefab.TranslationHelper;
|
import universalelectricity.prefab.TranslationHelper;
|
||||||
import universalelectricity.prefab.implement.IRedstoneProvider;
|
|
||||||
import universalelectricity.prefab.network.IPacketReceiver;
|
|
||||||
import universalelectricity.prefab.network.PacketManager;
|
import universalelectricity.prefab.network.PacketManager;
|
||||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
|
||||||
import assemblyline.api.IFilterable;
|
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
|
import assemblyline.common.machine.TileEntityFilterable;
|
||||||
import assemblyline.common.machine.filter.ItemFilter;
|
import assemblyline.common.machine.filter.ItemFilter;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
public class TileEntityDetector extends TileEntityAdvanced implements IFilterable, IInventory, IRedstoneProvider, IPacketReceiver
|
public class TileEntityDetector extends TileEntityFilterable
|
||||||
{
|
{
|
||||||
private boolean powering = false;
|
private boolean powering = false;
|
||||||
private boolean isInverted = false;
|
private boolean inverted = false;
|
||||||
private ItemStack[] containingItems = new ItemStack[1];
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
<<<<<<< Updated upstream
|
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
=======
|
|
||||||
int metadata = this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) & 3;
|
|
||||||
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord - 1, this.zCoord, this.xCoord + 1, this.yCoord, this.zCoord + 1);
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
|
|
||||||
if (!this.worldObj.isRemote && this.ticks % 10 == 0)
|
if (!this.worldObj.isRemote && this.ticks % 10 == 0)
|
||||||
{
|
{
|
||||||
int metadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
int metadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||||
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord - 1, this.yCoord, this.xCoord + 1, this.yCoord, this.zCoord + 1);
|
AxisAlignedBB testArea = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord - 1, this.zCoord, this.xCoord + 1, this.yCoord, this.zCoord + 1);
|
||||||
|
|
||||||
ArrayList<Entity> entities = (ArrayList<Entity>) this.worldObj.getEntitiesWithinAABB(EntityItem.class, testArea);
|
ArrayList<Entity> entities = (ArrayList<Entity>) this.worldObj.getEntitiesWithinAABB(EntityItem.class, testArea);
|
||||||
boolean powerCheck = false;
|
boolean powerCheck = false;
|
||||||
|
|
||||||
if (entities.size() > 0)
|
if (entities.size() > 0)
|
||||||
{
|
{
|
||||||
if (this.containingItems[0] != null)
|
if (getFilter() != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < entities.size(); i++)
|
for (int i = 0; i < entities.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +54,7 @@ public class TileEntityDetector extends TileEntityAdvanced implements IFilterabl
|
||||||
ItemStack item = e.func_92014_d();
|
ItemStack item = e.func_92014_d();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
ArrayList<ItemStack> checkStacks = ItemFilter.getFilters(this.containingItems[0]);
|
ArrayList<ItemStack> checkStacks = ItemFilter.getFilters(getFilter());
|
||||||
|
|
||||||
for (int ii = 0; ii < checkStacks.size(); ii++)
|
for (int ii = 0; ii < checkStacks.size(); ii++)
|
||||||
{
|
{
|
||||||
|
@ -89,7 +84,7 @@ public class TileEntityDetector extends TileEntityAdvanced implements IFilterabl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isInverted)
|
if (this.inverted)
|
||||||
{
|
{
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
@ -125,6 +120,7 @@ public class TileEntityDetector extends TileEntityAdvanced implements IFilterabl
|
||||||
this.worldObj.notifyBlocksOfNeighborChange(x, this.yCoord + 1, z, AssemblyLine.blockDetector.blockID);
|
this.worldObj.notifyBlocksOfNeighborChange(x, this.yCoord + 1, z, AssemblyLine.blockDetector.blockID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PacketManager.sendPacketToClients(getDescriptionPacket());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,12 +134,12 @@ public class TileEntityDetector extends TileEntityAdvanced implements IFilterabl
|
||||||
|
|
||||||
public boolean isInverted()
|
public boolean isInverted()
|
||||||
{
|
{
|
||||||
return isInverted;
|
return inverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInversion(boolean inverted)
|
public void setInversion(boolean inverted)
|
||||||
{
|
{
|
||||||
this.isInverted = inverted;
|
this.inverted = inverted;
|
||||||
|
|
||||||
if (this.worldObj.isRemote)
|
if (this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
|
@ -153,196 +149,40 @@ public class TileEntityDetector extends TileEntityAdvanced implements IFilterabl
|
||||||
|
|
||||||
public void toggleInversion()
|
public void toggleInversion()
|
||||||
{
|
{
|
||||||
this.setInversion(!this.isInverted);
|
this.setInversion(!this.inverted);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet getDescriptionPacket()
|
|
||||||
{
|
|
||||||
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.isInverted);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
|
||||||
{
|
|
||||||
if (this.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.isInverted = dataStream.readBoolean();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tag)
|
public void readFromNBT(NBTTagCompound tag)
|
||||||
{
|
{
|
||||||
super.readFromNBT(tag);
|
super.readFromNBT(tag);
|
||||||
NBTTagList itemList = tag.getTagList("Items");
|
|
||||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
|
||||||
|
|
||||||
for (int i = 0; i < itemList.tagCount(); ++i)
|
this.inverted = tag.getBoolean("isInverted");
|
||||||
{
|
this.powering = tag.getBoolean("powering");
|
||||||
NBTTagCompound itemAt = (NBTTagCompound) itemList.tagAt(i);
|
|
||||||
int itemSlot = itemAt.getByte("Slot") & 255;
|
|
||||||
|
|
||||||
if (itemSlot >= 0 && itemSlot < this.containingItems.length)
|
|
||||||
{
|
|
||||||
this.containingItems[itemSlot] = ItemStack.loadItemStackFromNBT(itemAt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isInverted = tag.getBoolean("isInverted");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound tag)
|
public void writeToNBT(NBTTagCompound tag)
|
||||||
{
|
{
|
||||||
super.writeToNBT(tag);
|
super.writeToNBT(tag);
|
||||||
NBTTagList itemList = new NBTTagList();
|
|
||||||
|
|
||||||
for (int i = 0; i < this.containingItems.length; ++i)
|
tag.setBoolean("isInverted", this.inverted);
|
||||||
{
|
tag.setBoolean("powering", this.powering);
|
||||||
if (this.containingItems[i] != null)
|
|
||||||
{
|
|
||||||
NBTTagCompound itemAt = new NBTTagCompound();
|
|
||||||
itemAt.setByte("Slot", (byte) i);
|
|
||||||
this.containingItems[i].writeToNBT(itemAt);
|
|
||||||
itemList.appendTag(itemAt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setTag("Items", itemList);
|
|
||||||
tag.setBoolean("isInverted", this.isInverted);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSizeInventory()
|
|
||||||
{
|
|
||||||
return this.containingItems.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int slot)
|
|
||||||
{
|
|
||||||
return containingItems[slot];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack decrStackSize(int slot, int amount)
|
|
||||||
{
|
|
||||||
if (this.containingItems[slot] != null)
|
|
||||||
{
|
|
||||||
ItemStack var3;
|
|
||||||
|
|
||||||
if (this.containingItems[slot].stackSize <= amount)
|
|
||||||
{
|
|
||||||
var3 = this.containingItems[slot];
|
|
||||||
this.containingItems[slot] = null;
|
|
||||||
this.onInventoryChanged();
|
|
||||||
return var3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var3 = this.containingItems[slot].splitStack(amount);
|
|
||||||
|
|
||||||
if (this.containingItems[slot].stackSize == 0)
|
|
||||||
{
|
|
||||||
this.containingItems[slot] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onInventoryChanged();
|
|
||||||
return var3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlotOnClosing(int slot)
|
|
||||||
{
|
|
||||||
if (this.containingItems[slot] != null)
|
|
||||||
{
|
|
||||||
ItemStack var2 = this.containingItems[slot];
|
|
||||||
this.containingItems[slot] = null;
|
|
||||||
return var2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
|
||||||
{
|
|
||||||
this.containingItems[slot] = stack;
|
|
||||||
|
|
||||||
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
|
|
||||||
{
|
|
||||||
stack.stackSize = this.getInventoryStackLimit();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.onInventoryChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInvName()
|
|
||||||
{
|
|
||||||
return TranslationHelper.getLocal("tile.detector.name");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUseableByPlayer(EntityPlayer player)
|
|
||||||
{
|
|
||||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openChest()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeChest()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPoweringTo(ForgeDirection side)
|
public boolean isPoweringTo(ForgeDirection side)
|
||||||
{
|
{
|
||||||
return this.powering;
|
return this.powering;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isIndirectlyPoweringTo(ForgeDirection side)
|
public boolean isIndirectlyPoweringTo(ForgeDirection side)
|
||||||
{
|
{
|
||||||
return this.isPoweringTo(side);
|
return this.isPoweringTo(side);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFilter(ItemStack filter)
|
public String getInvName()
|
||||||
{
|
{
|
||||||
this.setInventorySlotContents(0, filter);
|
return "Detector";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getFilter()
|
|
||||||
{
|
|
||||||
return this.getStackInSlot(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,41 +71,46 @@ public class ContainerStamper extends Container implements IInventory
|
||||||
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
|
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1)
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
|
||||||
{
|
{
|
||||||
ItemStack itemStack3 = null;
|
ItemStack copyStack = null;
|
||||||
Slot itemStack = (Slot) this.inventorySlots.get(par1);
|
Slot slotObj = (Slot) this.inventorySlots.get(slot);
|
||||||
|
|
||||||
if (itemStack != null && itemStack.getHasStack())
|
if (slotObj != null && slotObj.getHasStack())
|
||||||
{
|
{
|
||||||
ItemStack itemStack2 = itemStack.getStack();
|
ItemStack slotStack = slotObj.getStack();
|
||||||
itemStack3 = itemStack2.copy();
|
copyStack = slotStack.copy();
|
||||||
|
|
||||||
if (par1 > 4)
|
if (slot == 2)
|
||||||
{
|
{
|
||||||
if (this.getSlot(0).isItemValid(itemStack2))
|
setInventorySlotContents(0, null); //prevent filter from being duplicated
|
||||||
{
|
|
||||||
if (!this.mergeItemStack(itemStack2, 0, 1, false)) { return null; }
|
|
||||||
}
|
}
|
||||||
else if (!this.mergeItemStack(itemStack2, 1, 2, false)) { return null; }
|
|
||||||
}
|
|
||||||
else if (!this.mergeItemStack(itemStack2, this.containingItems.length, 37, false)) { return null; }
|
|
||||||
|
|
||||||
if (itemStack2.stackSize == 0)
|
if (slot > 4)
|
||||||
{
|
{
|
||||||
itemStack.putStack((ItemStack) null);
|
if (this.getSlot(0).isItemValid(slotStack))
|
||||||
|
{
|
||||||
|
if (!this.mergeItemStack(slotStack, 0, 1, false)) { return null; }
|
||||||
|
}
|
||||||
|
else if (!this.mergeItemStack(slotStack, 1, 2, false)) { return null; }
|
||||||
|
}
|
||||||
|
else if (!this.mergeItemStack(slotStack, this.containingItems.length, 37, false)) { return null; }
|
||||||
|
|
||||||
|
if (slotStack.stackSize == 0)
|
||||||
|
{
|
||||||
|
slotObj.putStack((ItemStack) null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
itemStack.onSlotChanged();
|
slotObj.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemStack2.stackSize == itemStack3.stackSize) { return null; }
|
if (slotStack.stackSize == copyStack.stackSize) { return null; }
|
||||||
|
|
||||||
itemStack.onPickupFromSlot(par1EntityPlayer, itemStack2);
|
slotObj.onPickupFromSlot(player, slotStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemStack3;
|
return copyStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue