Files
MinecraftForge/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch
T
2013-03-02 03:08:27 -08:00

109 lines
4.2 KiB
Diff

--- ../src_base/minecraft/net/minecraft/tileentity/TileEntity.java
+++ ../src_work/minecraft/net/minecraft/tileentity/TileEntity.java
@@ -10,8 +10,11 @@
import net.minecraft.block.Block;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class TileEntity
@@ -308,4 +311,93 @@
addMapping(TileEntityHopper.class, "Hopper");
addMapping(TileEntityComparator.class, "Comparator");
}
+
+ // -- BEGIN FORGE PATCHES --
+ /**
+ * Determines if this TileEntity requires update calls.
+ * @return True if you want updateEntity() to be called, false if not
+ */
+ public boolean canUpdate()
+ {
+ return true;
+ }
+
+ /**
+ * Called when you receive a TileEntityData packet for the location this
+ * TileEntity is currently in. On the client, the NetworkManager will always
+ * be the remote server. On the server, it will be whomever is responsible for
+ * sending the packet.
+ *
+ * @param net The NetworkManager the packet originated from
+ * @param pkt The data packet
+ */
+ public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
+ {
+ }
+
+ /**
+ * Called when the chunk this TileEntity is on is Unloaded.
+ */
+ public void onChunkUnload()
+ {
+ }
+
+ /**
+ * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes.
+ * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly.
+ *
+ * @param oldID The old ID of the block
+ * @param newID The new ID of the block (May be the same)
+ * @param oldMeta The old metadata of the block
+ * @param newMeta The new metadata of the block (May be the same)
+ * @param world Current world
+ * @param x X Postion
+ * @param y Y Position
+ * @param z Z Position
+ * @return True to remove the old tile entity, false to keep it in tact {and create a new one if the new values specify to}
+ */
+ public boolean shouldRefresh(int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass == 0;
+ }
+ /**
+ * Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}.
+ */
+ public static final AxisAlignedBB INFINITE_EXTENT_AABB = AxisAlignedBB.getBoundingBox(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+
+ /**
+ * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity}
+ * Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block
+ * at this location.
+ *
+ * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity}
+ */
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getRenderBoundingBox()
+ {
+ AxisAlignedBB bb = INFINITE_EXTENT_AABB;
+ Block type = getBlockType();
+ if (type == Block.enchantmentTable)
+ {
+ bb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
+ }
+ else if (type == Block.chest)
+ {
+ bb = AxisAlignedBB.getAABBPool().getAABB(xCoord - 1, yCoord, zCoord - 1, xCoord + 2, yCoord + 2, zCoord + 2);
+ }
+ else if (type != null && type != Block.beacon)
+ {
+ AxisAlignedBB cbb = getBlockType().getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord, zCoord);
+ if (cbb != null)
+ {
+ bb = cbb;
+ }
+ }
+ return bb;
+ }
}