This commit is contained in:
DarkGuardsman 2013-06-30 22:13:49 -04:00
parent 7de88e4d70
commit c69ac743ee
2 changed files with 23 additions and 73 deletions

View file

@ -32,11 +32,9 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
private ItemStack filterItem; private ItemStack filterItem;
private boolean inverted; private boolean inverted;
/** /** Looks through the things in the filter and finds out which item is being filtered.
* Looks through the things in the filter and finds out which item is being filtered.
* *
* @return Is this filterable block filtering this specific ItemStack? * @return Is this filterable block filtering this specific ItemStack? */
*/
public boolean isFiltering(ItemStack itemStack) public boolean isFiltering(ItemStack itemStack)
{ {
if (this.getFilter() != null && itemStack != null) if (this.getFilter() != null && itemStack != null)
@ -65,11 +63,7 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
public void setFilter(ItemStack filter) public void setFilter(ItemStack filter)
{ {
this.filterItem = filter; this.filterItem = filter;
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket());
}
} }
@Override @Override
@ -81,10 +75,7 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
public void setInverted(boolean inverted) public void setInverted(boolean inverted)
{ {
this.inverted = inverted; this.inverted = inverted;
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
{
PacketManager.sendPacketToClients(this.getDescriptionPacket());
}
} }
public boolean isInverted() public boolean isInverted()
@ -119,13 +110,11 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
return this.getDirection(worldObj, xCoord, yCoord, zCoord); return this.getDirection(worldObj, xCoord, yCoord, zCoord);
} }
/** /** Don't override this! Override getPackData() instead! */
* Don't override this! Override getPackData() instead!
*/
@Override @Override
public Packet getDescriptionPacket() public Packet getDescriptionPacket()
{ {
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.getPacketData().toArray()); return PacketManager.getPacket(AssemblyLine.CHANNEL, this, AssemblyTilePacket.NBT, this.getPacketData().toArray());
} }
public ArrayList getPacketData() public ArrayList getPacketData()
@ -137,31 +126,6 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
return array; return array;
} }
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
if (worldObj.isRemote)
{
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();
this.worldObj.markBlockForRenderUpdate(x, y, z);
NBTTagCompound tag = Packet.readNBTTagCompound(dis);
readFromNBT(tag);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
@Override @Override
public void writeToNBT(NBTTagCompound nbt) public void writeToNBT(NBTTagCompound nbt)
{ {

View file

@ -16,6 +16,7 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRotatable; import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
@ -41,7 +42,6 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IPacke
public static final int MAX_FRAME = 13; public static final int MAX_FRAME = 13;
public static final int MAX_SLANT_FRAME = 23; public static final int MAX_SLANT_FRAME = 23;
/** Joules required to run this thing. */
public final float acceleration = 0.01f; public final float acceleration = 0.01f;
public final float maxSpeed = 0.1f; public final float maxSpeed = 0.1f;
/** Current rotation of the model wheels */ /** Current rotation of the model wheels */
@ -120,16 +120,12 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IPacke
/** Is this belt in the front of a conveyor line? Used for rendering. */ /** Is this belt in the front of a conveyor line? Used for rendering. */
public boolean getIsFirstBelt() public boolean getIsFirstBelt()
{ {
Vector3 vec = new Vector3(this);
ForgeDirection front = this.getDirection(); TileEntity fBelt = vec.clone().modifyPositionFromSide(this.getDirection()).getTileEntity(this.worldObj);
ForgeDirection back = this.getDirection().getOpposite(); TileEntity bBelt = vec.clone().modifyPositionFromSide(this.getDirection().getOpposite()).getTileEntity(this.worldObj);
TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ); if (fBelt instanceof TileEntityConveyorBelt && !(bBelt instanceof TileEntityConveyorBelt))
TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ);
if (fBelt instanceof TileEntityConveyorBelt)
{ {
ForgeDirection fD = ((TileEntityConveyorBelt) fBelt).getDirection(); return ((TileEntityConveyorBelt) fBelt).getDirection() == this.getDirection();
ForgeDirection TD = this.getDirection();
return fD == TD;
} }
return false; return false;
} }
@ -138,16 +134,12 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IPacke
public boolean getIsMiddleBelt() public boolean getIsMiddleBelt()
{ {
ForgeDirection front = this.getDirection(); Vector3 vec = new Vector3(this);
ForgeDirection back = this.getDirection().getOpposite(); TileEntity fBelt = vec.clone().modifyPositionFromSide(this.getDirection()).getTileEntity(this.worldObj);
TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ); TileEntity bBelt = vec.clone().modifyPositionFromSide(this.getDirection().getOpposite()).getTileEntity(this.worldObj);
TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ); if (fBelt instanceof TileEntityConveyorBelt && bBelt instanceof TileEntityConveyorBelt)
if (fBelt instanceof TileEntityConveyorBelt && BBelt instanceof TileEntityConveyorBelt)
{ {
ForgeDirection fD = ((TileEntityConveyorBelt) fBelt).getDirection(); return ((TileEntityConveyorBelt) fBelt).getDirection() == this.getDirection() && ((TileEntityConveyorBelt) bBelt).getDirection() == this.getDirection();
ForgeDirection BD = ((TileEntityConveyorBelt) BBelt).getDirection();
ForgeDirection TD = this.getDirection();
return fD == TD && BD == TD;
} }
return false; return false;
} }
@ -155,17 +147,12 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IPacke
/** Is this belt in the back of a conveyor line? Used for rendering. */ /** Is this belt in the back of a conveyor line? Used for rendering. */
public boolean getIsLastBelt() public boolean getIsLastBelt()
{ {
Vector3 vec = new Vector3(this);
ForgeDirection front = this.getDirection(); TileEntity fBelt = vec.clone().modifyPositionFromSide(this.getDirection()).getTileEntity(this.worldObj);
ForgeDirection back = this.getDirection().getOpposite(); TileEntity bBelt = vec.clone().modifyPositionFromSide(this.getDirection().getOpposite()).getTileEntity(this.worldObj);
TileEntity fBelt = worldObj.getBlockTileEntity(xCoord + front.offsetX, yCoord + front.offsetY, zCoord + front.offsetZ); if (bBelt instanceof TileEntityConveyorBelt && !(fBelt instanceof TileEntityConveyorBelt))
TileEntity BBelt = worldObj.getBlockTileEntity(xCoord + back.offsetX, yCoord + back.offsetY, zCoord + back.offsetZ);
if (BBelt instanceof TileEntityConveyorBelt)
{ {
ForgeDirection BD = ((TileEntityConveyorBelt) BBelt).getDirection(); return ((TileEntityConveyorBelt) bBelt).getDirection() == this.getDirection().getOpposite();
ForgeDirection TD = this.getDirection();
return BD == TD;
} }
return false; return false;
} }
@ -216,8 +203,7 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IPacke
@Override @Override
public List<Entity> getAffectedEntities() public List<Entity> getAffectedEntities()
{ {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1); return worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1));
return worldObj.getEntitiesWithinAABB(Entity.class, bounds);
} }
public int getAnimationFrame() public int getAnimationFrame()