Files
MinecraftForge/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch
T

108 lines
4.5 KiB
Diff

--- ../src-base/minecraft/net/minecraft/tileentity/TileEntity.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntity.java
@@ -12,7 +12,10 @@
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import org.apache.logging.log4j.Level;
@@ -278,4 +281,93 @@
func_145826_a(TileEntityComparator.class, "Comparator");
func_145826_a(TileEntityFlowerPot.class, "FlowerPot");
}
+
+ // -- 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(NetworkManager net, S35PacketUpdateTileEntity pkt)
+ {
+ }
+
+ /**
+ * Called when the chunk this TileEntity is on is Unloaded.
+ */
+ public void onChunkUnload()
+ {
+ }
+
+ private boolean isVanilla = getClass().getName().startsWith("net.minecraft.tileentity");
+ /**
+ * 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 Position
+ * @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(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z)
+ {
+ return !isVanilla || (oldBlock != newBlock);
+ }
+
+ 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.func_72330_a(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 = func_145838_q();
+ if (type == Blocks.field_150381_bn)
+ {
+ bb = AxisAlignedBB.func_72332_a().func_72299_a(field_145851_c, field_145848_d, field_145849_e, field_145851_c + 1, field_145848_d + 1, field_145849_e + 1);
+ }
+ else if (type == Blocks.field_150486_ae || type == Blocks.field_150447_bR)
+ {
+ bb = AxisAlignedBB.func_72332_a().func_72299_a(field_145851_c - 1, field_145848_d, field_145849_e - 1, field_145851_c + 2, field_145848_d + 2, field_145849_e + 2);
+ }
+ else if (type != null && type != Blocks.field_150461_bJ)
+ {
+ AxisAlignedBB cbb = type.func_149668_a(field_145850_b, field_145851_c, field_145848_d, field_145849_e);
+ if (cbb != null)
+ {
+ bb = cbb;
+ }
+ }
+ return bb;
+ }
}