private TileEntity fixTileEntity(int x, int y, int z, int type, TileEntity found) { this.getServer() .getLogger() .severe( "Block at " + x + "," + y + "," + z + " is " + org.bukkit.Material.getMaterial(type).toString() + " but has " + found + ". " + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover."); if (Block.byId[type] instanceof BlockContainer) { TileEntity replacement = ((BlockContainer) Block.byId[type]).b(this); replacement.world = this; this.setTileEntity(x, y, z, replacement); return replacement; } else { this.getServer() .getLogger() .severe("Don't know how to fix for this type... Can't do anything! :("); return found; } }
// Spigot start // Helper method for scheduleTicks. If the hopper at x0, y0, z0 is pointed // at this tile entity, then make it active. private void scheduleTick(int x0, int y0, int z0) { TileEntity tileEntity = world.getTileEntity(x0, y0, z0); if (tileEntity instanceof TileEntityHopper && tileEntity.world != null) { // i is the metadeta assoiated with the direction the hopper faces. int i = BlockHopper.b(tileEntity.p()); // Facing class provides arrays for direction offset. if (tileEntity.x + Facing.b[i] == x && tileEntity.y + Facing.c[i] == y && tileEntity.z + Facing.d[i] == z) { ((TileEntityHopper) tileEntity).makeTick(); } } }
@SuppressWarnings("rawtypes") public static void sendChunkTiles(int cx, int cz, EntityPlayer player) { WorldServer worldserver = (WorldServer) player.world; List tileEntities = worldserver.getTileEntities(cx << 4, 0, cz << 4, (cx << 4) + 16, 128, (cz << 4) + 16); for (Object tileEntityObject : tileEntities) { if (tileEntityObject != null && tileEntityObject instanceof TileEntity) { TileEntity tileEntity = (TileEntity) tileEntityObject; Packet tilePacket = tileEntity.k(); if (tilePacket != null) { MapChunkThread.sendPacket(player, tilePacket); } } } }
public void g() { if (this.brewTime > 0) { --this.brewTime; if (this.brewTime == 0) { this.r(); this.update(); } else if (!this.k()) { this.brewTime = 0; this.update(); } else if (this.d != this.items[3].id) { this.brewTime = 0; this.update(); } } else if (this.k()) { this.brewTime = 400; this.d = this.items[3].id; } int i = this.i(); if (i != this.c) { this.c = i; this.world.setData(this.x, this.y, this.z, i); } super.g(); }
public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); nbttagcompound.setInt("blockId", this.a); nbttagcompound.setInt("blockData", this.b); nbttagcompound.setInt("facing", this.c); nbttagcompound.setFloat("progress", this.g); nbttagcompound.setBoolean("extending", this.d); }
public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); this.a = nbttagcompound.getInt("blockId"); this.b = nbttagcompound.getInt("blockData"); this.c = nbttagcompound.getInt("facing"); this.g = this.f = nbttagcompound.getFloat("progress"); this.d = nbttagcompound.getBoolean("extending"); }
public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); nbttagcompound.setInt("blockId", Block.getId(this.a)); nbttagcompound.setInt("blockData", this.i); nbttagcompound.setInt("facing", this.j); nbttagcompound.setFloat("progress", this.n); nbttagcompound.setBoolean("extending", this.k); }
public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); this.a = Block.getById(nbttagcompound.getInt("blockId")); this.i = nbttagcompound.getInt("blockData"); this.j = nbttagcompound.getInt("facing"); this.n = this.m = nbttagcompound.getFloat("progress"); this.k = nbttagcompound.getBoolean("extending"); }
public void a(NBTTagCompound var1) { super.a(var1); this.color = var1.getInt("Base"); this.patterns = var1.getList("Patterns", 10); this.h = null; this.i = null; this.j = null; this.g = true; }
private void b(TileEntity tileentity) { if (tileentity != null) { Packet packet = tileentity.getUpdatePacket(); if (packet != null) { this.playerConnection.sendPacket(packet); } } }
private void sendTileEntity(TileEntity tileentity) { if (tileentity != null) { Packet packet = tileentity.getUpdatePacket(); if (packet != null) { this.sendAll(packet); } } }
private class_anp.class_b_in_class_anp g() { for (int var1 = 0; var1 < 8; ++var1) { for (int var2 = 0; var2 < 8; ++var2) { Chunk var3 = this.d.getChunkAt(var1, var2); Iterator var4 = var3.r().values().iterator(); while (var4.hasNext()) { TileEntity var5 = (TileEntity) var4.next(); if (var5 instanceof TileEntityEnderPortal) { class_anp.class_b_in_class_anp var6 = this.f.a(this.d, var5.getPosition()); if (var6 != null) { return var6; } } } } } return null; }
/** Update which block ID the furnace is using depending on whether or not it is burning */ public static void a(boolean par0, World par1World, int par2, int par3, int par4) { int i = par1World.getData(par2, par3, par4); TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); c = true; if (par0) { par1World.setTypeId(par2, par3, par4, MhoDilandau.BlockIronFurnaceActive.id); } else { par1World.setTypeId(par2, par3, par4, MhoDilandau.BlockIronFurnaceIdle.id); } c = false; par1World.setData(par2, par3, par4, i); if (tileentity != null) { tileentity.m(); par1World.setTileEntity(par2, par3, par4, tileentity); } }
public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); nbttagcompound.setByte("SkullType", (byte) (this.a & 255)); nbttagcompound.setByte("Rot", (byte) (this.i & 255)); if (this.j != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); GameProfileSerializer.a(nbttagcompound1, this.j); nbttagcompound.set("Owner", nbttagcompound1); } }
public static TileEntity c(NBTTagCompound nbttagcompound) { TileEntity tileentity = null; try { Class oclass = (Class) i.get(nbttagcompound.getString("id")); if (oclass != null) { tileentity = (TileEntity) oclass.newInstance(); } } catch (Exception exception) { exception.printStackTrace(); } if (tileentity != null) { tileentity.a(nbttagcompound); } else { a.warn("Skipping BlockEntity with id " + nbttagcompound.getString("id")); } return tileentity; }
public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); // timeleft = nbttagcompound.getInteger("timeleft"); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); metalItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < metalItemStacks.length) { metalItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } }
public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); this.a = nbttagcompound.getByte("SkullType"); this.i = nbttagcompound.getByte("Rot"); if (this.a == 3) { if (nbttagcompound.hasKeyOfType("Owner", 10)) { this.j = GameProfileSerializer.a(nbttagcompound.getCompound("Owner")); } else if (nbttagcompound.hasKeyOfType("ExtraType", 8) && !UtilColor.b(nbttagcompound.getString("ExtraType"))) { this.j = new GameProfile((UUID) null, nbttagcompound.getString("ExtraType")); this.d(); } } }
public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); // nbttagcompound.setInteger("timeleft", timeleft); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < metalItemStacks.length; i++) { if (metalItemStacks[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); metalItemStacks[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbttagcompound.setTag("Items", nbttaglist); }
private void b(TileEntity tileentity) { if (tileentity != null) { // CanaryMod: SignShowHook if (tileentity instanceof TileEntitySign) { SignShowHook hook = new SignShowHook(this.getPlayer(), ((TileEntitySign) tileentity).getCanarySign()); Canary.hooks().callHook(hook); } // Packet packet = tileentity.m(); if (packet != null) { this.a.b(packet); } } }
public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getList("Items"); this.items = new ItemStack[this.getSize()]; for (int i = 0; i < nbttaglist.size(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.items.length) { this.items[b0] = ItemStack.a(nbttagcompound1); } } this.brewTime = nbttagcompound.getShort("BrewTime"); }
public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); nbttagcompound.setShort("BrewTime", (short) this.brewTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.items.length; ++i) { if (this.items[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); this.items[i].save(nbttagcompound1); nbttaglist.add(nbttagcompound1); } } nbttagcompound.set("Items", nbttaglist); }
public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.m("Items"); this.i = new ItemStack[this.j_()]; if (nbttagcompound.b("CustomName")) { this.s = nbttagcompound.i("CustomName"); } for (int i0 = 0; i0 < nbttaglist.c(); ++i0) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.b(i0); int i1 = nbttagcompound1.c("Slot") & 255; if (i1 >= 0 && i1 < this.i.length) { this.i[i1] = ItemStack.a(nbttagcompound1); } } }
public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); this.items = new ItemStack[this.getSize()]; if (nbttagcompound.hasKeyOfType("CustomName", 8)) { this.s = nbttagcompound.getString("CustomName"); } for (int i = 0; i < nbttaglist.size(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.get(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < this.items.length) { this.items[j] = ItemStack.createStack(nbttagcompound1); } } }
public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); NBTTagList nbttaglist = new NBTTagList(); for (int i0 = 0; i0 < this.i.length; ++i0) { if (this.i[i0] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.a("Slot", (byte) i0); this.i[i0].b(nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1); } } nbttagcompound.a("Items", (NBTBase) nbttaglist); if (this.c()) { nbttagcompound.a("CustomName", this.s); } }
public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.items.length; ++i) { if (this.items[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); this.items[i].save(nbttagcompound1); nbttaglist.add(nbttagcompound1); } } nbttagcompound.set("Items", nbttaglist); if (this.k_()) { nbttagcompound.setString("CustomName", this.a); } }
public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getList("Items", 10); this.a = new ItemStack[this.getSize()]; if (nbttagcompound.hasKeyOfType("CustomName", 8)) { this.i = nbttagcompound.getString("CustomName"); } this.j = nbttagcompound.getInt("TransferCooldown"); for (int i = 0; i < nbttaglist.size(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.get(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 0 && b0 < this.a.length) { this.a[b0] = ItemStack.createStack(nbttagcompound1); } } }
public void update() { super.update(); }
@Override public BlockState getBlockState() { if (blockEntityTag != null) { switch (material) { case SHIELD: blockEntityTag.setString("id", "banner"); break; case WHITE_SHULKER_BOX: case ORANGE_SHULKER_BOX: case MAGENTA_SHULKER_BOX: case LIGHT_BLUE_SHULKER_BOX: case YELLOW_SHULKER_BOX: case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: case SILVER_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: case BROWN_SHULKER_BOX: case GREEN_SHULKER_BOX: case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: blockEntityTag.setString("id", "shulker_box"); break; } } TileEntity te = (blockEntityTag == null) ? null : TileEntity.a(null, blockEntityTag); switch (material) { case SIGN: case SIGN_POST: case WALL_SIGN: if (te == null) { te = new TileEntitySign(); } return new CraftSign(material, (TileEntitySign) te); case CHEST: case TRAPPED_CHEST: if (te == null) { te = new TileEntityChest(); } return new CraftChest(material, (TileEntityChest) te); case BURNING_FURNACE: case FURNACE: if (te == null) { te = new TileEntityFurnace(); } return new CraftFurnace(material, (TileEntityFurnace) te); case DISPENSER: if (te == null) { te = new TileEntityDispenser(); } return new CraftDispenser(material, (TileEntityDispenser) te); case DROPPER: if (te == null) { te = new TileEntityDropper(); } return new CraftDropper(material, (TileEntityDropper) te); case END_GATEWAY: if (te == null) { te = new TileEntityEndGateway(); } return new CraftEndGateway(material, (TileEntityEndGateway) te); case HOPPER: if (te == null) { te = new TileEntityHopper(); } return new CraftHopper(material, (TileEntityHopper) te); case MOB_SPAWNER: if (te == null) { te = new TileEntityMobSpawner(); } return new CraftCreatureSpawner(material, (TileEntityMobSpawner) te); case NOTE_BLOCK: if (te == null) { te = new TileEntityNote(); } return new CraftNoteBlock(material, (TileEntityNote) te); case JUKEBOX: if (te == null) { te = new BlockJukeBox.TileEntityRecordPlayer(); } return new CraftJukebox(material, (BlockJukeBox.TileEntityRecordPlayer) te); case BREWING_STAND_ITEM: if (te == null) { te = new TileEntityBrewingStand(); } return new CraftBrewingStand(material, (TileEntityBrewingStand) te); case SKULL: if (te == null) { te = new TileEntitySkull(); } return new CraftSkull(material, (TileEntitySkull) te); case COMMAND: case COMMAND_REPEATING: case COMMAND_CHAIN: if (te == null) { te = new TileEntityCommand(); } return new CraftCommandBlock(material, (TileEntityCommand) te); case BEACON: if (te == null) { te = new TileEntityBeacon(); } return new CraftBeacon(material, (TileEntityBeacon) te); case SHIELD: case BANNER: case WALL_BANNER: case STANDING_BANNER: if (te == null) { te = new TileEntityBanner(); } return new CraftBanner(material, (TileEntityBanner) te); case FLOWER_POT_ITEM: if (te == null) { te = new TileEntityFlowerPot(); } return new CraftFlowerPot(material, (TileEntityFlowerPot) te); case STRUCTURE_BLOCK: if (te == null) { te = new TileEntityStructure(); } return new CraftStructureBlock(material, (TileEntityStructure) te); case WHITE_SHULKER_BOX: case ORANGE_SHULKER_BOX: case MAGENTA_SHULKER_BOX: case LIGHT_BLUE_SHULKER_BOX: case YELLOW_SHULKER_BOX: case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: case SILVER_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: case BROWN_SHULKER_BOX: case GREEN_SHULKER_BOX: case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: if (te == null) { te = new TileEntityShulkerBox(); } return new CraftShulkerBox(material, (TileEntityShulkerBox) te); case ENCHANTMENT_TABLE: if (te == null) { te = new TileEntityEnchantTable(); } return new CraftEnchantingTable(material, (TileEntityEnchantTable) te); case ENDER_CHEST: if (te == null) { te = new TileEntityEnderChest(); } return new CraftEnderChest(material, (TileEntityEnderChest) te); case DAYLIGHT_DETECTOR: case DAYLIGHT_DETECTOR_INVERTED: if (te == null) { te = new TileEntityLightDetector(); } return new CraftDaylightDetector(material, (TileEntityLightDetector) te); case REDSTONE_COMPARATOR: if (te == null) { te = new TileEntityComparator(); } return new CraftComparator(material, (TileEntityComparator) te); default: throw new IllegalStateException("Missing blockState for " + material); } }
public void b(NBTTagCompound var1) { super.b(var1); a(var1, this.color, this.patterns); }
@Override public void setBlockState(BlockState blockState) { Validate.notNull(blockState, "blockState must not be null"); TileEntity te = ((CraftBlockState) blockState).getTileEntity(); Validate.notNull(te, "Invalid tile for " + blockState); boolean valid; switch (material) { case SIGN: case SIGN_POST: case WALL_SIGN: valid = te instanceof TileEntitySign; break; case CHEST: case TRAPPED_CHEST: valid = te instanceof TileEntityChest; break; case BURNING_FURNACE: case FURNACE: valid = te instanceof TileEntityFurnace; break; case DISPENSER: valid = te instanceof TileEntityDispenser; break; case DROPPER: valid = te instanceof TileEntityDropper; break; case END_GATEWAY: valid = te instanceof TileEntityEndGateway; break; case HOPPER: valid = te instanceof TileEntityHopper; break; case MOB_SPAWNER: valid = te instanceof TileEntityMobSpawner; break; case NOTE_BLOCK: valid = te instanceof TileEntityNote; break; case JUKEBOX: valid = te instanceof BlockJukeBox.TileEntityRecordPlayer; break; case BREWING_STAND_ITEM: valid = te instanceof TileEntityBrewingStand; break; case SKULL: valid = te instanceof TileEntitySkull; break; case COMMAND: case COMMAND_REPEATING: case COMMAND_CHAIN: valid = te instanceof TileEntityCommand; break; case BEACON: valid = te instanceof TileEntityBeacon; break; case SHIELD: case BANNER: case WALL_BANNER: case STANDING_BANNER: valid = te instanceof TileEntityBanner; break; case FLOWER_POT_ITEM: valid = te instanceof TileEntityFlowerPot; break; case STRUCTURE_BLOCK: valid = te instanceof TileEntityStructure; break; case WHITE_SHULKER_BOX: case ORANGE_SHULKER_BOX: case MAGENTA_SHULKER_BOX: case LIGHT_BLUE_SHULKER_BOX: case YELLOW_SHULKER_BOX: case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: case SILVER_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: case BROWN_SHULKER_BOX: case GREEN_SHULKER_BOX: case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: valid = te instanceof TileEntityShulkerBox; break; case ENCHANTMENT_TABLE: valid = te instanceof TileEntityEnchantTable; break; case ENDER_CHEST: valid = te instanceof TileEntityEnderChest; break; case DAYLIGHT_DETECTOR: case DAYLIGHT_DETECTOR_INVERTED: valid = te instanceof TileEntityLightDetector; break; case REDSTONE_COMPARATOR: valid = te instanceof TileEntityComparator; break; default: valid = false; break; } Validate.isTrue(valid, "Invalid blockState for " + material); blockEntityTag = new NBTTagCompound(); te.save(blockEntityTag); }