Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package net.minecraft.server.v1_12_R1;
  7.  
  8. import java.util.logging.Level;
  9. import javax.annotation.Nullable;
  10. import net.minecraft.server.v1_12_R1.BlockJukeBox.TileEntityRecordPlayer;
  11. import org.apache.logging.log4j.LogManager;
  12. import org.apache.logging.log4j.Logger;
  13. import org.bukkit.Bukkit;
  14. import org.bukkit.block.BlockState;
  15. import org.bukkit.craftbukkit.v1_12_R1.SpigotTimings;
  16. import org.bukkit.inventory.InventoryHolder;
  17. import org.spigotmc.CustomTimingsHandler;
  18.  
  19. public abstract class TileEntity {
  20. public CustomTimingsHandler tickTimer = SpigotTimings.getTileEntityTimings(this);
  21. private static final Logger a = LogManager.getLogger();
  22. private static final RegistryMaterials<MinecraftKey, Class<? extends TileEntity>> f = new RegistryMaterials();
  23. protected World world;
  24. protected BlockPosition position;
  25. protected boolean d;
  26. private int g;
  27. protected Block e;
  28.  
  29. static {
  30. a("furnace", TileEntityFurnace.class);
  31. a("chest", TileEntityChest.class);
  32. a("ender_chest", TileEntityEnderChest.class);
  33. a("jukebox", TileEntityRecordPlayer.class);
  34. a("dispenser", TileEntityDispenser.class);
  35. a("dropper", TileEntityDropper.class);
  36. a("sign", TileEntitySign.class);
  37. a("mob_spawner", TileEntityMobSpawner.class);
  38. a("noteblock", TileEntityNote.class);
  39. a("piston", TileEntityPiston.class);
  40. a("brewing_stand", TileEntityBrewingStand.class);
  41. a("enchanting_table", TileEntityEnchantTable.class);
  42. a("end_portal", TileEntityEnderPortal.class);
  43. a("beacon", TileEntityBeacon.class);
  44. a("skull", TileEntitySkull.class);
  45. a("daylight_detector", TileEntityLightDetector.class);
  46. a("hopper", TileEntityHopper.class);
  47. a("comparator", TileEntityComparator.class);
  48. a("flower_pot", TileEntityFlowerPot.class);
  49. a("banner", TileEntityBanner.class);
  50. a("structure_block", TileEntityStructure.class);
  51. a("end_gateway", TileEntityEndGateway.class);
  52. a("command_block", TileEntityCommand.class);
  53. a("shulker_box", TileEntityShulkerBox.class);
  54. a("bed", TileEntityBed.class);
  55. }
  56.  
  57. public TileEntity() {
  58. this.position = BlockPosition.ZERO;
  59. this.g = -1;
  60. }
  61.  
  62. private static void a(String s, Class<? extends TileEntity> oclass) {
  63. f.a(new MinecraftKey(s), oclass);
  64. }
  65.  
  66. @Nullable
  67. public static MinecraftKey a(Class<? extends TileEntity> oclass) {
  68. return (MinecraftKey)f.b(oclass);
  69. }
  70.  
  71. public World getWorld() {
  72. return this.world;
  73. }
  74.  
  75. public void a(World world) {
  76. this.world = world;
  77. }
  78.  
  79. public boolean u() {
  80. return this.world != null;
  81. }
  82.  
  83. public void load(NBTTagCompound nbttagcompound) {
  84. this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
  85. }
  86.  
  87. public NBTTagCompound save(NBTTagCompound nbttagcompound) {
  88. return this.c(nbttagcompound);
  89. }
  90.  
  91. private NBTTagCompound c(NBTTagCompound nbttagcompound) {
  92. MinecraftKey minecraftkey = (MinecraftKey)f.b(this.getClass());
  93. if (minecraftkey == null) {
  94. throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!");
  95. } else {
  96. nbttagcompound.setString("id", minecraftkey.toString());
  97. nbttagcompound.setInt("x", this.position.getX());
  98. nbttagcompound.setInt("y", this.position.getY());
  99. nbttagcompound.setInt("z", this.position.getZ());
  100. return nbttagcompound;
  101. }
  102. }
  103.  
  104. @Nullable
  105. public static TileEntity create(World world, NBTTagCompound nbttagcompound) {
  106. TileEntity tileentity = null;
  107. String s = nbttagcompound.getString("id");
  108.  
  109. try {
  110. Class oclass = (Class)f.get(new MinecraftKey(s));
  111. if (oclass != null) {
  112. tileentity = (TileEntity)oclass.newInstance();
  113. }
  114. } catch (Throwable var6) {
  115. a.error("Failed to create block entity {}", s, var6);
  116. }
  117.  
  118. if (tileentity != null) {
  119. try {
  120. tileentity.b(world);
  121. tileentity.load(nbttagcompound);
  122. } catch (Throwable var5) {
  123. a.error("Failed to load data for block entity {}", s, var5);
  124. tileentity = null;
  125. }
  126. } else {
  127. a.warn("Skipping BlockEntity with id {}", s);
  128. }
  129.  
  130. return tileentity;
  131. }
  132.  
  133. protected void b(World world) {
  134. }
  135.  
  136. public int v() {
  137. if (this.g == -1) {
  138. IBlockData iblockdata = this.world.getType(this.position);
  139. this.g = iblockdata.getBlock().toLegacyData(iblockdata);
  140. }
  141.  
  142. return this.g;
  143. }
  144.  
  145. public void update() {
  146. if (this.world != null) {
  147. IBlockData iblockdata = this.world.getType(this.position);
  148. this.g = iblockdata.getBlock().toLegacyData(iblockdata);
  149. this.world.b(this.position, this);
  150. if (this.getBlock() != Blocks.AIR) {
  151. this.world.updateAdjacentComparators(this.position, this.getBlock());
  152. }
  153. }
  154.  
  155. }
  156.  
  157. public BlockPosition getPosition() {
  158. return this.position;
  159. }
  160.  
  161. public Block getBlock() {
  162. if (this.e == null && this.world != null) {
  163. this.e = this.world.getType(this.position).getBlock();
  164. }
  165.  
  166. return this.e;
  167. }
  168.  
  169. @Nullable
  170. public PacketPlayOutTileEntityData getUpdatePacket() {
  171. return null;
  172. }
  173.  
  174. public NBTTagCompound d() {
  175. return this.c(new NBTTagCompound());
  176. }
  177.  
  178. public boolean y() {
  179. return this.d;
  180. }
  181.  
  182. public void z() {
  183. this.d = true;
  184. }
  185.  
  186. public void A() {
  187. this.d = false;
  188. }
  189.  
  190. public boolean c(int i, int j) {
  191. return false;
  192. }
  193.  
  194. public void invalidateBlockCache() {
  195. this.e = null;
  196. this.g = -1;
  197. }
  198.  
  199. public void a(CrashReportSystemDetails crashreportsystemdetails) {
  200. crashreportsystemdetails.a("Name", new CrashReportCallable() {
  201. public String a() throws Exception {
  202. return TileEntity.f.b(TileEntity.this.getClass()) + " // " + TileEntity.this.getClass().getCanonicalName();
  203. }
  204.  
  205. public Object call() throws Exception {
  206. return this.a();
  207. }
  208. });
  209. if (this.world != null) {
  210. CrashReportSystemDetails.a(crashreportsystemdetails, this.position, this.getBlock(), this.v());
  211. crashreportsystemdetails.a("Actual block type", new CrashReportCallable() {
  212. public String a() throws Exception {
  213. int i = Block.getId(TileEntity.this.world.getType(TileEntity.this.position).getBlock());
  214.  
  215. try {
  216. return String.format("ID #%d (%s // %s)", i, Block.getById(i).a(), Block.getById(i).getClass().getCanonicalName());
  217. } catch (Throwable var2) {
  218. return "ID #" + i;
  219. }
  220. }
  221.  
  222. public Object call() throws Exception {
  223. return this.a();
  224. }
  225. });
  226. crashreportsystemdetails.a("Actual block data value", new CrashReportCallable() {
  227. public String a() throws Exception {
  228. IBlockData iblockdata = TileEntity.this.world.getType(TileEntity.this.position);
  229. int i = iblockdata.getBlock().toLegacyData(iblockdata);
  230. if (i < 0) {
  231. return "Unknown? (Got " + i + ")";
  232. } else {
  233. String s = String.format("%4s", Integer.toBinaryString(i)).replace(" ", "0");
  234. return String.format("%1$d / 0x%1$X / 0b%2$s", i, s);
  235. }
  236. }
  237.  
  238. public Object call() throws Exception {
  239. return this.a();
  240. }
  241. });
  242. }
  243.  
  244. }
  245.  
  246. public void setPosition(BlockPosition blockposition) {
  247. this.position = blockposition.h();
  248. }
  249.  
  250. public boolean isFilteredNBT() {
  251. return false;
  252. }
  253.  
  254. @Nullable
  255. public IChatBaseComponent i_() {
  256. return null;
  257. }
  258.  
  259. public void a(EnumBlockRotation enumblockrotation) {
  260. }
  261.  
  262. public void a(EnumBlockMirror enumblockmirror) {
  263. }
  264.  
  265. public InventoryHolder getOwner() {
  266. if (this.world == null) {
  267. return null;
  268. } else {
  269. org.bukkit.block.Block block = this.world.getWorld().getBlockAt(this.position.getX(), this.position.getY(), this.position.getZ());
  270. if (block == null) {
  271. Bukkit.getLogger().log(Level.WARNING, "No block for owner at %s %d %d %d", new Object[]{this.world.getWorld(), this.position.getX(), this.position.getY(), this.position.getZ()});
  272. return null;
  273. } else {
  274. BlockState state = block.getState();
  275. return state instanceof InventoryHolder ? (InventoryHolder)state : null;
  276. }
  277. }
  278. }
  279. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement