diff options
author | md_5 <git@md-5.net> | 2017-05-14 12:00:00 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2017-05-14 12:00:00 +1000 |
commit | 5195487ec6c01a80e3a2fca8c4acfc6b9524fcf5 (patch) | |
tree | 0314ba59f51141bb5e0e7ff6ca7723d168ac94b9 | |
parent | 6e3cec8bc78269d72ef7ef49ce82a5eadfb9615a (diff) | |
download | craftbukkit-5195487ec6c01a80e3a2fca8c4acfc6b9524fcf5.tar craftbukkit-5195487ec6c01a80e3a2fca8c4acfc6b9524fcf5.tar.gz craftbukkit-5195487ec6c01a80e3a2fca8c4acfc6b9524fcf5.tar.lz craftbukkit-5195487ec6c01a80e3a2fca8c4acfc6b9524fcf5.tar.xz craftbukkit-5195487ec6c01a80e3a2fca8c4acfc6b9524fcf5.zip |
Update to Minecraft 1.12-pre2
210 files changed, 2277 insertions, 1971 deletions
@@ -30,3 +30,5 @@ If you submit a PR involving both Bukkit and CraftBukkit, it's appreciated if ea entity.k.get(i).f(); // PAIL pathfinders, navigateToHome ``` Also, make sure to include `// Craftbukkit` comments to indicate modified NMS sources. + +Although the minimum requirement for compilation & usage is Java 8, we prefer all contributions to be written in Java 7 style code unless there is a compelling reason otherwise. diff --git a/nms-patches/Advancement.patch b/nms-patches/Advancement.patch new file mode 100644 index 00000000..ba026b62 --- /dev/null +++ b/nms-patches/Advancement.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/Advancement.java ++++ b/net/minecraft/server/Advancement.java +@@ -24,6 +24,7 @@ + private final String[][] f; + private final Set<Advancement> g = Sets.newLinkedHashSet(); + private final IChatBaseComponent h; ++ public final org.bukkit.advancement.Advancement bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancement(this); // CraftBukkit + + public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring) { + this.d = minecraftkey; diff --git a/nms-patches/AdvancementDataPlayer.patch b/nms-patches/AdvancementDataPlayer.patch new file mode 100644 index 00000000..2a323868 --- /dev/null +++ b/nms-patches/AdvancementDataPlayer.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/server/AdvancementDataPlayer.java ++++ b/net/minecraft/server/AdvancementDataPlayer.java +@@ -29,7 +29,7 @@ + + private static final Logger a = LogManager.getLogger(); + private static final Gson b = (new GsonBuilder()).registerTypeAdapter(AdvancementProgress.class, new AdvancementProgress.a()).registerTypeAdapter(MinecraftKey.class, new MinecraftKey.a()).setPrettyPrinting().create(); +- private static final TypeToken<Map<MinecraftKey, AdvancementProgress>> c = new TypeToken() { ++ private static final TypeToken<Map<MinecraftKey, AdvancementProgress>> c = new TypeToken<Map<MinecraftKey, AdvancementProgress>>() { // CraftBukkit - decompile error + }; + private final MinecraftServer d; + private final File e; +@@ -68,7 +68,7 @@ + this.g.clear(); + this.h.clear(); + this.i.clear(); +- this.k = true; ++ // this.k = true; // CraftBukkit - don't change flag on reload + this.g(); + } + +@@ -88,7 +88,7 @@ + Iterator iterator = this.data.entrySet().iterator(); + + while (iterator.hasNext()) { +- Entry entry = (Entry) iterator.next(); ++ Entry<Advancement, AdvancementProgress> entry = (Entry) iterator.next(); // CraftBukkit - decompile error + + if (((AdvancementProgress) entry.getValue()).isDone()) { + arraylist.add(entry.getKey()); +@@ -124,13 +124,15 @@ + if (this.e.isFile()) { + try { + String s = Files.toString(this.e, StandardCharsets.UTF_8); +- Map map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType()); ++ // CraftBukkit start ++ Map<MinecraftKey, AdvancementProgress> map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType()); + + if (map == null) { + throw new JsonParseException("Found null for advancements"); + } + +- Stream stream = map.entrySet().stream().sorted(Comparator.comparing(apply<invokedynamic>())); ++ Stream stream = map.entrySet().stream().sorted(Comparator.comparing(Entry::getValue)); ++ // CraftBukkit end + Iterator iterator = ((List) stream.collect(Collectors.toList())).iterator(); + + while (iterator.hasNext()) { +@@ -138,7 +140,11 @@ + Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey()); + + if (advancement == null) { +- AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?"); ++ // CraftBukkit start ++ if (((MinecraftKey) entry.getKey()).b().equals("minecraft")) { ++ AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?"); ++ } ++ // CraftBukkit end + } else { + this.a(advancement, (AdvancementProgress) entry.getValue()); + } +@@ -190,6 +196,7 @@ + this.i.add(advancement); + flag = true; + if (!flag1 && advancementprogress.isDone()) { ++ this.player.world.getServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit + advancement.d().a(this.player); + if (advancement.c() != null && advancement.c().i() && this.player.world.getGameRules().getBoolean("announceAdvancements")) { + this.d.getPlayerList().sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[] { this.player.getScoreboardDisplayName(), advancement.j()})); diff --git a/nms-patches/Advancements.patch b/nms-patches/Advancements.patch new file mode 100644 index 00000000..c6fb5b4c --- /dev/null +++ b/nms-patches/Advancements.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/Advancements.java ++++ b/net/minecraft/server/Advancements.java +@@ -71,7 +71,7 @@ + } + } + +- Advancements.a.info("Loaded " + this.advancements.size() + " advancements"); ++ // Advancements.a.info("Loaded " + this.b.size() + " advancements"); // CraftBukkit - moved to AdvancementDataWorld#reload + } + + public void a() { diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch index 18446d80..5933b92a 100644 --- a/nms-patches/Block.patch +++ b/nms-patches/Block.patch @@ -9,7 +9,7 @@ } public static int getCombinedId(IBlockData iblockdata) { -@@ -334,7 +334,8 @@ +@@ -343,7 +343,8 @@ int j = this.getDropCount(i, world.random); for (int k = 0; k < j; ++k) { @@ -19,7 +19,7 @@ Item item = this.getDropType(iblockdata, world.random, i); if (item != Items.a) { -@@ -896,7 +897,7 @@ +@@ -923,7 +924,7 @@ if (hashset.contains(block16)) { for (int i = 0; i < 15; ++i) { @@ -28,7 +28,7 @@ Block.REGISTRY_ID.a(block16.fromLegacyData(i), j); } -@@ -905,7 +906,7 @@ +@@ -932,7 +933,7 @@ while (unmodifiableiterator.hasNext()) { IBlockData iblockdata = (IBlockData) unmodifiableiterator.next(); @@ -37,7 +37,7 @@ Block.REGISTRY_ID.a(iblockdata, k); } -@@ -914,6 +915,12 @@ +@@ -941,6 +942,12 @@ } diff --git a/nms-patches/BlockButtonAbstract.patch b/nms-patches/BlockButtonAbstract.patch index 59694bc6..bf32c8f2 100644 --- a/nms-patches/BlockButtonAbstract.patch +++ b/nms-patches/BlockButtonAbstract.patch @@ -12,7 +12,7 @@ public abstract class BlockButtonAbstract extends BlockDirectional { public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered"); -@@ -123,6 +128,19 @@ +@@ -126,6 +131,19 @@ if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) { return true; } else { @@ -32,7 +32,7 @@ world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3); world.b(blockposition, blockposition); this.a(entityhuman, world, blockposition); -@@ -164,6 +182,16 @@ +@@ -167,6 +185,16 @@ if (this.I) { this.d(iblockdata, world, blockposition); } else { @@ -49,7 +49,7 @@ world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false))); this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING)); this.b(world, blockposition); -@@ -189,7 +217,41 @@ +@@ -192,7 +220,41 @@ boolean flag = !list.isEmpty(); boolean flag1 = ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue(); @@ -91,7 +91,7 @@ world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true))); this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING)); world.b(blockposition, blockposition); -@@ -197,6 +259,16 @@ +@@ -200,6 +262,16 @@ } if (!flag && flag1) { diff --git a/nms-patches/BlockCauldron.patch b/nms-patches/BlockCauldron.patch index 2f79cc98..4fe2b4b6 100644 --- a/nms-patches/BlockCauldron.patch +++ b/nms-patches/BlockCauldron.patch @@ -39,7 +39,7 @@ - this.a(world, blockposition, iblockdata, 3); + // this.a(world, blockposition, iblockdata, 3); + // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.Q, SoundCategory.BLOCKS, 1.0F, 1.0F); } return true; @@ -59,7 +59,7 @@ - this.a(world, blockposition, iblockdata, 0); + // this.a(world, blockposition, iblockdata, 0); + // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.P, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.S, SoundCategory.BLOCKS, 1.0F, 1.0F); } @@ -92,6 +108,10 @@ @@ -76,7 +76,7 @@ @@ -106,12 +126,17 @@ } - world.a((EntityHuman) null, blockposition, SoundEffects.K, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F); - this.a(world, blockposition, iblockdata, i - 1); + // this.a(world, blockposition, iblockdata, i - 1); + // CraftBukkit end @@ -95,7 +95,7 @@ @@ -122,7 +147,8 @@ } - world.a((EntityHuman) null, blockposition, SoundEffects.J, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.M, SoundCategory.BLOCKS, 1.0F, 1.0F); - this.a(world, blockposition, iblockdata, i + 1); + // this.a(world, blockposition, iblockdata, i + 1); + // CraftBukkit end diff --git a/nms-patches/BlockCommand.patch b/nms-patches/BlockCommand.patch index 808f7944..12a88a41 100644 --- a/nms-patches/BlockCommand.patch +++ b/nms-patches/BlockCommand.patch @@ -1,38 +1,27 @@ --- a/net/minecraft/server/BlockCommand.java +++ b/net/minecraft/server/BlockCommand.java -@@ -2,6 +2,8 @@ - - import java.util.Random; +@@ -4,6 +4,8 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockCommand extends BlockTileEntity { - public static final BlockStateDirection a = BlockDirectional.FACING; -@@ -29,7 +31,16 @@ + private static final Logger c = LogManager.getLogger(); +@@ -30,6 +32,15 @@ + TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity; + boolean flag = world.isBlockIndirectlyPowered(blockposition); boolean flag1 = tileentitycommand.f(); - boolean flag2 = tileentitycommand.h(); - -- if (flag && !flag1) { -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ int old = flag1 ? 15 : 0; -+ int current = flag ? 15 : 0; -+ -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current); -+ world.getServer().getPluginManager().callEvent(eventRedstone); -+ // CraftBukkit end ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ int old = flag1 ? 15 : 0; ++ int current = flag ? 15 : 0; + -+ if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit - tileentitycommand.a(true); - if (tileentitycommand.k() != TileEntityCommand.Type.SEQUENCE && !flag2) { - boolean flag3 = !tileentitycommand.l() || this.e(world, blockposition, iblockdata); -@@ -40,7 +51,7 @@ - this.c(world, blockposition); - } - } -- } else if (!flag && flag1) { -+ } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit - tileentitycommand.a(false); - } ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current); ++ world.getServer().getPluginManager().callEvent(eventRedstone); ++ flag = eventRedstone.getNewCurrent() > 0; ++ // CraftBukkit end + tileentitycommand.a(flag); + if (!flag1 && !tileentitycommand.h() && tileentitycommand.l() != TileEntityCommand.Type.SEQUENCE) { diff --git a/nms-patches/BlockEnderPortal.patch b/nms-patches/BlockEnderPortal.patch index 9501e5e7..eef4d6ac 100644 --- a/nms-patches/BlockEnderPortal.patch +++ b/nms-patches/BlockEnderPortal.patch @@ -12,11 +12,11 @@ @@ -37,6 +39,10 @@ public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - if (!entity.isPassenger() && !entity.isVehicle() && entity.aX() && !world.isClientSide && entity.getBoundingBox().c(iblockdata.d(world, blockposition).a(blockposition))) { + if (!entity.isPassenger() && !entity.isVehicle() && entity.bd() && !world.isClientSide && entity.getBoundingBox().c(iblockdata.d(world, blockposition).a(blockposition))) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); + // CraftBukkit end - entity.c(1); + entity.b(1); } diff --git a/nms-patches/BlockFire.patch b/nms-patches/BlockFire.patch index c2fb2103..11fa2edf 100644 --- a/nms-patches/BlockFire.patch +++ b/nms-patches/BlockFire.patch @@ -25,7 +25,7 @@ @@ -108,7 +114,7 @@ int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue(); - if (!flag && world.W() && this.b(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { + if (!flag && world.Y() && this.b(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain } else { @@ -103,7 +103,7 @@ - private void a(World world, BlockPosition blockposition, int i, Random random, int j) { + private void a(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition - int k = this.c(world.getType(blockposition).getBlock()); + int k = this.e(world.getType(blockposition).getBlock()); if (random.nextInt(i) < k) { IBlockData iblockdata = world.getType(blockposition); @@ -141,9 +141,9 @@ } else { world.a(blockposition, (Block) this, this.a(world) + world.random.nextInt(10)); } -@@ -306,4 +345,12 @@ - protected BlockStateList getStateList() { - return new BlockStateList(this, new IBlockState[] { BlockFire.AGE, BlockFire.NORTH, BlockFire.EAST, BlockFire.SOUTH, BlockFire.WEST, BlockFire.UPPER}); +@@ -310,4 +349,12 @@ + public EnumBlockFaceShape a(IBlockAccess iblockaccess, IBlockData iblockdata, BlockPosition blockposition, EnumDirection enumdirection) { + return EnumBlockFaceShape.UNDEFINED; } + + // CraftBukkit start diff --git a/nms-patches/BlockFluids.patch b/nms-patches/BlockFluids.patch index ba2f7bb4..8708adc5 100644 --- a/nms-patches/BlockFluids.patch +++ b/nms-patches/BlockFluids.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockFluids.java +++ b/net/minecraft/server/BlockFluids.java -@@ -163,14 +163,20 @@ +@@ -175,14 +175,20 @@ Integer integer = (Integer) iblockdata.get(BlockFluids.LEVEL); if (integer.intValue() == 0) { diff --git a/nms-patches/BlockJukeBox.patch b/nms-patches/BlockJukeBox.patch index 477d255e..2b1a5cd6 100644 --- a/nms-patches/BlockJukeBox.patch +++ b/nms-patches/BlockJukeBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockJukeBox.java +++ b/net/minecraft/server/BlockJukeBox.java -@@ -143,6 +143,11 @@ +@@ -141,6 +141,11 @@ } public void setRecord(ItemStack itemstack) { diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch index 56b43ae9..dc294d17 100644 --- a/nms-patches/BlockPiston.patch +++ b/nms-patches/BlockPiston.patch @@ -42,12 +42,12 @@ } } -- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { -+ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition +- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { ++ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition this.a(world, blockposition, enumdirection, false); } } else { -@@ -274,6 +298,48 @@ +@@ -277,6 +301,48 @@ int j = list.size() + list1.size(); IBlockData[] aiblockdata = new IBlockData[j]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); diff --git a/nms-patches/BlockPortal.patch b/nms-patches/BlockPortal.patch index 064c6f62..4956296f 100644 --- a/nms-patches/BlockPortal.patch +++ b/nms-patches/BlockPortal.patch @@ -19,7 +19,7 @@ + Entity entity = ItemMonsterEgg.spawnCreature(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { - entity.portalCooldown = entity.aE(); + entity.portalCooldown = entity.aK(); @@ -70,14 +74,16 @@ BlockPortal.Shape blockportal_shape = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.X); @@ -44,7 +44,7 @@ @@ -108,6 +114,10 @@ public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - if (!entity.isPassenger() && !entity.isVehicle() && entity.aX()) { + if (!entity.isPassenger() && !entity.isVehicle() && entity.bd()) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); @@ -52,7 +52,7 @@ entity.e(blockposition); } -@@ -212,6 +222,7 @@ +@@ -216,6 +226,7 @@ private BlockPosition position; private int height; private int width; @@ -60,7 +60,7 @@ public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { this.a = world; -@@ -270,6 +281,10 @@ +@@ -274,6 +285,10 @@ } protected int c() { @@ -71,7 +71,7 @@ int i; label56: -@@ -290,11 +305,21 @@ +@@ -294,11 +309,21 @@ block = this.a.getType(blockposition.shift(this.d)).getBlock(); if (block != Blocks.OBSIDIAN) { break label56; @@ -93,7 +93,7 @@ } } } -@@ -304,6 +329,11 @@ +@@ -308,6 +333,11 @@ if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) { this.height = 0; break; @@ -105,7 +105,7 @@ } } -@@ -325,7 +355,27 @@ +@@ -329,7 +359,27 @@ return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -134,7 +134,7 @@ for (int i = 0; i < this.width; ++i) { BlockPosition blockposition = this.position.shift(this.c, i); -@@ -334,6 +384,7 @@ +@@ -338,6 +388,7 @@ } } diff --git a/nms-patches/BlockPumpkin.patch b/nms-patches/BlockPumpkin.patch index d0fc889a..04cdad4b 100644 --- a/nms-patches/BlockPumpkin.patch +++ b/nms-patches/BlockPumpkin.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/BlockPumpkin.java +++ b/net/minecraft/server/BlockPumpkin.java -@@ -3,6 +3,12 @@ - import com.google.common.base.Predicate; +@@ -4,6 +4,12 @@ + import java.util.Iterator; import javax.annotation.Nullable; +// CraftBukkit start @@ -13,8 +13,8 @@ public class BlockPumpkin extends BlockFacingHorizontal { private ShapeDetector snowGolemPart; -@@ -40,18 +46,25 @@ - int i; +@@ -43,18 +49,25 @@ + EntityPlayer entityplayer; int j; + BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); // CraftBukkit - Use BlockStateListPopulator @@ -38,10 +38,10 @@ + // CraftBukkit start + if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { + blockList.updateList(); + iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator(); - for (j = 0; j < 120; ++j) { - world.addParticle(EnumParticle.SNOW_SHOVEL, (double) blockposition1.getX() + world.random.nextDouble(), (double) blockposition1.getY() + world.random.nextDouble() * 2.5D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); -@@ -62,12 +75,17 @@ + while (iterator.hasNext()) { +@@ -71,12 +84,17 @@ world.update(shapedetectorblock1.getPosition(), Blocks.AIR, false); } @@ -60,7 +60,7 @@ } } -@@ -76,7 +94,9 @@ +@@ -85,7 +103,9 @@ entityirongolem.setPlayerCreated(true); entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); @@ -68,10 +68,10 @@ + // CraftBukkit start + if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { + blockList.updateList(); + iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator(); - for (j = 0; j < 120; ++j) { - world.addParticle(EnumParticle.SNOWBALL, (double) blockposition2.getX() + world.random.nextDouble(), (double) blockposition2.getY() + world.random.nextDouble() * 3.9D, (double) blockposition2.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); -@@ -90,6 +110,7 @@ + while (iterator.hasNext()) { +@@ -105,6 +125,7 @@ } } } diff --git a/nms-patches/BlockRedstoneTorch.patch b/nms-patches/BlockRedstoneTorch.patch index f74f4350..e35ce527 100644 --- a/nms-patches/BlockRedstoneTorch.patch +++ b/nms-patches/BlockRedstoneTorch.patch @@ -43,7 +43,7 @@ + // CraftBukkit end world.setTypeAndData(blockposition, Blocks.UNLIT_REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3); if (this.a(world, blockposition, true)) { - world.a((EntityHuman) null, blockposition, SoundEffects.fl, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); + world.a((EntityHuman) null, blockposition, SoundEffects.gm, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); @@ -114,6 +133,15 @@ } } diff --git a/nms-patches/BlockShulkerBox.patch b/nms-patches/BlockShulkerBox.patch index e292c35e..e0a5aaa3 100644 --- a/nms-patches/BlockShulkerBox.patch +++ b/nms-patches/BlockShulkerBox.patch @@ -1,16 +1,7 @@ --- a/net/minecraft/server/BlockShulkerBox.java +++ b/net/minecraft/server/BlockShulkerBox.java -@@ -3,7 +3,7 @@ - public class BlockShulkerBox extends BlockTileEntity { +@@ -92,7 +92,32 @@ - public static final BlockStateEnum<EnumDirection> a = BlockStateDirection.of("facing"); -- private final EnumColor b; -+ public final EnumColor b; // PAIL: public, rename - - public BlockShulkerBox(EnumColor enumcolor) { - super(Material.STONE, MaterialMapColor.b); -@@ -89,7 +89,32 @@ - tileentityshulkerbox.d(entityhuman); } - public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {} @@ -30,7 +21,7 @@ + itemstack.setTag(nbttagcompound); + if (tileentityshulkerbox.hasCustomName()) { + itemstack.g(tileentityshulkerbox.getName()); -+ tileentityshulkerbox.a(""); ++ tileentityshulkerbox.setCustomName(""); + } + + a(world, blockposition, itemstack); @@ -43,7 +34,7 @@ public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) { if (itemstack.hasName()) { -@@ -105,7 +130,7 @@ +@@ -108,7 +133,7 @@ public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { TileEntity tileentity = world.getTileEntity(blockposition); @@ -52,7 +43,7 @@ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) { -@@ -123,8 +148,8 @@ +@@ -126,8 +151,8 @@ a(world, blockposition, itemstack); } diff --git a/nms-patches/BlockSkull.patch b/nms-patches/BlockSkull.patch index 51d202cf..b2c8601e 100644 --- a/nms-patches/BlockSkull.patch +++ b/nms-patches/BlockSkull.patch @@ -95,17 +95,17 @@ } @@ -157,14 +199,16 @@ - entitywither.o(); - Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().g(50.0D)).iterator(); + entitywither.p(); + Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator(); + // CraftBukkit start + if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { + blockList.updateList(); + while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); + EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - entityhuman.b((Statistic) AchievementList.I); + CriterionTriggers.m.a(entityplayer, (Entity) entitywither); } - world.addEntity(entitywither); diff --git a/nms-patches/BlockSnow.patch b/nms-patches/BlockSnow.patch index 4d864b91..b69c90e1 100644 --- a/nms-patches/BlockSnow.patch +++ b/nms-patches/BlockSnow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockSnow.java +++ b/net/minecraft/server/BlockSnow.java -@@ -81,6 +81,11 @@ +@@ -91,6 +91,11 @@ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { diff --git a/nms-patches/BlockTripwireHook.patch b/nms-patches/BlockTripwireHook.patch index c167cfee..07fde01d 100644 --- a/nms-patches/BlockTripwireHook.patch +++ b/nms-patches/BlockTripwireHook.patch @@ -9,7 +9,7 @@ public class BlockTripwireHook extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -155,6 +157,17 @@ +@@ -159,6 +161,17 @@ this.a(world, blockposition1, flag4, flag5, flag2, flag3); } diff --git a/nms-patches/BlockVine.patch b/nms-patches/BlockVine.patch index c9c4fd8c..949f8e93 100644 --- a/nms-patches/BlockVine.patch +++ b/nms-patches/BlockVine.patch @@ -9,7 +9,7 @@ public class BlockVine extends Block { public static final BlockStateBoolean UP = BlockStateBoolean.of("up"); -@@ -174,7 +176,13 @@ +@@ -176,7 +178,13 @@ } if (((Boolean) iblockdata1.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.WEST)).booleanValue()) { @@ -24,7 +24,7 @@ } } -@@ -196,17 +204,29 @@ +@@ -198,17 +206,29 @@ BlockPosition blockposition3 = blockposition2.shift(enumdirection2); BlockPosition blockposition4 = blockposition2.shift(enumdirection3); @@ -32,34 +32,34 @@ + org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()); + - if (flag2 && this.z(world.getType(blockposition3))) { + if (flag2 && this.a(world, blockposition3.shift(enumdirection2), enumdirection2)) { - world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)))); - } else if (flag3 && this.z(world.getType(blockposition4))) { + } else if (flag3 && this.a(world, blockposition4.shift(enumdirection3), enumdirection3)) { - world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)))); - } else if (flag2 && world.isEmpty(blockposition3) && this.z(world.getType(blockposition.shift(enumdirection2)))) { + } else if (flag2 && world.isEmpty(blockposition3) && this.a(world, blockposition3, enumdirection)) { - world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + bukkitBlock = world.getWorld().getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ()); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)))); - } else if (flag3 && world.isEmpty(blockposition4) && this.z(world.getType(blockposition.shift(enumdirection3)))) { + } else if (flag3 && world.isEmpty(blockposition4) && this.a(world, blockposition4, enumdirection)) { - world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + bukkitBlock = world.getWorld().getBlockAt(blockposition4.getX(), blockposition4.getY(), blockposition4.getZ()); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)))); - } else if (this.z(world.getType(blockposition2.up()))) { + } else if (this.a(world, blockposition2.up(), EnumDirection.DOWN)) { - world.setTypeAndData(blockposition2, this.getBlockData(), 2); + // world.setTypeAndData(blockposition2, this.getBlockData(), 2); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData())); } + // CraftBukkit end - } else if (block.material.k() && iblockdata2.h()) { + } else if (iblockdata2.d(world, blockposition2, enumdirection) == EnumBlockFaceShape.SOLID) { world.setTypeAndData(blockposition, iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2); } -@@ -233,7 +253,12 @@ +@@ -235,7 +255,12 @@ } if (((Boolean) iblockdata3.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.WEST)).booleanValue()) { diff --git a/nms-patches/Chunk.patch b/nms-patches/Chunk.patch index 7d8f1da3..92d24e2d 100644 --- a/nms-patches/Chunk.patch +++ b/nms-patches/Chunk.patch @@ -201,6 +201,6 @@ + BlockSand.instaFall = false; + this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); + // CraftBukkit end - this.e(); + this.markDirty(); } diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch index 954d9073..acf9f26e 100644 --- a/nms-patches/ChunkProviderServer.patch +++ b/nms-patches/ChunkProviderServer.patch @@ -22,7 +22,7 @@ + if (this.chunkLoader instanceof ChunkRegionLoader) { + loader = (ChunkRegionLoader) this.chunkLoader; + } -+ if (loader != null && loader.a(i, j)) { ++ if (loader != null && loader.chunkExists(i, j)) { + chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j); + } + } @@ -72,7 +72,7 @@ + + } + // We can only use the queue for already generated chunks -+ if (chunk == null && loader != null && loader.a(i, j)) { ++ if (chunk == null && loader != null && loader.chunkExists(i, j)) { + if (runnable != null) { + ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable); + return null; diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch index f83005d8..b3850584 100644 --- a/nms-patches/ChunkRegionLoader.patch +++ b/nms-patches/ChunkRegionLoader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkRegionLoader.java +++ b/net/minecraft/server/ChunkRegionLoader.java -@@ -29,25 +29,41 @@ +@@ -29,19 +29,35 @@ this.e = dataconvertermanager; } @@ -39,13 +39,6 @@ } return this.a(world, i, j, nbttagcompound); - } - -- public boolean a(int i, int j) { -+ public boolean a(int i, int j) { // PAIL chunkExists (also in IChunkLoader) - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j); - NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair); - @@ -55,7 +71,7 @@ } @@ -53,10 +46,10 @@ - protected Chunk a(World world, int i, int j, NBTTagCompound nbttagcompound) { + protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[] if (!nbttagcompound.hasKeyOfType("Level", 10)) { - ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}); + ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", Integer.valueOf(i), Integer.valueOf(j)); return null; @@ -72,10 +88,28 @@ - ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)}); + ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)); nbttagcompound1.setInt("xPos", i); nbttagcompound1.setInt("zPos", j); + @@ -88,14 +81,14 @@ @@ -106,20 +140,27 @@ } - public boolean c() { + public boolean a() { - if (this.b.isEmpty()) { + // CraftBukkit start + Iterator<Map.Entry<ChunkCoordIntPair, NBTTagCompound>> iter = this.b.entrySet().iterator(); + if (!iter.hasNext()) { + // CraftBukkit end if (this.f) { - ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", new Object[] { this.d.getName()}); + ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.d.getName()); } return false; @@ -133,7 +126,7 @@ public void b(World world, Chunk chunk) throws IOException {} @@ -157,6 +202,7 @@ - if (this.c()) { + if (this.a()) { continue; } + break; // CraftBukkit - Fix infinite loop when saving chunks @@ -198,6 +191,6 @@ + public static void a(Entity entity, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + if (world.addEntity(entity, reason) && entity.isVehicle()) { + // CraftBukkit end - Iterator iterator = entity.bx().iterator(); + Iterator iterator = entity.bD().iterator(); while (iterator.hasNext()) { diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch index ca7ab2a4..ceaba882 100644 --- a/nms-patches/CommandBlockListenerAbstract.patch +++ b/nms-patches/CommandBlockListenerAbstract.patch @@ -14,26 +14,26 @@ public abstract class CommandBlockListenerAbstract implements ICommandListener { private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss"); -@@ -13,6 +20,7 @@ - private String e = ""; - private String f = "@"; - private final CommandObjectiveExecutor g = new CommandObjectiveExecutor(); +@@ -15,6 +22,7 @@ + private String g = ""; + private String h = "@"; + private final CommandObjectiveExecutor i = new CommandObjectiveExecutor(); + protected org.bukkit.command.CommandSender sender; // CraftBukkit - add sender public CommandBlockListenerAbstract() {} -@@ -92,7 +100,9 @@ - - try { - this.d = null; -- this.b = icommandhandler.a(this, this.e); -+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher -+ this.b = executeSafely(this, sender, this.e); -+ // CraftBukkit end - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); -@@ -124,6 +134,138 @@ +@@ -107,7 +115,9 @@ + if (minecraftserver != null && minecraftserver.M() && minecraftserver.getEnableCommandBlock()) { + try { + this.f = null; +- this.d = minecraftserver.getCommandHandler().b(this, this.g); ++ // CraftBukkit start - Handle command block commands using Bukkit dispatcher ++ this.d = executeSafely(this, sender, this.g); ++ // CraftBukkit end + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); + CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); +@@ -149,6 +159,138 @@ } } @@ -170,5 +170,5 @@ + // CraftBukkit end + public String getName() { - return this.f; + return this.h; } diff --git a/nms-patches/CommandDebug.patch b/nms-patches/CommandDebug.patch index e7adc470..68da6b1f 100644 --- a/nms-patches/CommandDebug.patch +++ b/nms-patches/CommandDebug.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CommandDebug.java +++ b/net/minecraft/server/CommandDebug.java -@@ -32,6 +32,14 @@ +@@ -34,6 +34,14 @@ } public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException { @@ -15,7 +15,7 @@ if (astring.length < 1) { throw new ExceptionUsage("commands.debug.usage", new Object[0]); } else { -@@ -140,6 +148,13 @@ +@@ -142,6 +150,13 @@ } public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) { diff --git a/nms-patches/CommandExecute.patch b/nms-patches/CommandExecute.patch index e36811c1..6fad56fb 100644 --- a/nms-patches/CommandExecute.patch +++ b/nms-patches/CommandExecute.patch @@ -11,7 +11,7 @@ public class CommandExecute extends CommandAbstract { -@@ -58,7 +62,10 @@ +@@ -59,7 +63,10 @@ } String s = a(astring, b0); @@ -23,15 +23,15 @@ public String getName() { return entity.getName(); } -@@ -103,25 +110,59 @@ - return entity.B_(); +@@ -104,25 +111,59 @@ + return entity.C_(); } }; + ICommandListener icommandlistener1 = new ProxyListener(); // CraftBukkit ICommandHandler icommandhandler = minecraftserver.getCommandHandler(); try { -- int i = icommandhandler.a(icommandlistener1, s); +- int i = icommandhandler.b(icommandlistener1, s); + // CraftBukkit start + org.bukkit.command.CommandSender sender = null; + ICommandListener listener = icommandlistener; diff --git a/nms-patches/CommandGamemode.patch b/nms-patches/CommandGamemode.patch index b91fed85..1c227638 100644 --- a/nms-patches/CommandGamemode.patch +++ b/nms-patches/CommandGamemode.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/CommandGamemode.java +++ b/net/minecraft/server/CommandGamemode.java @@ -28,6 +28,12 @@ - EntityPlayer entityplayer = astring.length >= 2 ? a(minecraftserver, icommandlistener, astring[1]) : a(icommandlistener); + EntityPlayer entityplayer = astring.length >= 2 ? b(minecraftserver, icommandlistener, astring[1]) : a(icommandlistener); entityplayer.a(enumgamemode); + // CraftBukkit start - handle event cancelling the change diff --git a/nms-patches/CommandTp.patch b/nms-patches/CommandTp.patch index 9704499c..73ec32da 100644 --- a/nms-patches/CommandTp.patch +++ b/nms-patches/CommandTp.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/CommandTp.java @@ -53,17 +53,11 @@ } else { - Entity entity = b(minecraftserver, icommandlistener, astring[astring.length - 1]); + Entity entity = c(minecraftserver, icommandlistener, astring[astring.length - 1]); - if (entity.world != ((Entity) object).world) { - throw new CommandException("commands.tp.notSameDimension", new Object[0]); @@ -28,7 +28,7 @@ entity.stopRiding(); - ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset); + ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - entity.h(f); + entity.setHeadRotation(f); } else { float f2 = (float) MathHelper.g(commandabstract_commandnumber3.a()); @@ -126,10 +120,17 @@ diff --git a/nms-patches/Container.patch b/nms-patches/Container.patch index 748e8a75..e779d8af 100644 --- a/nms-patches/Container.patch +++ b/nms-patches/Container.patch @@ -52,9 +52,11 @@ - slot1.set(itemstack4); + // slot1.set(itemstack4); + draggedSlots.put(slot1.rawSlotIndex, itemstack4); // CraftBukkit - Put in map instead of setting -+ } -+ } -+ + } + } + +- itemstack2.setCount(l); +- playerinventory.setCarried(itemstack2); + // CraftBukkit start - InventoryDragEvent + InventoryView view = getBukkitView(); + org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack2); @@ -83,13 +85,11 @@ + if (playerinventory.getCarried() != null) { + playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor())); + needsUpdate = true; - } ++ } + } else { + playerinventory.setCarried(oldCursor); - } - -- itemstack2.setCount(l); -- playerinventory.setCarried(itemstack2); ++ } ++ + if (needsUpdate && entityhuman instanceof EntityPlayer) { + ((EntityPlayer) entityhuman).updateInventory(this); + } @@ -110,7 +110,7 @@ } if (j == 1) { -@@ -258,6 +321,15 @@ +@@ -254,6 +317,15 @@ } slot2.f(); @@ -126,3 +126,11 @@ } } } else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) { +@@ -575,6 +647,7 @@ + inventorycraftresult.a(irecipe); + itemstack = irecipe.craftItem(inventorycrafting); + } ++ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, itemstack, getBukkitView(), false); // CraftBukkit + + inventorycraftresult.setItem(0, itemstack); + entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack)); diff --git a/nms-patches/ContainerAnvil.patch b/nms-patches/ContainerAnvil.patch index 0541e3c9..3953bb5b 100644 --- a/nms-patches/ContainerAnvil.patch +++ b/nms-patches/ContainerAnvil.patch @@ -11,12 +11,9 @@ public class ContainerAnvil extends Container { private static final Logger f = LogManager.getLogger(); -@@ -20,10 +24,15 @@ - private final BlockPosition j; - public int a; +@@ -22,8 +26,13 @@ private int k; -- private String l; -+ public String l; // PAIL: private -> public + public String renameText; private final EntityHuman m; + // CraftBukkit start + private CraftInventoryView bukkitEntity; @@ -28,43 +25,43 @@ this.j = blockposition; this.i = world; this.m = entityhuman; -@@ -117,7 +126,7 @@ +@@ -110,7 +119,7 @@ byte b1 = 0; if (itemstack.isEmpty()) { - this.g.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.a = 0; + this.levelCost = 0; } else { ItemStack itemstack1 = itemstack.cloneItemStack(); -@@ -140,7 +149,7 @@ +@@ -128,7 +137,7 @@ if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) { k = Math.min(itemstack1.i(), itemstack1.k() / 4); if (k <= 0) { - this.g.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.a = 0; + this.levelCost = 0; return; } -@@ -155,7 +164,7 @@ +@@ -143,7 +152,7 @@ this.k = l; } else { if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.f())) { - this.g.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.a = 0; + this.levelCost = 0; return; } -@@ -245,7 +254,7 @@ +@@ -236,7 +245,7 @@ } if (flag2 && !flag1) { - this.g.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.a = 0; + this.levelCost = 0; return; } -@@ -292,7 +301,7 @@ +@@ -283,7 +292,7 @@ EnchantmentManager.a(map, itemstack1); } @@ -73,7 +70,7 @@ this.b(); } } -@@ -317,6 +326,7 @@ +@@ -301,6 +310,7 @@ } public boolean a(EntityHuman entityhuman) { @@ -81,7 +78,7 @@ return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D; } -@@ -372,4 +382,29 @@ +@@ -356,4 +366,29 @@ this.e(); } @@ -94,7 +91,7 @@ + for (int i = 0; i < this.listeners.size(); ++i) { + ICrafting icrafting = (ICrafting) this.listeners.get(i); + -+ icrafting.setContainerData(this, 0, this.a); ++ icrafting.setContainerData(this, 0, this.levelCost); + } + } + diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch index e95eade4..7f21527e 100644 --- a/nms-patches/ContainerEnchantTable.patch +++ b/nms-patches/ContainerEnchantTable.patch @@ -106,14 +106,15 @@ this.b(); } } else { -@@ -176,25 +238,50 @@ +@@ -176,25 +238,52 @@ if (!this.world.isClientSide) { List list = this.a(itemstack, i, this.costs[i]); - if (!list.isEmpty()) { -- entityhuman.enchantDone(j); +- entityhuman.enchantDone(itemstack, j); + // CraftBukkit start + if (true || !list.isEmpty()) { ++ // entityhuman.enchantDone(itemstack, j); // Moved down boolean flag = itemstack.getItem() == Items.BOOK; + Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>(); + for (Object obj : list) { @@ -124,11 +125,12 @@ + + EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, this.costs[i], enchants, i); + this.world.getServer().getPluginManager().callEvent(event); - ++ + int level = event.getExpLevelCost(); + if (event.isCancelled() || (level > entityhuman.expLevel && !entityhuman.abilities.canInstantlyBuild) || event.getEnchantsToAdd().isEmpty()) { + return false; + } + if (flag) { itemstack = new ItemStack(Items.ENCHANTED_BOOK); this.enchantSlots.setItem(0, itemstack); @@ -158,14 +160,14 @@ } } -+ entityhuman.enchantDone(j); ++ entityhuman.enchantDone(itemstack, j); + // CraftBukkit end + + // CraftBukkit - TODO: let plugins change this if (!entityhuman.abilities.canInstantlyBuild) { itemstack1.subtract(j); if (itemstack1.isEmpty()) { -@@ -229,6 +316,11 @@ +@@ -233,12 +322,18 @@ public void b(EntityHuman entityhuman) { super.b(entityhuman); @@ -175,9 +177,8 @@ + } + // CraftBukkit end if (!this.world.isClientSide) { - for (int i = 0; i < this.enchantSlots.getSize(); ++i) { - ItemStack itemstack = this.enchantSlots.splitWithoutUpdate(i); -@@ -242,6 +334,7 @@ + this.a(entityhuman, entityhuman.world, this.enchantSlots); + } } public boolean a(EntityHuman entityhuman) { @@ -185,7 +186,7 @@ return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; } -@@ -294,4 +387,17 @@ +@@ -291,4 +386,17 @@ return itemstack; } diff --git a/nms-patches/ContainerPlayer.patch b/nms-patches/ContainerPlayer.patch index 3e0d58dc..feaa5bcd 100644 --- a/nms-patches/ContainerPlayer.patch +++ b/nms-patches/ContainerPlayer.patch @@ -12,7 +12,7 @@ private static final EnumItemSlot[] h = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; @@ -7,10 +12,20 @@ - public IInventory resultInventory = new InventoryCraftResult(); + public InventoryCraftResult resultInventory = new InventoryCraftResult(); public boolean g; private final EntityHuman owner; + // CraftBukkit start @@ -50,32 +50,7 @@ } public boolean isAllowed(EntityHuman entityhuman) { -@@ -54,11 +69,22 @@ - - this.a(new Slot(playerinventory, 40, 77, 62) { - }); -- this.a((IInventory) this.craftInventory); -+ // this.a((IInventory) this.craftInventory); // CraftBukkit - unneeded since it just sets result slot to empty - } - - public void a(IInventory iinventory) { -- this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.owner.world)); -+ // this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.owner.world)); -+ // CraftBukkit start (Note: the following line would cause an error if called during construction) -+ CraftingManager.getInstance().lastCraftView = getBukkitView(); -+ ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.owner.world); -+ this.resultInventory.setItem(0, craftResult); -+ if (super.listeners.size() < 1) { -+ return; -+ } -+ -+ EntityPlayer player = (EntityPlayer) super.listeners.get(0); // TODO: Is this _always_ correct? Seems like it. -+ player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult)); -+ // CraftBukkit end - } - - public void b(EntityHuman entityhuman) { -@@ -148,4 +174,17 @@ +@@ -141,4 +156,17 @@ public boolean a(ItemStack itemstack, Slot slot) { return slot.inventory != this.resultInventory && super.a(itemstack, slot); } diff --git a/nms-patches/ContainerWorkbench.patch b/nms-patches/ContainerWorkbench.patch index 38991fa5..6b1c4cb0 100644 --- a/nms-patches/ContainerWorkbench.patch +++ b/nms-patches/ContainerWorkbench.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerWorkbench.java +++ b/net/minecraft/server/ContainerWorkbench.java -@@ -1,13 +1,28 @@ +@@ -1,14 +1,29 @@ package net.minecraft.server; +// CraftBukkit start @@ -11,11 +11,12 @@ public class ContainerWorkbench extends Container { - public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3); -- public IInventory resultInventory = new InventoryCraftResult(); +- public InventoryCraftResult resultInventory = new InventoryCraftResult(); + public InventoryCrafting craftInventory; // CraftBukkit - move initialization into constructor -+ public IInventory resultInventory; // CraftBukkit - move initialization into constructor ++ public InventoryCraftResult resultInventory; // CraftBukkit - move initialization into constructor private final World g; private final BlockPosition h; + private final EntityHuman i; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; @@ -30,31 +31,8 @@ + // CraftBukkit end this.g = world; this.h = blockposition; - this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 124, 35))); -@@ -35,7 +50,21 @@ - } - - public void a(IInventory iinventory) { -- this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.g)); -+ // this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.g)); -+ // CraftBukkit start -+ CraftingManager.getInstance().lastCraftView = getBukkitView(); -+ ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.g); -+ this.resultInventory.setItem(0, craftResult); -+ if (super.listeners.size() < 1) { -+ return; -+ } -+ // See CraftBukkit PR #39 -+ if (craftResult != null && craftResult.getItem() == Items.FILLED_MAP) { -+ return; -+ } -+ EntityPlayer player = (EntityPlayer) super.listeners.get(0); // TODO: Is this _always_ correct? Seems like it. -+ player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, craftResult)); -+ // CraftBukkit end - } - - public void b(EntityHuman entityhuman) { -@@ -53,6 +82,7 @@ + this.i = playerinventory.player; +@@ -47,6 +62,7 @@ } public boolean a(EntityHuman entityhuman) { @@ -62,7 +40,7 @@ return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.d((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D; } -@@ -106,4 +136,17 @@ +@@ -100,4 +116,17 @@ public boolean a(ItemStack itemstack, Slot slot) { return slot.inventory != this.resultInventory && super.a(itemstack, slot); } diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch index 1e5049d6..d7f5e216 100644 --- a/nms-patches/CraftingManager.patch +++ b/nms-patches/CraftingManager.patch @@ -1,37 +1,6 @@ --- a/net/minecraft/server/CraftingManager.java +++ b/net/minecraft/server/CraftingManager.java -@@ -9,10 +9,16 @@ - import java.util.Iterator; - import java.util.List; - -+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit -+ - public class CraftingManager { - - private static final CraftingManager a = new CraftingManager(); - public List<IRecipe> recipes = Lists.newArrayList(); -+ // CraftBukkit start -+ public IRecipe lastRecipe; -+ public org.bukkit.inventory.InventoryView lastCraftView; -+ // CraftBukkit end - - public static CraftingManager getInstance() { - return CraftingManager.a; -@@ -179,7 +185,12 @@ - this.registerShapedRecipe(new ItemStack(Items.ARMOR_STAND, 1), new Object[] { "///", " / ", "/_/", Character.valueOf('/'), Items.STICK, Character.valueOf('_'), new ItemStack(Blocks.STONE_SLAB, 1, BlockDoubleStepAbstract.EnumStoneSlabVariant.STONE.a())}); - this.registerShapedRecipe(new ItemStack(Blocks.END_ROD, 4), new Object[] { "/", "#", Character.valueOf('/'), Items.BLAZE_ROD, Character.valueOf('#'), Items.CHORUS_FRUIT_POPPED}); - this.registerShapedRecipe(new ItemStack(Blocks.di, 1), new Object[] { "XXX", "XXX", "XXX", Character.valueOf('X'), new ItemStack(Items.DYE, 1, EnumColor.WHITE.getInvColorIndex())}); -- Collections.sort(this.recipes, new Comparator() { -+ sort(); -+ } -+ -+ // CraftBukkit start -+ public void sort() { -+ Collections.sort(this.recipes, new Comparator() { - public int a(IRecipe irecipe, IRecipe irecipe1) { - return irecipe instanceof ShapelessRecipes && irecipe1 instanceof ShapedRecipes ? 1 : (irecipe1 instanceof ShapelessRecipes && irecipe instanceof ShapedRecipes ? -1 : (irecipe1.a() < irecipe.a() ? -1 : (irecipe1.a() > irecipe.a() ? 1 : 0))); - } -@@ -290,13 +301,18 @@ +@@ -158,12 +158,14 @@ do { if (!iterator.hasNext()) { @@ -42,12 +11,31 @@ irecipe = (IRecipe) iterator.next(); } while (!irecipe.a(inventorycrafting, world)); -- return irecipe.craftItem(inventorycrafting); -+ // CraftBukkit start - INVENTORY_PRE_CRAFT event -+ inventorycrafting.currentRecipe = irecipe; -+ ItemStack result = irecipe.craftItem(inventorycrafting); -+ return CraftEventFactory.callPreCraftEvent(inventorycrafting, result, lastCraftView, false); -+ // CraftBukkit end ++ inventorycrafting.currentRecipe = irecipe; // CraftBukkit + return irecipe.craftItem(inventorycrafting); + } + +@@ -175,12 +177,14 @@ + + do { + if (!iterator.hasNext()) { ++ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found + return null; + } + + irecipe = (IRecipe) iterator.next(); + } while (!irecipe.a(inventorycrafting, world)); + ++ inventorycrafting.currentRecipe = irecipe; // CraftBukkit + return irecipe; + } + +@@ -210,7 +214,7 @@ + } + + public static int a(IRecipe irecipe) { +- return CraftingManager.recipes.a((Object) irecipe); ++ return CraftingManager.recipes.a(irecipe); // CraftBukkit - decompile error } - public NonNullList<ItemStack> b(InventoryCrafting inventorycrafting, World world) { + @Nullable diff --git a/nms-patches/CrashReport.patch b/nms-patches/CrashReport.patch index 5303ce35..de74312b 100644 --- a/nms-patches/CrashReport.patch +++ b/nms-patches/CrashReport.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CrashReport.java +++ b/net/minecraft/server/CrashReport.java -@@ -123,6 +123,7 @@ +@@ -125,6 +125,7 @@ return this.a(); } }); diff --git a/nms-patches/CustomFunctionData.patch b/nms-patches/CustomFunctionData.patch new file mode 100644 index 00000000..f7ac23a0 --- /dev/null +++ b/nms-patches/CustomFunctionData.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/server/CustomFunctionData.java ++++ b/net/minecraft/server/CustomFunctionData.java +@@ -31,7 +31,7 @@ + } + + public World getWorld() { +- return CustomFunctionData.this.c.worldServer[0]; ++ return CustomFunctionData.this.c.worlds.get(0); // CraftBukkit + } + + public MinecraftServer C_() { +@@ -55,7 +55,7 @@ + } + + public int c() { +- return this.c.worldServer[0].getGameRules().c("maxCommandChainLength"); ++ return this.c.worlds.get(0).getGameRules().c("maxCommandChainLength"); // CraftBukkit + } + + public Map<MinecraftKey, CustomFunction> d() { +@@ -63,7 +63,7 @@ + } + + public void e() { +- String s = this.c.worldServer[0].getGameRules().get("gameLoopFunction"); ++ String s = this.c.worlds.get(0).getGameRules().get("gameLoopFunction"); // CraftBukkit + + if (!s.equals(this.e)) { + this.e = s; diff --git a/nms-patches/DataInspectorBlockEntity.patch b/nms-patches/DataInspectorBlockEntity.patch index 182ddf44..0ec5d799 100644 --- a/nms-patches/DataInspectorBlockEntity.patch +++ b/nms-patches/DataInspectorBlockEntity.patch @@ -4,9 +4,9 @@ boolean flag; if (s1 == null) { -- DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", new Object[] { s}); +- DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s); + // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item) -+ // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", new Object[] { s}); ++ // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s); flag = false; } else { flag = !nbttagcompound2.hasKey("id"); diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch index e3db9392..eb648a36 100644 --- a/nms-patches/DedicatedServer.patch +++ b/nms-patches/DedicatedServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DedicatedServer.java +++ b/net/minecraft/server/DedicatedServer.java -@@ -18,11 +18,21 @@ +@@ -19,11 +19,21 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -23,7 +23,7 @@ private RemoteStatusListener n; public final RemoteControlCommandListener remoteControlCommandListener = new RemoteControlCommandListener(this); private RemoteControlListener p; -@@ -32,8 +42,10 @@ +@@ -33,8 +43,10 @@ private EnumGamemode t; private boolean u; @@ -36,22 +36,22 @@ Thread thread = new Thread("Server Infinisleeper") { { this.setDaemon(true); -@@ -52,16 +64,30 @@ +@@ -53,16 +65,30 @@ }; } - protected boolean init() throws IOException { -+ public boolean init() throws IOException { ++ public boolean init() throws IOException { // CraftBukkit - decompile error Thread thread = new Thread("Server console handler") { public void run() { -- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in)); +- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); + // CraftBukkit start + if (!org.bukkit.craftbukkit.Main.useConsole) { + return; + } ++ jline.console.ConsoleReader bufferedreader = reader; + // CraftBukkit end -+ jline.console.ConsoleReader bufferedreader = reader; // CraftBukkit String s; try { @@ -71,7 +71,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -70,6 +96,27 @@ +@@ -71,6 +97,27 @@ } }; @@ -98,8 +98,8 @@ + thread.setDaemon(true); thread.start(); - DedicatedServer.LOGGER.info("Starting minecraft server version 1.11.2"); -@@ -78,7 +125,7 @@ + DedicatedServer.LOGGER.info("Starting minecraft server version 1.12-pre2"); +@@ -79,7 +126,7 @@ } DedicatedServer.LOGGER.info("Loading properties"); @@ -108,7 +108,7 @@ this.r = new EULA(new File("eula.txt")); if (!this.r.a()) { DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); -@@ -135,6 +182,8 @@ +@@ -136,6 +183,8 @@ return false; } @@ -117,16 +117,25 @@ if (!this.getOnlineMode()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -149,7 +198,7 @@ +@@ -150,7 +199,7 @@ if (!NameReferencingFileConverter.a(this.propertyManager)) { return false; } else { - this.a((PlayerList) (new DedicatedPlayerList(this))); -+ this.convertable = new WorldLoaderServer(server.getWorldContainer(), this.getDataConverterManager()); // CraftBukkit - moved from MinecraftServer constructor ++ this.convertable = new WorldLoaderServer(server.getWorldContainer(), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor long j = System.nanoTime(); if (this.S() == null) { -@@ -207,7 +256,18 @@ +@@ -198,7 +247,7 @@ + + DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\" or \"?\"", s3); + if (this.propertyManager.a("announce-player-achievements")) { +- this.worldServer[0].getGameRules().set("announceAdvancements", this.propertyManager.getBoolean("announce-player-achievements", true) ? "true" : "false"); ++ this.worlds.get(0).getGameRules().set("announceAdvancements", this.propertyManager.getBoolean("announce-player-achievements", true) ? "true" : "false"); // CraftBukkit + this.propertyManager.b("announce-player-achievements"); + this.propertyManager.savePropertiesFile(); + } +@@ -213,7 +262,18 @@ DedicatedServer.LOGGER.info("Starting remote control listener"); this.p = new RemoteControlListener(this); this.p.a(); @@ -143,9 +152,9 @@ } + // CraftBukkit end - if (this.aQ() > 0L) { + if (this.aT() > 0L) { Thread thread1 = new Thread(new ThreadWatchdog(this)); -@@ -292,11 +352,11 @@ +@@ -298,11 +358,11 @@ return crashreport; } @@ -157,26 +166,26 @@ - protected void D() { + public void D() { // CraftBukkit - fix decompile error super.D(); - this.aM(); + this.aP(); } -@@ -327,7 +387,15 @@ +@@ -333,7 +393,15 @@ while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); -- this.getCommandHandler().a(servercommand.source, servercommand.command); +- this.getCommandHandler().b(servercommand.source, servercommand.command); + // CraftBukkit start - ServerCommand for preprocessing + ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) continue; + servercommand = new ServerCommand(event.getCommand(), servercommand.source); + -+ // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand ++ // this.getCommandHandler().b(servercommand.source, servercommand.command); // Called in dispatchServerCommand + server.dispatchServerCommand(console, servercommand); + // CraftBukkit end } } -@@ -534,16 +602,70 @@ +@@ -536,16 +604,70 @@ } public String getPlugins() { @@ -197,17 +206,17 @@ + if (i > 0) { + result.append("; "); + } - -- public String executeRemoteCommand(String s) { -- this.remoteControlCommandListener.clearMessages(); -- this.b.a(this.remoteControlCommandListener, s); -- return this.remoteControlCommandListener.getMessages(); ++ + result.append(plugins[i].getDescription().getName()); + result.append(" "); + result.append(plugins[i].getDescription().getVersion().replaceAll(";", ",")); + } + } -+ + +- public String executeRemoteCommand(String s) { +- this.remoteControlCommandListener.clearMessages(); +- this.b.b(this.remoteControlCommandListener, s); +- return this.remoteControlCommandListener.getMessages(); + return result.toString(); + // CraftBukkit end + } @@ -243,7 +252,7 @@ } public PlayerList getPlayerList() { - return this.aN(); + return this.aQ(); } + + // CraftBukkit start diff --git a/nms-patches/DispenserRegistry.patch b/nms-patches/DispenserRegistry.patch index d3f267cc..310e6d55 100644 --- a/nms-patches/DispenserRegistry.patch +++ b/nms-patches/DispenserRegistry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java -@@ -7,6 +7,15 @@ +@@ -8,6 +8,15 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -16,7 +16,7 @@ public class DispenserRegistry { public static final PrintStream a = System.out; -@@ -69,7 +78,7 @@ +@@ -70,7 +79,7 @@ BlockDispenser.REGISTRY.a(Items.SPLASH_POTION, new IDispenseBehavior() { public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) { return (new DispenseBehaviorProjectile() { @@ -25,7 +25,7 @@ return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack()); } -@@ -86,7 +95,7 @@ +@@ -87,7 +96,7 @@ BlockDispenser.REGISTRY.a(Items.LINGERING_POTION, new IDispenseBehavior() { public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) { return (new DispenseBehaviorProjectile() { @@ -34,7 +34,7 @@ return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack()); } -@@ -106,14 +115,46 @@ +@@ -107,14 +116,46 @@ double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX(); double d1 = (double) ((float) (isourceblock.getBlockPosition().getY() + enumdirection.getAdjacentY()) + 0.2F); double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ(); @@ -83,7 +83,7 @@ return itemstack; } }); -@@ -123,10 +164,39 @@ +@@ -124,10 +165,39 @@ double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX(); double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F); double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ(); @@ -125,7 +125,7 @@ return itemstack; } -@@ -147,8 +217,38 @@ +@@ -148,8 +218,38 @@ double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); @@ -166,7 +166,7 @@ return itemstack; } -@@ -169,7 +269,53 @@ +@@ -170,7 +270,53 @@ ItemBucket itembucket = (ItemBucket) itemstack.getItem(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); @@ -221,7 +221,7 @@ } }; -@@ -196,6 +342,30 @@ +@@ -197,6 +343,30 @@ item = Items.LAVA_BUCKET; } @@ -252,7 +252,7 @@ world.setAir(blockposition); itemstack.subtract(1); if (itemstack.isEmpty()) { -@@ -213,14 +383,42 @@ +@@ -214,14 +384,42 @@ protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { World world = isourceblock.getWorld(); @@ -285,12 +285,12 @@ if (world.isEmpty(blockposition)) { - world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -- if (itemstack.isDamaged(1, world.random)) { +- if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { - itemstack.setCount(0); + // CraftBukkit start - Ignition by dispensing flint and steel + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()).isCancelled()) { + world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ if (itemstack.isDamaged(1, world.random)) { ++ if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { + itemstack.setCount(0); + } } @@ -298,7 +298,7 @@ } else if (world.getType(blockposition).getBlock() == Blocks.TNT) { Blocks.TNT.postBreak(world, blockposition, Blocks.TNT.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf(true))); world.setAir(blockposition); -@@ -238,6 +436,32 @@ +@@ -239,6 +437,32 @@ World world = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); @@ -331,7 +331,7 @@ if (ItemDye.a(itemstack, world, blockposition)) { if (!world.isClientSide) { world.triggerEffect(2005, blockposition, 0); -@@ -245,6 +469,26 @@ +@@ -246,6 +470,26 @@ } else { this.b = false; } @@ -358,7 +358,7 @@ return itemstack; } else { -@@ -256,11 +500,40 @@ +@@ -257,11 +501,40 @@ protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { World world = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); @@ -395,13 +395,13 @@ + // CraftBukkit end world.addEntity(entitytntprimed); - world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gV, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.hW, SoundCategory.BLOCKS, 1.0F, 1.0F); - itemstack.subtract(1); + // itemstack.subtract(1); // CraftBukkit - handled above return itemstack; } }); -@@ -271,6 +544,30 @@ +@@ -272,6 +545,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); BlockSkull blockskull = Blocks.SKULL; @@ -432,7 +432,7 @@ this.b = true; if (world.isEmpty(blockposition) && blockskull.b(world, blockposition, itemstack)) { if (!world.isClientSide) { -@@ -319,6 +616,30 @@ +@@ -320,6 +617,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); BlockPumpkin blockpumpkin = (BlockPumpkin) Blocks.PUMPKIN; @@ -463,7 +463,7 @@ this.b = true; if (world.isEmpty(blockposition) && blockpumpkin.b(world, blockposition)) { if (!world.isClientSide) { -@@ -388,6 +709,30 @@ +@@ -403,6 +724,30 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); @@ -494,7 +494,7 @@ this.b = world.a(block, blockposition, false, EnumDirection.DOWN, (Entity) null); if (this.b) { EnumDirection enumdirection1 = world.isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP; -@@ -456,12 +801,40 @@ +@@ -471,12 +816,40 @@ d3 = 0.0D; } diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 92e5b892..b91ad4b5 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -49,17 +49,17 @@ private static final Logger a = LogManager.getLogger(); private static final List<ItemStack> b = Collections.emptyList(); private static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); -@@ -101,6 +141,9 @@ - private boolean aH; - private double[] aI; - private long aJ; +@@ -102,6 +142,9 @@ + private boolean aI; + private final double[] aJ; + private long aK; + public boolean valid; // CraftBukkit + public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only + public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949 public Entity(World world) { this.id = Entity.entityCount++; -@@ -206,6 +249,33 @@ +@@ -208,6 +251,33 @@ } protected void setYawPitch(float f, float f1) { @@ -93,8 +93,8 @@ this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; } -@@ -228,6 +298,51 @@ - this.U(); +@@ -230,6 +300,51 @@ + this.Y(); } + // CraftBukkit start @@ -107,11 +107,11 @@ + + if (true || minecraftserver.getAllowNether()) { // CraftBukkit + if (!this.isPassenger()) { -+ int i = this.V(); ++ int i = this.Z(); + + if (this.al++ >= i) { + this.al = i; -+ this.portalCooldown = this.aE(); ++ this.portalCooldown = this.aK(); + byte b0; + + if (this.world.worldProvider.getDimensionManager().getDimensionID() == -1) { @@ -120,7 +120,7 @@ + b0 = -1; + } + -+ this.c(b0); ++ this.b(b0); + } + } + @@ -136,16 +136,16 @@ + } + } + -+ this.H(); ++ this.I(); + this.world.methodProfiler.b(); + } + } + // CraftBukkit end + - public void U() { + public void Y() { this.world.methodProfiler.a("entityBaseTick"); - if (this.isPassenger() && this.bB().dead) { -@@ -244,12 +359,14 @@ + if (this.isPassenger() && this.bH().dead) { +@@ -246,6 +361,8 @@ this.lastZ = this.locZ; this.lastPitch = this.pitch; this.lastYaw = this.yaw; @@ -154,22 +154,15 @@ if (!this.world.isClientSide && this.world instanceof WorldServer) { this.world.methodProfiler.a("portal"); if (this.ak) { - MinecraftServer minecraftserver = this.world.getMinecraftServer(); - -- if (minecraftserver.getAllowNether()) { -+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit - if (!this.isPassenger()) { - int i = this.V(); - -@@ -283,6 +400,7 @@ - this.H(); +@@ -285,6 +402,7 @@ + this.I(); this.world.methodProfiler.b(); } + */ - this.am(); - this.ak(); -@@ -334,6 +452,27 @@ + this.as(); + this.aq(); +@@ -336,6 +454,27 @@ protected void burnFromLava() { if (!this.fireProof) { this.damageEntity(DamageSource.LAVA, 4.0F); @@ -197,7 +190,7 @@ this.setOnFire(15); } } -@@ -374,6 +513,22 @@ +@@ -376,6 +515,22 @@ this.a(this.getBoundingBox().d(d0, d1, d2)); this.recalcPosition(); } else { @@ -220,7 +213,7 @@ if (enummovetype == EnumMoveType.PISTON) { long i = this.world.getTime(); -@@ -515,7 +670,7 @@ +@@ -517,7 +672,7 @@ } } @@ -229,7 +222,7 @@ double d11; if (this.P > 0.0F && flag && (d7 != d0 || d9 != d2)) { -@@ -613,7 +768,7 @@ +@@ -615,7 +770,7 @@ this.world.methodProfiler.a("rest"); this.recalcPosition(); this.positionChanged = d7 != d0 || d9 != d2; @@ -238,7 +231,7 @@ this.onGround = this.B && d8 < 0.0D; this.C = this.positionChanged || this.B; l = MathHelper.floor(this.locX); -@@ -648,6 +803,28 @@ +@@ -650,6 +805,28 @@ block1.a(this.world, this); } @@ -267,7 +260,7 @@ if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) { double d22 = this.locX - d4; double d23 = this.locY - d5; -@@ -681,6 +858,8 @@ +@@ -685,6 +862,8 @@ } } @@ -276,16 +269,16 @@ try { this.checkBlockCollisions(); } catch (Throwable throwable) { -@@ -690,6 +869,8 @@ +@@ -694,6 +873,8 @@ this.appendEntityCrashDetails(crashreportsystemdetails); throw new ReportedException(crashreport); } + */ + // CraftBukkit end - boolean flag1 = this.ai(); + boolean flag1 = this.an(); -@@ -698,7 +879,14 @@ +@@ -702,7 +883,14 @@ if (!flag1) { ++this.fireTicks; if (this.fireTicks == 0) { @@ -301,7 +294,7 @@ } } } else if (this.fireTicks <= 0) { -@@ -819,7 +1007,7 @@ +@@ -834,7 +1022,7 @@ return null; } @@ -310,7 +303,7 @@ if (!this.fireProof) { this.damageEntity(DamageSource.FIRE, (float) i); } -@@ -987,6 +1175,13 @@ +@@ -1008,6 +1196,13 @@ } public void spawnIn(World world) { @@ -324,7 +317,7 @@ this.world = world; } -@@ -1219,6 +1414,18 @@ +@@ -1245,6 +1440,18 @@ try { nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ})); nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ})); @@ -343,7 +336,7 @@ nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch})); nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setShort("Fire", (short) this.fireTicks); -@@ -1228,6 +1435,12 @@ +@@ -1254,6 +1461,12 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.a("UUID", this.getUniqueID()); @@ -356,24 +349,24 @@ if (this.hasCustomName()) { nbttagcompound.setString("CustomName", this.getCustomName()); } -@@ -1303,6 +1516,8 @@ - this.motX = nbttaglist1.e(0); - this.motY = nbttaglist1.e(1); - this.motZ = nbttaglist1.e(2); +@@ -1329,6 +1542,8 @@ + this.motX = nbttaglist1.f(0); + this.motY = nbttaglist1.f(1); + this.motZ = nbttaglist1.f(2); + + /* CraftBukkit start - Moved section down if (Math.abs(this.motX) > 10.0D) { this.motX = 0.0D; } -@@ -1314,6 +1529,7 @@ +@@ -1340,6 +1555,7 @@ if (Math.abs(this.motZ) > 10.0D) { this.motZ = 0.0D; } + // CraftBukkit end */ - this.locX = nbttaglist.e(0); - this.locY = nbttaglist.e(1); -@@ -1371,6 +1587,58 @@ + this.locX = nbttaglist.f(0); + this.locY = nbttaglist.f(1); +@@ -1397,6 +1613,58 @@ this.setPosition(this.locX, this.locY, this.locZ); } @@ -432,7 +425,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1438,6 +1706,12 @@ +@@ -1464,6 +1732,12 @@ if (itemstack.isEmpty()) { return null; } else { @@ -445,8 +438,8 @@ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); entityitem.q(); -@@ -1563,6 +1837,24 @@ - if (entity.bB() != this) { +@@ -1589,6 +1863,24 @@ + if (entity.bH() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); } else { + // CraftBukkit start @@ -467,11 +460,11 @@ + } + } + // CraftBukkit end - if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bw() instanceof EntityHuman)) { + if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bC() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1576,6 +1868,22 @@ - if (entity.bB() == this) { +@@ -1602,6 +1894,22 @@ + if (entity.bH() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { + // CraftBukkit start @@ -493,18 +486,18 @@ this.passengers.remove(entity); entity.j = 60; } -@@ -1715,14 +2023,49 @@ +@@ -1741,14 +2049,49 @@ } public void setAirTicks(int i) { -- this.datawatcher.set(Entity.az, Integer.valueOf(i)); +- this.datawatcher.set(Entity.aA, Integer.valueOf(i)); + // CraftBukkit start + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); + event.getEntity().getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } -+ this.datawatcher.set(Entity.az, Integer.valueOf(event.getAmount())); ++ this.datawatcher.set(Entity.aA, Integer.valueOf(event.getAmount())); + // CraftBukkit end } @@ -546,10 +539,10 @@ } } -@@ -1867,19 +2210,70 @@ +@@ -1893,19 +2236,70 @@ if (!this.world.isClientSide && !this.dead) { this.world.methodProfiler.a("changeDimension"); - MinecraftServer minecraftserver = this.B_(); + MinecraftServer minecraftserver = this.C_(); - int j = this.dimension; - WorldServer worldserver = minecraftserver.getWorldServer(j); - WorldServer worldserver1 = minecraftserver.getWorldServer(i); @@ -620,7 +613,7 @@ BlockPosition blockposition; if (i == 1) { -@@ -1908,12 +2302,18 @@ +@@ -1934,12 +2328,18 @@ blockposition = new BlockPosition(this); } @@ -640,7 +633,7 @@ if (j == 1 && i == 1) { BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn()); -@@ -1921,6 +2321,7 @@ +@@ -1947,6 +2347,7 @@ } else { entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); } @@ -648,7 +641,7 @@ boolean flag = entity.attachedToPlayer; -@@ -1928,13 +2329,21 @@ +@@ -1954,13 +2355,21 @@ worldserver1.addEntity(entity); entity.attachedToPlayer = flag; worldserver1.entityJoinedWorld(entity, false); @@ -671,7 +664,7 @@ return entity; } else { return null; -@@ -2038,6 +2447,11 @@ +@@ -2064,6 +2473,11 @@ } public void setCustomName(String s) { @@ -680,10 +673,10 @@ + s = s.substring(0, 256); + } + // CraftBukkit end - this.datawatcher.set(Entity.aA, s); + this.datawatcher.set(Entity.aB, s); } -@@ -2095,7 +2509,26 @@ +@@ -2121,7 +2535,26 @@ } public void a(AxisAlignedBB axisalignedbb) { @@ -711,8 +704,8 @@ } public float getHeadHeight() { -@@ -2269,7 +2702,7 @@ - for (Iterator iterator = this.bx().iterator(); iterator.hasNext(); entity.a(oclass, set)) { +@@ -2295,7 +2728,7 @@ + for (Iterator iterator = this.bD().iterator(); iterator.hasNext(); entity.a(oclass, set)) { entity = (Entity) iterator.next(); if (oclass.isAssignableFrom(entity.getClass())) { - set.add(entity); diff --git a/nms-patches/EntityAgeable.patch b/nms-patches/EntityAgeable.patch index 5982edfc..5800328e 100644 --- a/nms-patches/EntityAgeable.patch +++ b/nms-patches/EntityAgeable.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/server/EntityAgeable.java @@ -10,6 +10,7 @@ protected int c; - private float bx = -1.0F; - private float by; + private float by = -1.0F; + private float bz; + public boolean ageLocked; // CraftBukkit public EntityAgeable(World world) { diff --git a/nms-patches/EntityAnimal.patch b/nms-patches/EntityAnimal.patch index 4661fecc..80469e67 100644 --- a/nms-patches/EntityAnimal.patch +++ b/nms-patches/EntityAnimal.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/EntityAnimal.java +++ b/net/minecraft/server/EntityAnimal.java -@@ -5,6 +5,7 @@ - protected Block bz; - private int bw; - private EntityHuman bx; +@@ -8,6 +8,7 @@ + protected Block bA; + private int bx; + private UUID by; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable public EntityAnimal(World world) { super(world); -@@ -38,6 +39,9 @@ +@@ -41,6 +42,9 @@ } @@ -18,19 +18,19 @@ public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable(damagesource)) { return false; -@@ -46,6 +50,7 @@ +@@ -49,6 +53,7 @@ return super.damageEntity(damagesource, f); } } + // CraftBukkit end */ public float a(BlockPosition blockposition) { - return this.world.getType(blockposition.down()).getBlock() == this.bz ? 10.0F : this.world.n(blockposition) - 0.5F; -@@ -120,6 +125,7 @@ - public void c(EntityHuman entityhuman) { - this.bw = 600; - this.bx = entityhuman; + return this.world.getType(blockposition.down()).getBlock() == this.bA ? 10.0F : this.world.n(blockposition) - 0.5F; +@@ -130,6 +135,7 @@ + if (entityhuman != null) { + this.by = entityhuman.getUniqueID(); + } + this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit + this.world.broadcastEntityEffect(this, (byte) 18); } - diff --git a/nms-patches/EntityArmorStand.patch b/nms-patches/EntityArmorStand.patch index c2691b1b..f0135822 100644 --- a/nms-patches/EntityArmorStand.patch +++ b/nms-patches/EntityArmorStand.patch @@ -15,10 +15,10 @@ + public class EntityArmorStand extends EntityLiving { - private static final Vector3f bq = new Vector3f(0.0F, 0.0F, 0.0F); + private static final Vector3f br = new Vector3f(0.0F, 0.0F, 0.0F); @@ -364,6 +373,21 @@ - if (itemstack1.isEmpty() || (this.bA & 1 << enumitemslot.c() + 8) == 0) { - if (!itemstack1.isEmpty() || (this.bA & 1 << enumitemslot.c() + 16) == 0) { + if (itemstack1.isEmpty() || (this.bB & 1 << enumitemslot.c() + 8) == 0) { + if (!itemstack1.isEmpty() || (this.bB & 1 << enumitemslot.c() + 16) == 0) { ItemStack itemstack2; + // CraftBukkit start + org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1); @@ -50,22 +50,22 @@ if (!this.world.isClientSide && !this.dead) { if (DamageSource.OUT_OF_WORLD.equals(damagesource)) { - this.die(); -+ this.Q(); // CraftBukkit - this.die() -> this.Q() ++ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; - } else if (!this.isInvulnerable(damagesource) && !this.bz && !this.isMarker()) { + } else if (!this.isInvulnerable(damagesource) && !this.bA && !this.isMarker()) { if (damagesource.isExplosion()) { - this.G(); + this.F(); - this.die(); -+ this.Q(); // CraftBukkit - this.die() -> this.Q() ++ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; } else if (DamageSource.FIRE.equals(damagesource)) { if (this.isBurning()) { @@ -421,7 +450,7 @@ } else if (damagesource.u()) { - this.I(); + this.H(); this.D(); - this.die(); -+ this.Q(); // CraftBukkit - this.die() -> this.Q() ++ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; } else { long i = this.world.getTime(); @@ -74,59 +74,43 @@ this.E(); this.D(); - this.die(); -+ this.Q(); // CraftBukkit - this.die() -> this.Q() ++ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() } return false; -@@ -460,19 +489,19 @@ +@@ -460,7 +489,7 @@ f1 -= f; if (f1 <= 0.5F) { - this.G(); + this.F(); - this.die(); -+ this.Q(); // CraftBukkit - this.die() -> this.Q() ++ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() } else { this.setHealth(f1); } - +@@ -468,7 +497,7 @@ } -- private void E() { + private void E() { - Block.a(this.world, new BlockPosition(this), new ItemStack(Items.ARMOR_STAND)); -+ private void E() { // PAIL: Rename dropLoot + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops - this.G(); + this.F(); } -- private void G() { -+ private void G() { // PAIL: Rename dropEquippedItems - this.I(); - - int i; @@ -481,7 +510,7 @@ - for (i = 0; i < this.bx.size(); ++i) { - itemstack = (ItemStack) this.bx.get(i); + for (i = 0; i < this.by.size(); ++i) { + itemstack = (ItemStack) this.by.get(i); if (!itemstack.isEmpty()) { - Block.a(this.world, (new BlockPosition(this)).up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.bx.set(i, ItemStack.a); + this.by.set(i, ItemStack.a); } } @@ -489,7 +518,7 @@ - for (i = 0; i < this.by.size(); ++i) { - itemstack = (ItemStack) this.by.get(i); + for (i = 0; i < this.bz.size(); ++i) { + itemstack = (ItemStack) this.bz.get(i); if (!itemstack.isEmpty()) { - Block.a(this.world, (new BlockPosition(this)).up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.by.set(i, ItemStack.a); + this.bz.set(i, ItemStack.a); } } -@@ -600,7 +629,8 @@ - return this.isSmall(); - } - -- public void Q() { -+ public void Q() { // PAIL: Rename killEntity (super) -+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event - this.die(); - } - diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch index 22012571..e322502a 100644 --- a/nms-patches/EntityBoat.patch +++ b/nms-patches/EntityBoat.patch @@ -48,13 +48,13 @@ + // f = event.getDamage(); // TODO Why don't we do this? + // CraftBukkit end + - this.d(-this.q()); - this.b(10); - this.setDamage(this.n() + f * 10.0F); + this.d(-this.r()); + this.c(10); + this.setDamage(this.p() + f * 10.0F); @@ -102,6 +132,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; - if (flag || this.n() > 40.0F) { + if (flag || this.p() > 40.0F) { + // CraftBukkit start + VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); + this.world.getServer().getPluginManager().callEvent(destroyEvent); @@ -98,12 +98,12 @@ } + private Location lastLocation; // CraftBukkit - public void A_() { + public void B_() { this.aH = this.aG; - this.aG = this.t(); + this.aG = this.u(); @@ -178,7 +234,6 @@ - if (this.n() > 0.0F) { - this.setDamage(this.n() - 1.0F); + if (this.p() > 0.0F) { + this.setDamage(this.p() - 1.0F); } - this.lastX = this.locX; @@ -131,8 +131,8 @@ + for (int i = 0; i <= 1; ++i) { if (this.a(i)) { - this.f[i] = (float) ((double) this.f[i] + 0.01D); -@@ -593,6 +664,11 @@ + if (!this.isSilent() && (double) (this.f[i] % 6.2831855F) <= 0.7853981852531433D && ((double) this.f[i] + 0.39269909262657166D) % 6.2831854820251465D >= 0.7853981852531433D) { +@@ -622,6 +693,11 @@ this.e(this.fallDistance, 1.0F); if (!this.world.isClientSide && !this.dead) { @@ -144,7 +144,7 @@ this.die(); if (this.world.getGameRules().getBoolean("doEntityDrops")) { int i; -@@ -606,6 +682,7 @@ +@@ -635,6 +711,7 @@ } } } diff --git a/nms-patches/EntityChicken.patch b/nms-patches/EntityChicken.patch index c498decf..d98f010b 100644 --- a/nms-patches/EntityChicken.patch +++ b/nms-patches/EntityChicken.patch @@ -10,15 +10,15 @@ + } + // CraftBukkit end super.n(); - this.bA = this.bw; - this.by = this.bx; + this.bB = this.bx; + this.bz = this.by; @@ -61,7 +66,9 @@ - this.bw += this.bB * 2.0F; - if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bC <= 0) { - this.a(SoundEffects.ac, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.bx += this.bC * 2.0F; + if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bD <= 0) { + this.a(SoundEffects.af, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit this.a(Items.EGG, 1); + this.forceDrops = false; // CraftBukkit - this.bC = this.random.nextInt(6000) + 6000; + this.bD = this.random.nextInt(6000) + 6000; } diff --git a/nms-patches/EntityCow.patch b/nms-patches/EntityCow.patch index c231dfd8..a69a0750 100644 --- a/nms-patches/EntityCow.patch +++ b/nms-patches/EntityCow.patch @@ -24,7 +24,7 @@ + } + + ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack()); - entityhuman.a(SoundEffects.ar, 1.0F, 1.0F); + entityhuman.a(SoundEffects.au, 1.0F, 1.0F); itemstack.subtract(1); if (itemstack.isEmpty()) { - entityhuman.a(enumhand, new ItemStack(Items.MILK_BUCKET)); diff --git a/nms-patches/EntityCreature.patch b/nms-patches/EntityCreature.patch index 4d141b8f..5e75f0a9 100644 --- a/nms-patches/EntityCreature.patch +++ b/nms-patches/EntityCreature.patch @@ -10,7 +10,7 @@ + public abstract class EntityCreature extends EntityInsentient { - public static final UUID bu = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); + public static final UUID bv = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); @@ -68,6 +72,7 @@ if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { @@ -21,7 +21,7 @@ @@ -76,6 +81,7 @@ - this.q(f); + this.s(f); if (f > 10.0F) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit this.unleash(true, true); diff --git a/nms-patches/EntityCreeper.patch b/nms-patches/EntityCreeper.patch index 853db77e..11864322 100644 --- a/nms-patches/EntityCreeper.patch +++ b/nms-patches/EntityCreeper.patch @@ -56,7 +56,7 @@ - this.aU = true; - this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag); - this.die(); -- this.do_(); +- this.dq(); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); + this.world.getServer().getPluginManager().callEvent(event); @@ -64,7 +64,7 @@ + this.aU = true; + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag); + this.die(); -+ this.do_(); ++ this.dq(); + } else { + fuseTicks = 0; + } diff --git a/nms-patches/EntityEnderDragon.patch b/nms-patches/EntityEnderDragon.patch index cf7365ef..6bfae174 100644 --- a/nms-patches/EntityEnderDragon.patch +++ b/nms-patches/EntityEnderDragon.patch @@ -12,11 +12,11 @@ +// PAIL: Fixme public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster { - private static final Logger bI = LogManager.getLogger(); + private static final Logger bJ = LogManager.getLogger(); @@ -33,6 +38,7 @@ - private final PathPoint[] bN = new PathPoint[24]; - private final int[] bO = new int[24]; - private final Path bP = new Path(); + private final PathPoint[] bO = new PathPoint[24]; + private final int[] bP = new int[24]; + private final Path bQ = new Path(); + private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, true); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() public EntityEnderDragon(World world) { diff --git a/nms-patches/EntityEnderPearl.patch b/nms-patches/EntityEnderPearl.patch index d175b03e..e209aab0 100644 --- a/nms-patches/EntityEnderPearl.patch +++ b/nms-patches/EntityEnderPearl.patch @@ -13,7 +13,7 @@ public class EntityEnderPearl extends EntityProjectile { private EntityLiving d; -@@ -55,21 +62,35 @@ +@@ -59,21 +66,35 @@ EntityPlayer entityplayer = (EntityPlayer) entityliving; if (entityplayer.playerConnection.a().isConnected() && entityplayer.world == this.world && !entityplayer.isSleeping()) { diff --git a/nms-patches/EntityEvoker.patch b/nms-patches/EntityEvoker.patch deleted file mode 100644 index 6d8b367a..00000000 --- a/nms-patches/EntityEvoker.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/server/EntityEvoker.java -+++ b/net/minecraft/server/EntityEvoker.java -@@ -76,6 +76,12 @@ - this.datawatcher.set(EntityEvoker.a, Byte.valueOf((byte) i)); - } - -+ // CraftBukkit start -+ public int getSpell() { -+ return this.datawatcher.get(EntityEvoker.a).intValue(); -+ } -+ // CraftBukkit end -+ - private int di() { - return this.b; - } diff --git a/nms-patches/EntityExperienceOrb.patch b/nms-patches/EntityExperienceOrb.patch index fa196829..24aa1aba 100644 --- a/nms-patches/EntityExperienceOrb.patch +++ b/nms-patches/EntityExperienceOrb.patch @@ -14,8 +14,8 @@ public int a; @@ -34,6 +40,7 @@ - public void A_() { - super.A_(); + public void B_() { + super.B_(); + EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target if (this.c > 0) { --this.c; diff --git a/nms-patches/EntityFallingBlock.patch b/nms-patches/EntityFallingBlock.patch index c43f5e4f..9780f6c0 100644 --- a/nms-patches/EntityFallingBlock.patch +++ b/nms-patches/EntityFallingBlock.patch @@ -9,7 +9,7 @@ public class EntityFallingBlock extends Entity { private IBlockData block; -@@ -65,7 +67,7 @@ +@@ -69,7 +71,7 @@ if (this.ticksLived++ == 0) { blockposition = new BlockPosition(this); @@ -18,31 +18,31 @@ this.world.setAir(blockposition); } else if (!this.world.isClientSide) { this.die(); -@@ -88,7 +90,7 @@ +@@ -110,7 +112,7 @@ - if (BlockFalling.i(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) { + if (!flag1 && BlockFalling.i(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) { this.onGround = false; - return; + // return; // CraftBukkit } this.motX *= 0.699999988079071D; -@@ -97,7 +99,13 @@ +@@ -119,7 +121,13 @@ if (iblockdata.getBlock() != Blocks.PISTON_EXTENSION) { this.die(); if (!this.f) { -- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) { +- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && (flag1 || !BlockFalling.i(this.world.getType(blockposition.down()))) && this.world.setTypeAndData(blockposition, this.block, 3)) { + // CraftBukkit start -+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && !BlockFalling.i(this.world.getType(blockposition.down()))) { ++ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && (flag1 || !BlockFalling.i(this.world.getType(blockposition.down())))) { + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) { + return; + } + this.world.setTypeAndData(blockposition, this.block, 3); + // CraftBukkit end if (block instanceof BlockFalling) { - ((BlockFalling) block).a_(this.world, blockposition); + ((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata); } -@@ -156,7 +164,9 @@ +@@ -175,7 +183,9 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/EntityFireball.patch b/nms-patches/EntityFireball.patch index 28389160..620ec367 100644 --- a/nms-patches/EntityFireball.patch +++ b/nms-patches/EntityFireball.patch @@ -52,14 +52,14 @@ this.locX += this.motX; @@ -150,6 +167,11 @@ } else { - this.ap(); + this.av(); if (damagesource.getEntity() != null) { + // CraftBukkit start + if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { + return false; + } + // CraftBukkit end - Vec3D vec3d = damagesource.getEntity().aB(); + Vec3D vec3d = damagesource.getEntity().aH(); if (vec3d != null) { @@ -163,6 +185,7 @@ diff --git a/nms-patches/EntityFishingHook.patch b/nms-patches/EntityFishingHook.patch index 65113404..bcad37d4 100644 --- a/nms-patches/EntityFishingHook.patch +++ b/nms-patches/EntityFishingHook.patch @@ -43,7 +43,7 @@ + } + // CraftBukkit end this.motY = (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F)); - this.a(SoundEffects.H, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + this.a(SoundEffects.K, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getBoundingBox().b + 0.5D; @@ -384,6 +401,14 @@ int i = 0; diff --git a/nms-patches/EntityGhast.patch b/nms-patches/EntityGhast.patch index da45161b..e4a07c97 100644 --- a/nms-patches/EntityGhast.patch +++ b/nms-patches/EntityGhast.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityGhast.java +++ b/net/minecraft/server/EntityGhast.java -@@ -159,7 +159,8 @@ +@@ -158,7 +158,8 @@ world.a((EntityHuman) null, 1016, new BlockPosition(this.ghast), 0); EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4); diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch index a810e53c..02e4e1d9 100644 --- a/nms-patches/EntityHanging.patch +++ b/nms-patches/EntityHanging.patch @@ -143,7 +143,7 @@ + // CraftBukkit end + this.die(); - this.ap(); + this.av(); this.a(damagesource.getEntity()); @@ -151,6 +199,18 @@ diff --git a/nms-patches/EntityHorseAbstract.patch b/nms-patches/EntityHorseAbstract.patch index aff173b0..ae678d96 100644 --- a/nms-patches/EntityHorseAbstract.patch +++ b/nms-patches/EntityHorseAbstract.patch @@ -9,23 +9,19 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable { @@ -39,6 +40,7 @@ - private float bS; - protected boolean bE = true; - protected int bF; + private float bT; + protected boolean bF = true; + protected int bG; + public int maxDomestication = 100; // CraftBukkit - store max domestication value public EntityHorseAbstract(World world) { super(world); -@@ -211,10 +213,10 @@ - return 2; - } - -- protected void dx() { -+ public void dx() { // PAIL: protected-> public, rename +@@ -214,7 +216,7 @@ + public void loadChest() { InventoryHorseChest inventoryhorsechest = this.inventoryChest; -- this.inventoryChest = new InventoryHorseChest("HorseChest", this.di()); -+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.di(), this); // CraftBukkit +- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dl()); ++ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dl(), this); // CraftBukkit this.inventoryChest.a(this.getName()); if (inventoryhorsechest != null) { inventoryhorsechest.b(this); @@ -37,7 +33,7 @@ + return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 } - protected float ci() { + protected float co() { @@ -414,7 +416,7 @@ } @@ -72,8 +68,8 @@ + this.heal(1.0F, RegainReason.REGEN); // CraftBukkit } - if (this.dE()) { -@@ -719,6 +722,7 @@ + if (this.dH()) { +@@ -723,6 +726,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString()); } @@ -81,7 +77,7 @@ if (!this.inventoryChest.getItem(0).isEmpty()) { nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); -@@ -745,6 +749,11 @@ +@@ -749,6 +753,11 @@ if (!s.isEmpty()) { this.setOwnerUUID(UUID.fromString(s)); } @@ -93,10 +89,10 @@ AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); -@@ -797,6 +806,18 @@ +@@ -801,6 +810,18 @@ } - public void b(int i) { + public void b_(int i) { + // CraftBukkit start + float power; + if (i >= 90) { @@ -110,5 +106,5 @@ + } + // CraftBukkit end this.canSlide = true; - this.dL(); + this.dr(); } diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch index 7bc17380..72cbcf83 100644 --- a/nms-patches/EntityHuman.patch +++ b/nms-patches/EntityHuman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityHuman.java +++ b/net/minecraft/server/EntityHuman.java -@@ -9,6 +9,18 @@ +@@ -9,6 +9,19 @@ import java.util.UUID; import javax.annotation.Nullable; @@ -8,6 +8,7 @@ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.entity.CraftItem; +import org.bukkit.entity.Player; ++import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.player.PlayerBedEnterEvent; +import org.bukkit.event.player.PlayerBedLeaveEvent; @@ -19,20 +20,20 @@ public abstract class EntityHuman extends EntityLiving { private static final DataWatcherObject<Float> a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); -@@ -16,10 +28,10 @@ - protected static final DataWatcherObject<Byte> bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); - protected static final DataWatcherObject<Byte> br = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); +@@ -18,10 +31,10 @@ + protected static final DataWatcherObject<NBTTagCompound> bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.n); + protected static final DataWatcherObject<NBTTagCompound> bu = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.n); public PlayerInventory inventory = new PlayerInventory(this); -- private InventoryEnderChest enderChest = new InventoryEnderChest(); -+ private InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor +- protected InventoryEnderChest enderChest = new InventoryEnderChest(); ++ protected InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor public Container defaultContainer; public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int bw; - public float bx; - public float by; -@@ -52,6 +64,17 @@ + protected int bA; + public float bB; + public float bC; +@@ -53,6 +66,17 @@ @Nullable public EntityFishingHook hookedFish; @@ -50,7 +51,7 @@ protected ItemCooldown l() { return new ItemCooldown(); } -@@ -312,7 +335,8 @@ +@@ -311,7 +335,8 @@ if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) { if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) { @@ -60,69 +61,16 @@ } if (this.foodData.c() && this.ticksLived % 10 == 0) { -@@ -336,7 +360,7 @@ +@@ -335,7 +360,7 @@ - this.l((float) attributeinstance.getValue()); + this.m((float) attributeinstance.getValue()); float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - float f1 = (float) (Math.atan(-this.motY * 0.20000000298023224D) * 15.0D); + float f1 = (float) ( org.bukkit.craftbukkit.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0D); // CraftBukkit if (f > 0.1F) { f = 0.1F; -@@ -442,28 +466,34 @@ - public void b(Entity entity, int i) { - if (entity != this) { - this.addScore(i); -- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f); -+ // CraftBukkit - Get our scores instead -+ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList<ScoreboardScore>()); - - if (entity instanceof EntityHuman) { - this.b(StatisticList.D); -- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e)); -+ // CraftBukkit - Get our scores instead -+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection); -+ // collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e)); -+ // CraftBukkit end - } else { - this.b(StatisticList.B); - } - - collection.addAll(this.d(entity)); -- Iterator iterator = collection.iterator(); -+ Iterator<ScoreboardScore> iterator = collection.iterator(); - - while (iterator.hasNext()) { -- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); -+ // CraftBukkit start -+ // ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); - -- this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore(); -+ iterator.next().incrementScore(); -+ // CraftBukkit end - } - - } - } - -- private Collection<ScoreboardObjective> d(Entity entity) { -+ private Collection<ScoreboardScore> d(Entity entity) { // CraftBukkit - String s = entity instanceof EntityHuman ? entity.getName() : entity.bf(); - ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName()); - -@@ -488,7 +518,10 @@ - int j = scoreboardteam1.m().b(); - - if (j >= 0 && j < IScoreboardCriteria.m.length) { -- return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]); -+ // CraftBukkit - Get our scores instead -+ return this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.m[j], this.getName(), new java.util.ArrayList<ScoreboardScore>()); -+ // return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]); -+ // CraftBukkit end - } - } - -@@ -497,6 +530,7 @@ +@@ -457,6 +482,7 @@ @Nullable public EntityItem a(boolean flag) { @@ -130,7 +78,7 @@ return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && !this.inventory.getItemInHand().isEmpty() ? this.inventory.getItemInHand().getCount() : 1), false, true); } -@@ -539,6 +573,30 @@ +@@ -499,6 +525,30 @@ entityitem.motZ += Math.sin((double) f1) * (double) f; } @@ -161,7 +109,7 @@ ItemStack itemstack1 = this.a(entityitem); if (flag1) { -@@ -646,6 +704,13 @@ +@@ -614,6 +664,13 @@ this.a(true, true, false); } @@ -173,18 +121,18 @@ + // CraftBukkit end + if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { - this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.f = nbttagcompound.getBoolean("SpawnForced"); -@@ -683,6 +748,7 @@ - this.foodData.b(nbttagcompound); - this.abilities.a(nbttagcompound); - nbttagcompound.set("EnderItems", this.enderChest.i()); + this.d = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); + this.e = nbttagcompound.getBoolean("SpawnForced"); +@@ -666,6 +723,7 @@ + if (!this.getShoulderEntityRight().isEmpty()) { + nbttagcompound.set("ShoulderEntityRight", this.getShoulderEntityRight()); + } + nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds - } - public boolean damageEntity(DamageSource damagesource, float f) { -@@ -701,7 +767,7 @@ + } +@@ -686,7 +744,7 @@ + this.releaseShoulderEntities(); if (damagesource.r()) { if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { - f = 0.0F; @@ -192,7 +140,7 @@ } if (this.world.getDifficulty() == EnumDifficulty.EASY) { -@@ -713,7 +779,7 @@ +@@ -698,7 +756,7 @@ } } @@ -201,12 +149,12 @@ } } } -@@ -727,10 +793,29 @@ +@@ -712,10 +770,29 @@ } public boolean a(EntityHuman entityhuman) { -- ScoreboardTeamBase scoreboardteambase = this.aQ(); -- ScoreboardTeamBase scoreboardteambase1 = entityhuman.aQ(); +- ScoreboardTeamBase scoreboardteambase = this.aW(); +- ScoreboardTeamBase scoreboardteambase1 = entityhuman.aW(); + // CraftBukkit start - Change to check OTHER player's scoreboard team according to API + // To summarize this method's logic, it's "Can parameter hurt this" + org.bukkit.scoreboard.Team team; @@ -234,7 +182,7 @@ } protected void damageArmor(float f) { -@@ -773,7 +858,12 @@ +@@ -758,7 +835,12 @@ return (float) i / (float) this.inventory.armor.size(); } @@ -248,7 +196,7 @@ if (!this.isInvulnerable(damagesource)) { f = this.applyArmorModifier(damagesource, f); f = this.applyMagicModifier(damagesource, f); -@@ -793,6 +883,7 @@ +@@ -778,6 +860,7 @@ } } @@ -256,7 +204,7 @@ } public void openSign(TileEntitySign tileentitysign) {} -@@ -914,8 +1005,15 @@ +@@ -899,8 +982,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isBurning()) { @@ -274,7 +222,7 @@ } } -@@ -946,8 +1044,11 @@ +@@ -931,8 +1021,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.r(entityliving) && this.h(entityliving) < 9.0D) { @@ -287,7 +235,7 @@ } } -@@ -956,11 +1057,28 @@ +@@ -941,11 +1034,28 @@ } if (entity instanceof EntityPlayer && entity.velocityChanged) { @@ -316,7 +264,7 @@ } if (flag2) { -@@ -1013,7 +1131,14 @@ +@@ -994,7 +1104,14 @@ this.a(StatisticList.y, Math.round(f5 * 10.0F)); if (j > 0) { @@ -332,7 +280,7 @@ } if (this.world instanceof WorldServer && f5 > 2.0F) { -@@ -1029,6 +1154,11 @@ +@@ -1010,6 +1127,11 @@ if (flag4) { entity.extinguish(); } @@ -344,7 +292,7 @@ } } -@@ -1119,6 +1249,20 @@ +@@ -1100,6 +1222,20 @@ this.stopRiding(); } @@ -362,10 +310,10 @@ + } + // CraftBukkit end + + this.releaseShoulderEntities(); this.setSize(0.2F, 0.2F); if (this.world.isLoaded(blockposition)) { - float f = 0.5F + (float) enumdirection.getAdjacentX() * 0.4F; -@@ -1178,6 +1322,23 @@ +@@ -1160,6 +1296,23 @@ this.world.everyoneSleeping(); } @@ -389,15 +337,59 @@ this.sleepTicks = flag ? 0 : 100; if (flag2) { this.setRespawnPosition(this.bedPosition, false); -@@ -1229,9 +1390,11 @@ +@@ -1211,9 +1364,11 @@ if (blockposition != null) { - this.e = blockposition; - this.f = flag; + this.d = blockposition; + this.e = flag; + this.spawnWorld = this.world.worldData.getName(); // CraftBukkit } else { - this.e = null; - this.f = false; + this.d = null; + this.e = false; + this.spawnWorld = ""; // CraftBukkit } } +@@ -1537,13 +1692,17 @@ + } + + protected void releaseShoulderEntities() { +- this.spawnEntityFromShoulder(this.getShoulderEntityLeft()); +- this.setShoulderEntityLeft(new NBTTagCompound()); +- this.spawnEntityFromShoulder(this.getShoulderEntityRight()); +- this.setShoulderEntityRight(new NBTTagCompound()); ++ // CraftBukkit start ++ if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) { ++ this.setShoulderEntityLeft(new NBTTagCompound()); ++ } ++ if (this.spawnEntityFromShoulder(this.getShoulderEntityRight())) { ++ this.setShoulderEntityRight(new NBTTagCompound()); ++ } ++ // CraftBukkit end + } + +- private void spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) { ++ private boolean spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean + if (!this.world.isClientSide && !nbttagcompound.isEmpty()) { + Entity entity = EntityTypes.a(nbttagcompound, this.world); + +@@ -1552,9 +1711,10 @@ + } + + entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ); +- this.world.addEntity(entity); ++ return this.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit + } + ++ return true; // CraftBukkit + } + + public abstract boolean isSpectator(); +@@ -1756,7 +1916,7 @@ + return entitymonster.c(this.a); + } + +- public boolean apply(@Nullable Object object) { ++ public boolean apply(@Nullable EntityMonster object) { // CraftBukkit - decompile error + return this.a((EntityMonster) object); + } + diff --git a/nms-patches/EntityInsentient.patch b/nms-patches/EntityInsentient.patch index d76af694..f29afe3e 100644 --- a/nms-patches/EntityInsentient.patch +++ b/nms-patches/EntityInsentient.patch @@ -88,7 +88,7 @@ NBTTagList nbttaglist; int i; -@@ -521,7 +573,9 @@ +@@ -525,7 +577,9 @@ } if (!itemstack1.isEmpty() && (double) (this.random.nextFloat() - 0.1F) < d0) { @@ -97,8 +97,8 @@ + this.forceDrops = false; // CraftBukkit } - if (itemstack.getItem() == Items.DIAMOND && entityitem.n() != null) { -@@ -569,11 +623,11 @@ + this.setSlot(enumitemslot, itemstack); +@@ -565,11 +619,11 @@ double d2 = entityhuman.locZ - this.locZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; @@ -112,7 +112,7 @@ this.die(); } else if (d3 < 1024.0D) { this.ticksFarFromPlayer = 0; -@@ -942,12 +996,24 @@ +@@ -938,12 +992,24 @@ public final boolean b(EntityHuman entityhuman, EnumHand enumhand) { if (this.isLeashed() && this.getLeashHolder() == entityhuman) { @@ -137,9 +137,9 @@ this.setLeashHolder(entityhuman, true); itemstack.subtract(1); return true; -@@ -968,10 +1034,12 @@ +@@ -964,10 +1030,12 @@ - if (this.bD) { + if (this.bE) { if (!this.isAlive()) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.PLAYER_UNLEASH)); // CraftBukkit this.unleash(true, true); @@ -150,8 +150,8 @@ this.unleash(true, true); } } -@@ -982,7 +1050,9 @@ - this.bD = false; +@@ -978,7 +1046,9 @@ + this.bE = false; this.leashHolder = null; if (!this.world.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit @@ -160,7 +160,7 @@ } if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { -@@ -1052,6 +1122,7 @@ +@@ -1048,6 +1118,7 @@ this.setLeashHolder(entityleash, true); } else { diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch index 4215e019..50faa6a4 100644 --- a/nms-patches/EntityItem.patch +++ b/nms-patches/EntityItem.patch @@ -19,7 +19,7 @@ @@ -54,9 +56,12 @@ this.die(); } else { - super.A_(); + super.B_(); - if (this.pickupDelay > 0 && this.pickupDelay != 32767) { - --this.pickupDelay; - } @@ -42,7 +42,7 @@ } + // Craftbukkit end */ - this.ak(); + this.aq(); if (!this.world.isClientSide) { @@ -121,6 +128,12 @@ } @@ -74,7 +74,7 @@ + return false; + } + // CraftBukkit end - this.ap(); + this.av(); this.f = (int) ((float) this.f - f); if (this.f <= 0) { @@ -270,6 +289,26 @@ @@ -102,5 +102,5 @@ + // CraftBukkit end + if (this.pickupDelay == 0 && (this.h == null || 6000 - this.age <= 200 || this.h.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) { - if (item == Item.getItemOf(Blocks.LOG)) { - entityhuman.b((Statistic) AchievementList.g); + entityhuman.receive(this, i); + if (itemstack.isEmpty()) { diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch index 4178fdcf..f2cd4fa0 100644 --- a/nms-patches/EntityItemFrame.patch +++ b/nms-patches/EntityItemFrame.patch @@ -10,5 +10,5 @@ + } + // CraftBukkit end this.b(damagesource.getEntity(), false); - this.a(SoundEffects.dh, 1.0F, 1.0F); + this.a(SoundEffects.du, 1.0F, 1.0F); this.setItem(ItemStack.a); diff --git a/nms-patches/EntityLightning.patch b/nms-patches/EntityLightning.patch index 649e5fd3..ec1e14a8 100644 --- a/nms-patches/EntityLightning.patch +++ b/nms-patches/EntityLightning.patch @@ -46,12 +46,12 @@ } } @@ -41,7 +53,24 @@ - public void A_() { - super.A_(); + public void B_() { + super.B_(); if (this.lifeTicks == 2) { -- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dx, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); +- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dK, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + // CraftBukkit start - Use relative location for far away sounds -+ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dv, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); ++ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dG, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + float pitch = 0.8F + this.random.nextFloat() * 0.2F; + int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; + for (EntityPlayer player : (List<EntityPlayer>) (List) this.world.players) { @@ -62,13 +62,13 @@ + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; + double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; -+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dx, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch)); ++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dK, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch)); + } else { -+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dx, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch)); ++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dK, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch)); + } + } + // CraftBukkit end - this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dw, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); + this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dJ, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); } @@ -57,13 +86,17 @@ diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch index 2b013447..84f0863c 100644 --- a/nms-patches/EntityLiving.patch +++ b/nms-patches/EntityLiving.patch @@ -25,10 +25,10 @@ public abstract class EntityLiving extends Entity { private static final Logger a = LogManager.getLogger(); -@@ -87,6 +105,14 @@ - private BlockPosition bE; - private DamageSource bF; - private long bG; +@@ -88,6 +106,14 @@ + private BlockPosition bF; + private DamageSource bG; + private long bH; + // CraftBukkit start + public int expToDrop; + public int maxAirTicks = 300; @@ -38,9 +38,9 @@ + public boolean collides = true; + // CraftBukkit end - public void Q() { + public void killEntity() { this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE); -@@ -101,7 +127,8 @@ +@@ -102,7 +128,8 @@ this.updateEffects = true; this.activeItem = ItemStack.a; this.initAttributes(); @@ -50,7 +50,7 @@ this.i = true; this.aM = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.setPosition(this.locX, this.locY, this.locZ); -@@ -139,7 +166,13 @@ +@@ -140,7 +167,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); @@ -65,7 +65,7 @@ } } -@@ -201,7 +234,11 @@ +@@ -202,7 +235,11 @@ this.stopRiding(); } } else { @@ -78,7 +78,7 @@ } if (!this.world.isClientSide) { -@@ -258,6 +295,18 @@ +@@ -259,6 +296,18 @@ this.world.methodProfiler.b(); } @@ -97,9 +97,9 @@ protected void b(BlockPosition blockposition) { int i = EnchantmentManager.a(Enchantments.j, this); -@@ -273,19 +322,19 @@ +@@ -274,19 +323,19 @@ - protected void bG() { + protected void bM() { ++this.deathTicks; - if (this.deathTicks == 20) { + if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) @@ -107,14 +107,14 @@ - if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) { - i = this.getExpValue(this.killer); +- +- while (i > 0) { +- int j = EntityExperienceOrb.getOrbValue(i); + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + i = this.expToDrop; + while (i > 0) { + int j = EntityExperienceOrb.getOrbValue(i); -- while (i > 0) { -- int j = EntityExperienceOrb.getOrbValue(i); -- - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } @@ -126,7 +126,7 @@ this.die(); -@@ -441,6 +490,17 @@ +@@ -442,6 +491,17 @@ } } @@ -144,7 +144,7 @@ if (nbttagcompound.hasKeyOfType("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -463,9 +523,15 @@ +@@ -464,9 +524,15 @@ } @@ -160,7 +160,7 @@ try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -483,6 +549,17 @@ +@@ -484,6 +550,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -178,7 +178,7 @@ if (this.updateEffects) { if (!this.world.isClientSide) { -@@ -580,6 +657,12 @@ +@@ -585,6 +662,12 @@ } public void addEffect(MobEffect mobeffect) { @@ -191,7 +191,7 @@ if (this.d(mobeffect)) { MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect()); -@@ -612,6 +695,12 @@ +@@ -617,6 +700,12 @@ @Nullable public MobEffect c(@Nullable MobEffectList mobeffectlist) { @@ -204,7 +204,7 @@ return (MobEffect) this.effects.remove(mobeffectlist); } -@@ -651,20 +740,52 @@ +@@ -656,20 +745,52 @@ } @@ -258,10 +258,10 @@ this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth()))); } -@@ -680,14 +801,16 @@ - } else if (damagesource.o() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { - return false; +@@ -687,14 +808,16 @@ } else { + float f1 = f; + - if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) + if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { @@ -278,7 +278,7 @@ this.damageShield(f); f = 0.0F; if (!damagesource.a()) { -@@ -706,20 +829,39 @@ +@@ -713,20 +836,39 @@ if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { if (f <= this.lastDamage) { @@ -320,37 +320,37 @@ this.aA = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -806,18 +948,27 @@ +@@ -833,18 +975,26 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; + // CraftBukkit start -+ ItemStack itemstack = ItemStack.a; ++ ItemStack itemstack1 = ItemStack.a; for (int j = 0; j < i; ++j) { EnumHand enumhand = aenumhand[j]; -- ItemStack itemstack = this.b(enumhand); -+ itemstack = this.b(enumhand); +- ItemStack itemstack1 = this.b(enumhand); ++ itemstack1 = this.b(enumhand); - if (itemstack.getItem() == Items.cY) { -- itemstack.subtract(1); -+ // itemstack.subtract(1); - flag = true; + if (itemstack1.getItem() == Items.cY) { + itemstack = itemstack1.cloneItemStack(); +- itemstack1.subtract(1); ++ // itemstack1.subtract(1); // CraftBukkit break; } } +- if (itemstack != null) { + EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity()); -+ event.setCancelled(!flag); ++ event.setCancelled(itemstack == null); + this.world.getServer().getPluginManager().callEvent(event); -+ flag = !event.isCancelled(); + - if (flag) { -+ itemstack.subtract(1); ++ if (itemstack != null && !event.isCancelled()) { ++ itemstack1.subtract(1); + // CraftBukkit end - if (this instanceof EntityHuman) { - ((EntityHuman) this).b(StatisticList.b(Items.cY)); - } -@@ -914,6 +1065,12 @@ + if (this instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) this; + +@@ -944,6 +1094,12 @@ boolean flag = this.lastDamageByPlayerTime > 0; this.a(flag, i, damagesource); @@ -363,7 +363,7 @@ } } -@@ -1003,8 +1160,13 @@ +@@ -1033,8 +1189,13 @@ int i = MathHelper.f((f - 3.0F - f2) * f1); if (i > 0) { @@ -378,16 +378,16 @@ int j = MathHelper.floor(this.locX); int k = MathHelper.floor(this.locY - 0.20000000298023224D); int l = MathHelper.floor(this.locZ); -@@ -1031,7 +1193,7 @@ +@@ -1061,7 +1222,7 @@ protected float applyArmorModifier(DamageSource damagesource, float f) { if (!damagesource.ignoresArmor()) { - this.damageArmor(f); + // this.damageArmor(f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) - f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.h).getValue()); + f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.i).getValue()); } -@@ -1044,7 +1206,8 @@ +@@ -1074,7 +1235,8 @@ } else { int i; @@ -397,7 +397,7 @@ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1065,22 +1228,129 @@ +@@ -1095,22 +1257,142 @@ } } @@ -529,7 +529,20 @@ + + return true; + } else { -+ return (event.getDamage(DamageModifier.BLOCKING) < 0) ? false : originalDamage > 0; ++ // Duplicate triggers if blocking ++ if (event.getDamage(DamageModifier.BLOCKING) < 0) { ++ if (this instanceof EntityPlayer) { ++ CriterionTriggers.h.a((EntityPlayer) this, damagesource, f, originalDamage, true); ++ } ++ ++ if (damagesource.getEntity() instanceof EntityPlayer) { ++ CriterionTriggers.g.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true); ++ } ++ ++ return false; ++ } else { ++ return originalDamage > 0; ++ } + // CraftBukkit end } } @@ -537,7 +550,7 @@ } public CombatTracker getCombatTracker() { -@@ -1147,6 +1417,7 @@ +@@ -1177,6 +1459,7 @@ public AttributeMapBase getAttributeMap() { if (this.attributeMap == null) { this.attributeMap = new AttributeMapServer(); @@ -545,7 +558,7 @@ } return this.attributeMap; -@@ -1438,6 +1709,7 @@ +@@ -1469,6 +1752,7 @@ } if (this.onGround && !this.world.isClientSide) { @@ -553,7 +566,7 @@ this.setFlag(7, false); } } else { -@@ -1798,6 +2070,7 @@ +@@ -1838,6 +2122,7 @@ } if (!this.world.isClientSide) { @@ -561,7 +574,7 @@ this.setFlag(7, flag); } -@@ -1895,11 +2168,11 @@ +@@ -1931,11 +2216,11 @@ } public boolean isInteractable() { @@ -574,12 +587,12 @@ + return this.isAlive() && !this.m_() && this.collides; // CraftBukkit } - protected void ap() { -@@ -2036,7 +2309,27 @@ + protected void av() { +@@ -2072,7 +2357,27 @@ protected void v() { if (!this.activeItem.isEmpty() && this.isHandRaised()) { - this.a(this.activeItem, 16); -- this.a(this.cz(), this.activeItem.a(this.world, this)); + this.b(this.activeItem, 16); +- this.a(this.cF(), this.activeItem.a(this.world, this)); + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; + if (this instanceof EntityPlayer) { @@ -599,12 +612,12 @@ + itemstack = this.activeItem.a(this.world, this); + } + -+ this.a(this.cz(), itemstack); ++ this.a(this.cF(), itemstack); + // CraftBukkit end - this.cF(); + this.cL(); } -@@ -2115,10 +2408,18 @@ +@@ -2151,10 +2456,18 @@ } if (flag1) { diff --git a/nms-patches/EntityLlama.patch b/nms-patches/EntityLlama.patch deleted file mode 100644 index c3214d7e..00000000 --- a/nms-patches/EntityLlama.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/server/EntityLlama.java -+++ b/net/minecraft/server/EntityLlama.java -@@ -20,7 +20,7 @@ - this.setSize(0.9F, 1.87F); - } - -- private void p(int i) { -+ public void p(int i) { // PAIL: private-> public, rename - this.datawatcher.set(EntityLlama.bG, Integer.valueOf(Math.max(1, Math.min(5, i)))); - } - -@@ -30,7 +30,7 @@ - this.p(1 + this.random.nextInt(i)); - } - -- public int dL() { -+ public int dL() { // PAIL: rename - return ((Integer) this.datawatcher.get(EntityLlama.bG)).intValue(); - } - diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch index 2760942b..3a325170 100644 --- a/nms-patches/EntityMinecartAbstract.patch +++ b/nms-patches/EntityMinecartAbstract.patch @@ -53,7 +53,7 @@ + // CraftBukkit end this.e(-this.u()); this.d(10); - this.ap(); + this.av(); @@ -108,6 +141,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; @@ -67,13 +67,13 @@ + return true; + } + // CraftBukkit end - this.az(); + this.aF(); if (flag && !this.hasCustomName()) { this.die(); @@ -146,6 +188,14 @@ } - public void A_() { + public void B_() { + // CraftBukkit start + double prevX = this.locX; + double prevY = this.locY; @@ -87,13 +87,13 @@ } @@ -166,7 +216,7 @@ - i = this.V(); + i = this.Z(); if (this.ak) { - if (minecraftserver.getAllowNether()) { + if (true || minecraftserver.getAllowNether()) { // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled if (!this.isPassenger() && this.al++ >= i) { this.al = i; - this.portalCooldown = this.aE(); + this.portalCooldown = this.aK(); @@ -266,6 +316,18 @@ } @@ -156,7 +156,7 @@ @@ -297,7 +383,7 @@ } - protected double o() { + protected double p() { - return 0.4D; + return this.maxSpeed; // CraftBukkit } diff --git a/nms-patches/EntityOcelot.patch b/nms-patches/EntityOcelot.patch index 6574350a..ae02a4e6 100644 --- a/nms-patches/EntityOcelot.patch +++ b/nms-patches/EntityOcelot.patch @@ -34,10 +34,10 @@ - if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { - this.setTamed(true); + this.c(entityhuman); this.setCatType(1 + this.world.random.nextInt(3)); - this.setOwnerUUID(entityhuman.getUniqueID()); -@@ -238,7 +243,7 @@ + this.p(true); +@@ -237,7 +242,7 @@ entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entityocelot.setAgeRaw(-24000); diff --git a/nms-patches/EntityPainting.patch b/nms-patches/EntityPainting.patch index f8f07bc3..06269bbb 100644 --- a/nms-patches/EntityPainting.patch +++ b/nms-patches/EntityPainting.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityPainting.java +++ b/net/minecraft/server/EntityPainting.java -@@ -10,6 +10,7 @@ +@@ -11,6 +11,7 @@ public EntityPainting(World world) { super(world); diff --git a/nms-patches/EntityPig.patch b/nms-patches/EntityPig.patch index eb84f4f2..6d97b021 100644 --- a/nms-patches/EntityPig.patch +++ b/nms-patches/EntityPig.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityPig.java +++ b/net/minecraft/server/EntityPig.java -@@ -5,6 +5,8 @@ +@@ -4,6 +4,8 @@ import java.util.Set; import javax.annotation.Nullable; @@ -8,8 +8,8 @@ + public class EntityPig extends EntityAnimal { - private static final DataWatcherObject<Boolean> bw = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h); -@@ -125,13 +127,14 @@ + private static final DataWatcherObject<Boolean> bx = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h); +@@ -124,13 +126,14 @@ } public void die(DamageSource damagesource) { @@ -25,7 +25,7 @@ } @Nullable -@@ -156,6 +159,12 @@ +@@ -155,6 +158,12 @@ if (!this.world.isClientSide && !this.dead) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); @@ -38,7 +38,7 @@ entitypigzombie.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); entitypigzombie.setAI(this.hasAI()); -@@ -164,7 +173,8 @@ +@@ -163,7 +172,8 @@ entitypigzombie.setCustomNameVisible(this.getCustomNameVisible()); } diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index dfbb51c1..5b01aa9c 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -22,8 +22,8 @@ + public class EntityPlayer extends EntityHuman implements ICrafting { - private static final Logger bR = LogManager.getLogger(); -@@ -44,6 +60,19 @@ + private static final Logger bW = LogManager.getLogger(); +@@ -51,6 +67,19 @@ public int ping; public boolean viewingCredits; @@ -43,10 +43,10 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { super(worldserver, gameprofile); playerinteractmanager.player = this; -@@ -67,13 +96,18 @@ - +@@ -75,13 +104,18 @@ this.server = minecraftserver; - this.bU = minecraftserver.getPlayerList().a((EntityHuman) this); + this.ca = minecraftserver.getPlayerList().a((EntityHuman) this); + this.bZ = minecraftserver.getPlayerList().h(this); - this.P = 0.0F; + this.P = 1.0F; // CraftBukkit - hit when sneaking this.setPositionRotation(blockposition, 0.0F, 0.0F); @@ -63,20 +63,20 @@ } public void a(NBTTagCompound nbttagcompound) { -@@ -86,6 +120,7 @@ - } +@@ -104,6 +138,7 @@ + if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { + this.cs.a(nbttagcompound.getCompound("recipeBook")); } - + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit + } - public static void a(DataConverterManager dataconvertermanager) { -@@ -119,8 +154,33 @@ - nbttagcompound1.set("Entity", nbttagcompound2); - nbttagcompound.set("RootVehicle", nbttagcompound1); +@@ -150,8 +185,34 @@ } -+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit -+ } + + nbttagcompound.set("recipeBook", this.cs.e()); ++ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit + } + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(World world) { @@ -100,15 +100,16 @@ + } + this.dimension = ((WorldServer) this.world).dimension; + this.playerInteractManager.a((WorldServer) world); - } ++ } + // CraftBukkit end - ++ public void levelDown(int i) { super.levelDown(i); -@@ -151,6 +211,11 @@ + this.lastSentExp = -1; +@@ -185,6 +246,11 @@ } - public void A_() { + public void B_() { + // CraftBukkit start + if (this.joining) { + this.joining = false; @@ -117,17 +118,17 @@ this.playerInteractManager.a(); --this.invulnerableTicks; if (this.noDamageTicks > 0) { -@@ -210,7 +275,7 @@ +@@ -250,7 +316,7 @@ } - if (this.getHealth() != this.lastHealthSent || this.cc != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cd) { + if (this.getHealth() != this.lastHealthSent || this.ci != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cj) { - this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); + this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit this.lastHealthSent = this.getHealth(); - this.cc = this.foodData.getFoodLevel(); - this.cd = this.foodData.getSaturationLevel() == 0.0F; -@@ -231,6 +296,12 @@ - this.a(IScoreboardCriteria.i, MathHelper.f((float) this.bX)); + this.ci = this.foodData.getFoodLevel(); + this.cj = this.foodData.getSaturationLevel() == 0.0F; +@@ -271,6 +337,12 @@ + this.a(IScoreboardCriteria.i, MathHelper.f((float) this.cd)); } + // CraftBukkit start - Force max health updates @@ -136,11 +137,11 @@ + } + // CraftBukkit end + - if (this.getArmorStrength() != this.bY) { - this.bY = this.getArmorStrength(); - this.a(IScoreboardCriteria.j, MathHelper.f((float) this.bY)); -@@ -255,6 +326,16 @@ - this.o(); + if (this.getArmorStrength() != this.ce) { + this.ce = this.getArmorStrength(); + this.a(IScoreboardCriteria.j, MathHelper.f((float) this.ce)); +@@ -295,6 +367,16 @@ + CriterionTriggers.o.a(this); } + // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent @@ -156,7 +157,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -265,12 +346,11 @@ +@@ -305,12 +387,11 @@ } private void a(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -171,42 +172,42 @@ scoreboardscore.setScore(i); } -@@ -319,31 +399,61 @@ +@@ -321,32 +402,62 @@ boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag)); - if (flag) { -- ScoreboardTeamBase scoreboardteambase = this.aQ(); +- ScoreboardTeamBase scoreboardteambase = this.aW(); + // CraftBukkit start - fire PlayerDeathEvent + if (this.dead) { + return; + } + java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.inventory.getSize()); -+ boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory"); ++ boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory") || this.isSpectator(); + + if (!keepInventory) { + for (ItemStack item : this.inventory.getContents()) { -+ if (!item.isEmpty() && !EnchantmentManager.e(item)) { // PAIL: shouldNotDrop (Vanishing enchant) ++ if (!item.isEmpty() && !EnchantmentManager.shouldNotDrop(item)) { + loot.add(CraftItemStack.asCraftMirror(item)); + } + } + } + + IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage(); -+ -+ String deathmessage = chatmessage.toPlainText(); -+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); - if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) { - if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { - this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage()); - } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) { - this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage()); ++ String deathmessage = chatmessage.toPlainText(); ++ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); ++ + String deathMessage = event.getDeathMessage(); + + if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override? + if (deathMessage.equals(deathmessage)) { -+ ScoreboardTeamBase scoreboardteambase = this.aQ(); ++ ScoreboardTeamBase scoreboardteambase = this.aW(); + + if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) { + if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { @@ -223,8 +224,9 @@ } } + this.releaseShoulderEntities(); - if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { -- this.cN(); +- this.cT(); - this.inventory.o(); + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { @@ -247,7 +249,62 @@ scoreboardscore.incrementScore(); } -@@ -402,13 +512,16 @@ +@@ -374,29 +485,36 @@ + if (entity != this) { + super.a(entity, i, damagesource); + this.addScore(i); +- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f); ++ // CraftBukkit - Get our scores instead ++ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList<ScoreboardScore>()); + + if (entity instanceof EntityHuman) { + this.b(StatisticList.D); +- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e)); ++ // CraftBukkit - Get our scores instead ++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection); ++ // collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e)); ++ // CraftBukkit end + } else { + this.b(StatisticList.B); + } + + collection.addAll(this.E(entity)); +- Iterator iterator = collection.iterator(); ++ Iterator<ScoreboardScore> iterator = collection.iterator(); // CraftBukkit + + while (iterator.hasNext()) { +- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); ++ // CraftBukkit start ++ // ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); + +- this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore(); ++ // this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore(); ++ iterator.next().incrementScore(); ++ // CraftBukkit end + } + + CriterionTriggers.b.a(this, entity, damagesource); + } + } + +- private Collection<ScoreboardObjective> E(Entity entity) { ++ private Collection<ScoreboardScore> E(Entity entity) { // CraftBukkit + String s = entity instanceof EntityHuman ? entity.getName() : entity.bl(); + ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName()); + +@@ -421,7 +539,10 @@ + int j = scoreboardteam1.m().b(); + + if (j >= 0 && j < IScoreboardCriteria.m.length) { +- return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]); ++ // CraftBukkit - Get our scores instead ++ return this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.m[j], this.getName(), new java.util.ArrayList<ScoreboardScore>()); ++ // return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]); ++ // CraftBukkit end + } + } + +@@ -463,12 +584,14 @@ } private boolean canPvP() { @@ -257,17 +314,23 @@ } @Nullable - public Entity c(int i) { + public Entity b(int i) { - this.worldChangeInvuln = true; + if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 + // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension + if (this.dimension == 0 && i == -1) { + this.cw = new Vec3D(this.locX, this.locY, this.locZ); + } else if (this.dimension != -1 && i != 0) { +@@ -476,6 +599,7 @@ + } + if (this.dimension == 1 && i == 1) { + this.worldChangeInvuln = true; // CraftBukkit - Moved down from above this.world.kill(this); if (!this.viewingCredits) { this.viewingCredits = true; -@@ -429,7 +542,10 @@ - this.b((Statistic) AchievementList.y); +@@ -489,7 +613,10 @@ + i = 1; } - this.server.getPlayerList().a(this, i); @@ -278,7 +341,7 @@ this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false)); this.lastSentExp = -1; this.lastHealthSent = -1.0F; -@@ -474,6 +590,7 @@ +@@ -535,6 +662,7 @@ } public void a(boolean flag, boolean flag1, boolean flag2) { @@ -286,7 +349,7 @@ if (this.isSleeping()) { this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); } -@@ -552,23 +669,55 @@ +@@ -613,23 +741,55 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -345,10 +408,10 @@ if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) { this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true); } else { -@@ -582,18 +731,21 @@ +@@ -643,18 +803,21 @@ if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) { - this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), (byte) 2)); - this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.Y, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); + this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), ChatMessageType.GAME_INFO)); + this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ab, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); + iinventory.closeContainer(this); // CraftBukkit return; } @@ -369,7 +432,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); -@@ -601,8 +753,14 @@ +@@ -662,8 +825,14 @@ } public void openTrade(IMerchant imerchant) { @@ -385,7 +448,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e(); -@@ -622,13 +780,20 @@ +@@ -683,13 +852,20 @@ } public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -407,7 +470,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); } -@@ -665,6 +830,11 @@ +@@ -730,6 +906,11 @@ public void a(Container container, NonNullList<ItemStack> nonnulllist) { this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); @@ -419,15 +482,24 @@ } public void setContainerData(Container container, int i, int j) { -@@ -679,6 +849,7 @@ +@@ -744,6 +925,7 @@ } public void closeInventory() { + CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); - this.s(); + this.r(); + } +@@ -818,7 +1000,7 @@ + arraylist.add(CraftingManager.a(minecraftkey)); + } + +- this.a((List) arraylist); ++ this.a((List<IRecipe>) arraylist); // CraftBukkit - decompile error } -@@ -760,7 +931,16 @@ + + public void b(List<IRecipe> list) { +@@ -840,7 +1022,16 @@ public void triggerHealthUpdate() { this.lastHealthSent = -1.0E8F; @@ -443,8 +515,8 @@ + // CraftBukkit end public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, (byte) (flag ? 2 : 0))); -@@ -821,6 +1001,18 @@ + this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT)); +@@ -939,6 +1130,18 @@ } public void a(EnumGamemode enumgamemode) { @@ -463,7 +535,7 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -846,6 +1038,7 @@ +@@ -965,6 +1168,7 @@ } public boolean a(int i, String s) { @@ -471,7 +543,7 @@ if ("seed".equals(s) && !this.server.aa()) { return true; } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) { -@@ -859,6 +1052,15 @@ +@@ -978,6 +1182,15 @@ } else { return true; } @@ -487,7 +559,7 @@ } public String A() { -@@ -870,6 +1072,12 @@ +@@ -989,6 +1202,12 @@ } public void a(PacketPlayInSettings packetplayinsettings) { @@ -498,18 +570,18 @@ + } + // CraftBukkit end this.locale = packetplayinsettings.a(); - this.cg = packetplayinsettings.c(); - this.ch = packetplayinsettings.d(); -@@ -931,7 +1139,7 @@ - this.cj = (Entity) (entity == null ? this : entity); - if (entity1 != this.cj) { - this.playerConnection.sendPacket(new PacketPlayOutCamera(this.cj)); -- this.enderTeleportTo(this.cj.locX, this.cj.locY, this.cj.locZ); -+ this.playerConnection.a(this.cj.locX, this.cj.locY, this.cj.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit + this.cm = packetplayinsettings.c(); + this.cn = packetplayinsettings.d(); +@@ -1054,7 +1273,7 @@ + this.cp = (Entity) (entity == null ? this : entity); + if (entity1 != this.cp) { + this.playerConnection.sendPacket(new PacketPlayOutCamera(this.cp)); +- this.enderTeleportTo(this.cp.locX, this.cp.locY, this.cp.locZ); ++ this.playerConnection.a(this.cp.locX, this.cp.locY, this.cp.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit } } -@@ -958,7 +1166,7 @@ +@@ -1081,7 +1300,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -518,24 +590,28 @@ } public void a(EnumHand enumhand) { -@@ -975,11 +1183,151 @@ +@@ -1098,12 +1317,17 @@ } - public void M() { + public void N() { + if (!CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) // CraftBukkit this.setFlag(7, true); } - public void N() { -- this.setFlag(7, true); -- this.setFlag(7, false); + public void O() { + // CraftBukkit start + if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { -+ this.setFlag(7, true); -+ this.setFlag(7, false); + this.setFlag(7, true); + this.setFlag(7, false); + } + // CraftBukkit end -+ } + } + + public AdvancementDataPlayer getAdvancementData() { +@@ -1114,4 +1338,139 @@ + public Vec3D Q() { + return this.cw; + } + + // CraftBukkit start - Add per-player time and weather. + public long timeOffset = 0; @@ -669,6 +745,6 @@ + @Override + public CraftPlayer getBukkitEntity() { + return (CraftPlayer) super.getBukkitEntity(); - } ++ } + // CraftBukkit end } diff --git a/nms-patches/EntitySheep.patch b/nms-patches/EntitySheep.patch index c20df343..a9b69caf 100644 --- a/nms-patches/EntitySheep.patch +++ b/nms-patches/EntitySheep.patch @@ -12,7 +12,7 @@ + public class EntitySheep extends EntityAnimal { - private static final DataWatcherObject<Byte> bw = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); + private static final DataWatcherObject<Byte> bx = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); @@ -12,6 +18,13 @@ public boolean a(EntityHuman entityhuman) { return false; @@ -25,9 +25,9 @@ + } + // CraftBukkit end }, 2, 1); - private static final Map<EnumColor, float[]> by = Maps.newEnumMap(EnumColor.class); - private int bA; -@@ -26,6 +39,7 @@ + private static final Map<EnumColor, float[]> bz = Maps.newEnumMap(EnumColor.class); + private int bB; +@@ -29,6 +42,7 @@ this.setSize(0.9F, 1.3F); this.container.setItem(0, new ItemStack(Items.DYE)); this.container.setItem(1, new ItemStack(Items.DYE)); @@ -35,7 +35,7 @@ } protected void r() { -@@ -128,11 +142,22 @@ +@@ -131,11 +145,22 @@ if (itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { if (!this.world.isClientSide) { @@ -58,7 +58,7 @@ entityitem.motY += (double) (this.random.nextFloat() * 0.05F); entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); -@@ -219,6 +244,12 @@ +@@ -222,6 +247,12 @@ } public void A() { diff --git a/nms-patches/EntityShulker.patch b/nms-patches/EntityShulker.patch index c1482b16..9b21b293 100644 --- a/nms-patches/EntityShulker.patch +++ b/nms-patches/EntityShulker.patch @@ -11,33 +11,6 @@ public class EntityShulker extends EntityGolem implements IMonster { -@@ -14,7 +18,7 @@ - protected static final DataWatcherObject<EnumDirection> a = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.l); - protected static final DataWatcherObject<Optional<BlockPosition>> b = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.k); - protected static final DataWatcherObject<Byte> c = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a); -- protected static final DataWatcherObject<Byte> bw = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a); -+ public static final DataWatcherObject<Byte> bw = DataWatcher.a(EntityShulker.class, DataWatcherRegistry.a); // PAIL: protected -> public, rename COLOR - public static final EnumColor bx = EnumColor.PURPLE; - private float bA; - private float bB; -@@ -65,7 +69,7 @@ - } - - public void D() { -- if (!this.do()) { -+ if (!this.do_()) { - super.D(); - } - -@@ -76,7 +80,7 @@ - } - - protected SoundEffect bW() { -- return this.do() ? SoundEffects.fH : SoundEffects.fG; -+ return this.do_() ? SoundEffects.fH : SoundEffects.fG; - } - - protected void i() { @@ -112,7 +116,7 @@ this.datawatcher.set(EntityShulker.b, Optional.of(new BlockPosition(i, j, k))); @@ -67,21 +40,3 @@ break; } } -@@ -390,7 +403,7 @@ - } - - public boolean damageEntity(DamageSource damagesource, float f) { -- if (this.do()) { -+ if (this.do_()) { - Entity entity = damagesource.i(); - - if (entity instanceof EntityArrow) { -@@ -409,7 +422,7 @@ - } - } - -- private boolean do() { -+ private boolean do_() { - return this.dj() == 0; - } - diff --git a/nms-patches/EntitySkeletonAbstract.patch b/nms-patches/EntitySkeletonAbstract.patch index db96e176..424cca7c 100644 --- a/nms-patches/EntitySkeletonAbstract.patch +++ b/nms-patches/EntitySkeletonAbstract.patch @@ -9,12 +9,12 @@ public abstract class EntitySkeletonAbstract extends EntityMonster implements IRangedEntity { private static final DataWatcherObject<Boolean> a = DataWatcher.a(EntitySkeletonAbstract.class, DataWatcherRegistry.h); - private final PathfinderGoalBowShoot b = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F); + private final PathfinderGoalBowShoot<EntitySkeletonAbstract> b = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F); - private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, flag) { + private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, false) { // CraftBukkit - decompile error public void d() { super.d(); - EntitySkeletonAbstract.this.a(false); + EntitySkeletonAbstract.this.p(false); @@ -80,7 +81,14 @@ } @@ -31,24 +31,7 @@ } } } -@@ -99,7 +107,7 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // CraftBukkit - if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) damagesource.getEntity(); - double d0 = entityhuman.locX - this.locX; -@@ -109,6 +117,7 @@ - entityhuman.b((Statistic) AchievementList.v); - } - } -+ super.die(damagesource); // CraftBukkit - moved from above - - } - -@@ -166,8 +175,19 @@ +@@ -152,8 +160,19 @@ double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4)); @@ -63,7 +46,7 @@ + world.addEntity(entityarrow); + } + // CraftBukkit end - this.a(SoundEffects.fV, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); + this.a(SoundEffects.gW, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); - this.world.addEntity(entityarrow); + // this.world.addEntity(entityarrow); // CraftBukkit - moved up } diff --git a/nms-patches/EntitySlice.patch b/nms-patches/EntitySlice.patch index 3f381048..2efa923f 100644 --- a/nms-patches/EntitySlice.patch +++ b/nms-patches/EntitySlice.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySlice.java +++ b/net/minecraft/server/EntitySlice.java -@@ -12,7 +12,7 @@ +@@ -13,7 +13,7 @@ public class EntitySlice<T> extends AbstractSet<T> { @@ -9,7 +9,7 @@ private final Map<Class<?>, List<T>> b = Maps.newHashMap(); private final Set<Class<?>> c = Sets.newIdentityHashSet(); private final Class<T> d; -@@ -40,7 +40,7 @@ +@@ -41,7 +41,7 @@ Object object = iterator.next(); if (oclass.isAssignableFrom(object.getClass())) { @@ -18,7 +18,7 @@ } } -@@ -77,7 +77,7 @@ +@@ -78,7 +78,7 @@ List list = (List) this.b.get(oclass); if (list == null) { @@ -27,12 +27,3 @@ } else { list.add(t0); } -@@ -125,7 +125,7 @@ - } - - public Iterator<T> iterator() { -- return this.e.isEmpty() ? Iterators.emptyIterator() : Iterators.unmodifiableIterator(this.e.iterator()); -+ return this.e.isEmpty() ? Iterators.<T>emptyIterator() : Iterators.unmodifiableIterator(this.e.iterator()); - } - - public int size() { diff --git a/nms-patches/EntityTNTPrimed.patch b/nms-patches/EntityTNTPrimed.patch index 37d5ae34..0836702c 100644 --- a/nms-patches/EntityTNTPrimed.patch +++ b/nms-patches/EntityTNTPrimed.patch @@ -17,7 +17,7 @@ public EntityTNTPrimed(World world) { super(world); -@@ -63,10 +66,13 @@ +@@ -64,10 +67,13 @@ --this.c; if (this.c <= 0) { @@ -30,9 +30,9 @@ + this.die(); + // CraftBukkit end } else { - this.ak(); + this.aq(); this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); -@@ -75,9 +81,17 @@ +@@ -76,9 +82,17 @@ } private void explode() { diff --git a/nms-patches/EntityTippedArrow.patch b/nms-patches/EntityTippedArrow.patch index 83722039..12e28241 100644 --- a/nms-patches/EntityTippedArrow.patch +++ b/nms-patches/EntityTippedArrow.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/server/EntityTippedArrow.java +++ b/net/minecraft/server/EntityTippedArrow.java -@@ -116,11 +116,30 @@ +@@ -116,6 +116,25 @@ } } -- public int o() { + // CraftBukkit start accessor methods + public void refreshEffects() { + this.getDataWatcher().set(EntityTippedArrow.f, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); @@ -24,12 +23,6 @@ + } + // CraftBukkit end + -+ public int o() { // PAIL: rename getColor + public int getColor() { return ((Integer) this.datawatcher.get(EntityTippedArrow.f)).intValue(); } - -- private void d(int i) { -+ public void d(int i) { // PAIL: private -> public, rename setColor - this.at = true; - this.datawatcher.set(EntityTippedArrow.f, Integer.valueOf(i)); - } diff --git a/nms-patches/EntityVillager.patch b/nms-patches/EntityVillager.patch index 697cdc03..fa7f585a 100644 --- a/nms-patches/EntityVillager.patch +++ b/nms-patches/EntityVillager.patch @@ -15,7 +15,7 @@ public class EntityVillager extends EntityAgeable implements NPC, IMerchant { -@@ -36,7 +44,7 @@ +@@ -37,7 +45,7 @@ public EntityVillager(World world, int i) { super(world); @@ -24,7 +24,7 @@ this.setProfession(i); this.setSize(0.6F, 1.95F); ((Navigation) this.getNavigation()).a(true); -@@ -118,7 +126,14 @@ +@@ -119,7 +127,14 @@ MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); if (merchantrecipe.h()) { @@ -40,7 +40,7 @@ } } -@@ -454,7 +469,20 @@ +@@ -460,7 +475,20 @@ for (int l = 0; l < k; ++l) { EntityVillager.IMerchantRecipeOption entityvillager_imerchantrecipeoption = aentityvillager_imerchantrecipeoption3[l]; diff --git a/nms-patches/EntityWither.patch b/nms-patches/EntityWither.patch index 10c3e64d..909781c9 100644 --- a/nms-patches/EntityWither.patch +++ b/nms-patches/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityWither.java +++ b/net/minecraft/server/EntityWither.java -@@ -6,6 +6,12 @@ +@@ -5,6 +5,12 @@ import java.util.List; import javax.annotation.Nullable; @@ -13,9 +13,9 @@ public class EntityWither extends EntityMonster implements IRangedEntity { private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b); -@@ -193,13 +199,38 @@ - if (this.dh() > 0) { - i = this.dh() - 1; +@@ -192,13 +198,38 @@ + if (this.dk() > 0) { + i = this.dk() - 1; if (i <= 0) { - this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); - this.world.a(1023, new BlockPosition(this), 0); @@ -55,7 +55,7 @@ } } else { -@@ -290,6 +321,11 @@ +@@ -289,6 +320,11 @@ Block block = iblockdata.getBlock(); if (iblockdata.getMaterial() != Material.AIR && a(block)) { @@ -67,7 +67,7 @@ flag = this.world.setAir(blockposition, true) || flag; } } -@@ -303,7 +339,7 @@ +@@ -302,7 +338,7 @@ } if (this.ticksLived % 20 == 0) { @@ -75,4 +75,4 @@ + this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit } - this.bF.setProgress(this.getHealth() / this.getMaxHealth()); + this.bG.setProgress(this.getHealth() / this.getMaxHealth()); diff --git a/nms-patches/EntityWolf.patch b/nms-patches/EntityWolf.patch index 85f3026f..3631a7a5 100644 --- a/nms-patches/EntityWolf.patch +++ b/nms-patches/EntityWolf.patch @@ -60,25 +60,25 @@ @@ -266,7 +288,7 @@ this.goalSit.setSitting(!this.isSitting()); this.bd = false; - this.navigation.o(); + this.navigation.p(); - this.setGoalTarget((EntityLiving) null); + this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason } } else if (itemstack.getItem() == Items.BONE && !this.isAngry()) { if (!entityhuman.abilities.canInstantlyBuild) { -@@ -274,12 +296,14 @@ +@@ -274,12 +296,13 @@ } if (!this.world.isClientSide) { - if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check. + if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { - this.setTamed(true); - this.navigation.o(); + this.c(entityhuman); + this.navigation.p(); this.setGoalTarget((EntityLiving) null); this.goalSit.setSitting(true); - this.setHealth(20.0F); +- this.setHealth(20.0F); + this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() - this.setOwnerUUID(entityhuman.getUniqueID()); this.p(true); this.world.broadcastEntityEffect(this, (byte) 7); + } else { diff --git a/nms-patches/EntityZombieVillager.patch b/nms-patches/EntityZombieVillager.patch index 776cdba1..e8b6e11d 100644 --- a/nms-patches/EntityZombieVillager.patch +++ b/nms-patches/EntityZombieVillager.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/EntityZombieVillager.java +++ b/net/minecraft/server/EntityZombieVillager.java -@@ -7,6 +7,7 @@ - private static final DataWatcherObject<Boolean> b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.h); +@@ -9,6 +9,7 @@ private static final DataWatcherObject<Integer> c = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b); private int conversionTime; + private UUID by; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(World world) { super(world); -@@ -54,6 +55,11 @@ - public void A_() { +@@ -60,6 +61,11 @@ + public void B_() { if (!this.world.isClientSide && this.isConverting()) { - int i = this.dq(); + int i = this.ds(); + // CraftBukkit start - Use wall time instead of ticks for villager conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + this.lastTick = MinecraftServer.currentTick; @@ -20,12 +20,12 @@ this.conversionTime -= i; if (this.conversionTime <= 0) { -@@ -116,7 +122,7 @@ +@@ -123,7 +129,7 @@ entityvillager.setCustomNameVisible(this.getCustomNameVisible()); } - this.world.addEntity(entityvillager); + this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason - entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); - this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0); - } + EntityHuman entityhuman = this.world.b(this.by); + + if (entityhuman instanceof EntityPlayer) { diff --git a/nms-patches/FoodMetaData.patch b/nms-patches/FoodMetaData.patch index 8037db1f..a83f70c2 100644 --- a/nms-patches/FoodMetaData.patch +++ b/nms-patches/FoodMetaData.patch @@ -64,7 +64,7 @@ this.a(f); this.foodTickTimer = 0; } - } else if (flag && this.foodLevel >= 18 && entityhuman.db()) { + } else if (flag && this.foodLevel >= 18 && entityhuman.dh()) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { - entityhuman.heal(1.0F); diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch index ea264a63..9d05ff87 100644 --- a/nms-patches/HandshakeListener.patch +++ b/nms-patches/HandshakeListener.patch @@ -57,8 +57,8 @@ + } + // CraftBukkit end + - if (packethandshakinginsetprotocol.b() > 316) { - chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.11.2"); + if (packethandshakinginsetprotocol.b() > 329) { + chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.12-pre2"); this.b.sendPacket(new PacketLoginOutDisconnect(chatcomponenttext)); @@ -26,6 +71,7 @@ this.b.close(chatcomponenttext); diff --git a/nms-patches/IRecipe.patch b/nms-patches/IRecipe.patch index bf22eb6d..d4840d72 100644 --- a/nms-patches/IRecipe.patch +++ b/nms-patches/IRecipe.patch @@ -1,9 +1,13 @@ --- a/net/minecraft/server/IRecipe.java +++ b/net/minecraft/server/IRecipe.java -@@ -11,4 +11,6 @@ - ItemStack b(); +@@ -28,7 +28,9 @@ + return ((MinecraftKey) CraftingManager.recipes.b(this)).a((MinecraftKey) CraftingManager.recipes.b(irecipe)); + } - NonNullList<ItemStack> b(InventoryCrafting inventorycrafting); +- public int compareTo(Object object) { ++ public int compareTo(IRecipe object) { // CraftBukkit = decompile error + return this.a((IRecipe) object); + } + -+ org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit ++ public abstract org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit } diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch index 3a400769..70c8e7f1 100644 --- a/nms-patches/InventoryCraftResult.patch +++ b/nms-patches/InventoryCraftResult.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/InventoryCraftResult.java +++ b/net/minecraft/server/InventoryCraftResult.java -@@ -1,11 +1,44 @@ - package net.minecraft.server; +@@ -2,12 +2,45 @@ import java.util.Iterator; + import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; @@ -13,6 +13,7 @@ public class InventoryCraftResult implements IInventory { private final NonNullList<ItemStack> items; + private IRecipe b; + // CraftBukkit start + private int maxStack = MAX_STACK; @@ -45,7 +46,7 @@ public InventoryCraftResult() { this.items = NonNullList.a(1, ItemStack.a); } -@@ -59,7 +92,7 @@ +@@ -61,7 +94,7 @@ } public int getMaxStackSize() { diff --git a/nms-patches/InventoryCrafting.patch b/nms-patches/InventoryCrafting.patch index 97079fa2..3ddb4a1c 100644 --- a/nms-patches/InventoryCrafting.patch +++ b/nms-patches/InventoryCrafting.patch @@ -17,7 +17,7 @@ @@ -9,6 +17,53 @@ private final int c; - private final Container d; + public final Container container; + // CraftBukkit start - add fields + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); @@ -68,4 +68,4 @@ + public InventoryCrafting(Container container, int i, int j) { this.items = NonNullList.a(i * j, ItemStack.a); - this.d = container; + this.container = container; diff --git a/nms-patches/ItemBlock.patch b/nms-patches/ItemBlock.patch index 34d35aaa..859afa28 100644 --- a/nms-patches/ItemBlock.patch +++ b/nms-patches/ItemBlock.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemBlock.java +++ b/net/minecraft/server/ItemBlock.java -@@ -33,7 +33,7 @@ +@@ -36,7 +36,7 @@ SoundEffectType soundeffecttype = this.a.getStepSound(); diff --git a/nms-patches/ItemBucket.patch b/nms-patches/ItemBucket.patch index e486ce13..31987d2d 100644 --- a/nms-patches/ItemBucket.patch +++ b/nms-patches/ItemBucket.patch @@ -26,7 +26,7 @@ + // CraftBukkit end world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11); entityhuman.b(StatisticList.b((Item) this)); - entityhuman.a(SoundEffects.P, 1.0F, 1.0F); + entityhuman.a(SoundEffects.S, 1.0F, 1.0F); - return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.WATER_BUCKET)); + return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.WATER_BUCKET, event.getItemStack())); // CraftBukkit } else if (material == Material.LAVA && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) { @@ -37,7 +37,7 @@ + return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); + } + // CraftBukkit end - entityhuman.a(SoundEffects.Q, 1.0F, 1.0F); + entityhuman.a(SoundEffects.T, 1.0F, 1.0F); world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11); entityhuman.b(StatisticList.b((Item) this)); - return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.LAVA_BUCKET)); @@ -51,10 +51,10 @@ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); - } else if (this.a(entityhuman, world, blockposition1)) { + } else if (this.a(entityhuman, world, blockposition1, movingobjectposition.direction, blockposition, itemstack)) { // CraftBukkit - entityhuman.b(StatisticList.b((Item) this)); - return !entityhuman.abilities.canInstantlyBuild ? new InteractionResultWrapper(EnumInteractionResult.SUCCESS, new ItemStack(Items.BUCKET)) : new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack); - } else { -@@ -63,16 +83,19 @@ + if (entityhuman instanceof EntityPlayer) { + CriterionTriggers.x.a((EntityPlayer) entityhuman, blockposition, itemstack); + } +@@ -67,16 +87,19 @@ } } @@ -78,7 +78,7 @@ } return itemstack; -@@ -80,7 +103,13 @@ +@@ -84,7 +107,13 @@ } } @@ -92,7 +92,7 @@ if (this.a == Blocks.AIR) { return false; } else { -@@ -92,6 +121,15 @@ +@@ -96,6 +125,15 @@ if (!world.isEmpty(blockposition) && !flag && !flag1) { return false; } else { diff --git a/nms-patches/ItemChorusFruit.patch b/nms-patches/ItemChorusFruit.patch index 2e175882..c05c10b5 100644 --- a/nms-patches/ItemChorusFruit.patch +++ b/nms-patches/ItemChorusFruit.patch @@ -13,7 +13,7 @@ public ItemChorusFruit(int i, float f) { @@ -19,6 +25,20 @@ - double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.Z() - 1)); + double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.ab() - 1)); double d5 = entityliving.locZ + (entityliving.getRandom().nextDouble() - 0.5D) * 16.0D; + // CraftBukkit start diff --git a/nms-patches/ItemCooldown.patch b/nms-patches/ItemCooldown.patch deleted file mode 100644 index 8925a837..00000000 --- a/nms-patches/ItemCooldown.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/server/ItemCooldown.java -+++ b/net/minecraft/server/ItemCooldown.java -@@ -7,8 +7,8 @@ - - public class ItemCooldown { - -- private final Map<Item, ItemCooldown.Info> a = Maps.newHashMap(); -- private int b; -+ public final Map<Item, ItemCooldown.Info> a = Maps.newHashMap(); // PAIL: private->public -+ public int b; // PAIL: currentTick, private->public - - public ItemCooldown() {} - -@@ -55,10 +55,10 @@ - - protected void c(Item item) {} - -- class Info { -+ public class Info { // PAIL: private->public - - final int a; -- final int b; -+ public final int b; // PAIL: endTick, private->public - - private Info(int i, int j) { - this.a = i; diff --git a/nms-patches/ItemEnderPearl.patch b/nms-patches/ItemEnderPearl.patch index 72c19dab..ea00f572 100644 --- a/nms-patches/ItemEnderPearl.patch +++ b/nms-patches/ItemEnderPearl.patch @@ -21,8 +21,8 @@ itemstack.subtract(1); } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.bj, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.j.nextFloat() * 0.4F + 0.8F)); - entityhuman.di().a(this, 20); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.bn, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.j.nextFloat() * 0.4F + 0.8F)); + entityhuman.getCooldownTracker().a(this, 20); - if (!world.isClientSide) { - EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); - diff --git a/nms-patches/ItemFireball.patch b/nms-patches/ItemFireball.patch index f60e3955..aa84efa1 100644 --- a/nms-patches/ItemFireball.patch +++ b/nms-patches/ItemFireball.patch @@ -12,6 +12,6 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.bx, SoundCategory.BLOCKS, 1.0F, (ItemFireball.j.nextFloat() - ItemFireball.j.nextFloat()) * 0.2F + 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.bD, SoundCategory.BLOCKS, 1.0F, (ItemFireball.j.nextFloat() - ItemFireball.j.nextFloat()) * 0.2F + 1.0F); world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); } diff --git a/nms-patches/ItemFishingRod.patch b/nms-patches/ItemFishingRod.patch index fb2f9fbd..ca728962 100644 --- a/nms-patches/ItemFishingRod.patch +++ b/nms-patches/ItemFishingRod.patch @@ -8,16 +8,17 @@ public class ItemFishingRod extends Item { public ItemFishingRod() { -@@ -19,7 +21,6 @@ - itemstack.damage(i, entityhuman); +@@ -20,7 +22,7 @@ entityhuman.a(enumhand); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.J, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); } else { -- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.I, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); +- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); ++ // world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down if (!world.isClientSide) { EntityFishingHook entityfishinghook = new EntityFishingHook(world, entityhuman); int j = EnchantmentManager.c(itemstack); -@@ -34,6 +35,17 @@ - entityfishinghook.b(k); +@@ -35,6 +37,17 @@ + entityfishinghook.c(k); } + // CraftBukkit start @@ -28,7 +29,7 @@ + entityhuman.hookedFish = null; + return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); + } -+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.I, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); ++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); + // CraftBukkit end + world.addEntity(entityfishinghook); diff --git a/nms-patches/ItemFlintAndSteel.patch b/nms-patches/ItemFlintAndSteel.patch index bd5b2aa3..7442ab6f 100644 --- a/nms-patches/ItemFlintAndSteel.patch +++ b/nms-patches/ItemFlintAndSteel.patch @@ -10,6 +10,6 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.a(entityhuman, blockposition, SoundEffects.bI, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.j.nextFloat() * 0.4F + 0.8F); + world.a(entityhuman, blockposition, SoundEffects.bO, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.j.nextFloat() * 0.4F + 0.8F); world.setTypeAndData(blockposition, Blocks.FIRE.getBlockData(), 11); } diff --git a/nms-patches/ItemHanging.patch b/nms-patches/ItemHanging.patch index 89b547f8..f6826f00 100644 --- a/nms-patches/ItemHanging.patch +++ b/nms-patches/ItemHanging.patch @@ -27,6 +27,6 @@ + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - entityhanging.o(); + entityhanging.p(); world.addEntity(entityhanging); } diff --git a/nms-patches/ItemSnowball.patch b/nms-patches/ItemSnowball.patch index 64293dcc..77d48395 100644 --- a/nms-patches/ItemSnowball.patch +++ b/nms-patches/ItemSnowball.patch @@ -10,7 +10,7 @@ itemstack.subtract(1); } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.go, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.hp, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); + */ if (!world.isClientSide) { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); @@ -22,7 +22,7 @@ + itemstack.subtract(1); + } + -+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.go, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); ++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.hp, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); + } else if (entityhuman instanceof EntityPlayer) { + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch index 0d778c71..a2944084 100644 --- a/nms-patches/ItemStack.patch +++ b/nms-patches/ItemStack.patch @@ -20,7 +20,7 @@ public final class ItemStack { public static final ItemStack a = new ItemStack((Item) null); -@@ -42,32 +55,68 @@ +@@ -42,32 +55,74 @@ this(item, i, 0); } @@ -53,9 +53,15 @@ + // Called to run this stack through the data converter to handle older storage methods and serialized items + public void convertStack() { + if (MinecraftServer.getServer() != null) { ++ // Don't convert beds - both the old and new data values are valid ++ // Conversion would make getting white beds (data value 0) impossible ++ if (this.item == Items.BED) { ++ return; ++ } ++ + NBTTagCompound savedStack = new NBTTagCompound(); + this.save(savedStack); -+ MinecraftServer.getServer().getDataConverterManager().a(DataConverterTypes.ITEM_INSTANCE, savedStack); // PAIL: convert ++ MinecraftServer.getServer().dataConverterManager.a(DataConverterTypes.ITEM_INSTANCE, savedStack); // PAIL: convert + this.load(savedStack); + } + } @@ -94,7 +100,7 @@ this.F(); } -@@ -94,11 +143,138 @@ +@@ -94,11 +149,138 @@ } public EnumInteractionResult placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { @@ -234,7 +240,7 @@ return enuminteractionresult; } -@@ -122,7 +298,7 @@ +@@ -122,7 +304,7 @@ nbttagcompound.setByte("Count", (byte) this.count); nbttagcompound.setShort("Damage", (short) this.damage); if (this.tag != null) { @@ -243,7 +249,7 @@ } return nbttagcompound; -@@ -157,11 +333,30 @@ +@@ -157,11 +339,30 @@ } public void setData(int i) { @@ -276,9 +282,9 @@ } public int k() { -@@ -198,6 +393,11 @@ +@@ -202,6 +403,11 @@ if (this.f()) { - if (this.isDamaged(i, entityliving.getRandom())) { + if (this.isDamaged(i, entityliving.getRandom(), entityliving instanceof EntityPlayer ? (EntityPlayer) entityliving : null)) { entityliving.b(this); + // CraftBukkit start - Check for item breaking + if (this.count == 1 && entityliving instanceof EntityHuman) { @@ -288,16 +294,16 @@ this.subtract(1); if (entityliving instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entityliving; -@@ -239,7 +439,7 @@ +@@ -243,7 +449,7 @@ } public ItemStack cloneItemStack() { - ItemStack itemstack = new ItemStack(this.item, this.count, this.damage); + ItemStack itemstack = new ItemStack(this.item, this.count, this.damage, false); // CraftBukkit + itemstack.d(this.D()); if (this.tag != null) { - itemstack.tag = this.tag.g(); -@@ -509,6 +709,12 @@ +@@ -514,6 +720,12 @@ nbttaglist.add(nbttagcompound); } diff --git a/nms-patches/JsonList.patch b/nms-patches/JsonList.patch index adca302a..9af5b05c 100644 --- a/nms-patches/JsonList.patch +++ b/nms-patches/JsonList.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/JsonList.java +++ b/net/minecraft/server/JsonList.java -@@ -83,7 +83,7 @@ +@@ -84,7 +84,7 @@ public V get(K k0) { this.h(); @@ -9,7 +9,7 @@ } public void remove(K k0) { -@@ -101,6 +101,12 @@ +@@ -102,6 +102,12 @@ return (String[]) this.d.keySet().toArray(new String[this.d.size()]); } @@ -22,7 +22,7 @@ public boolean isEmpty() { return this.d.size() < 1; } -@@ -176,7 +182,7 @@ +@@ -177,7 +183,7 @@ JsonListEntry jsonlistentry = (JsonListEntry) iterator.next(); if (jsonlistentry.getKey() != null) { @@ -31,7 +31,7 @@ } } } -@@ -204,11 +210,11 @@ +@@ -205,11 +211,11 @@ } } diff --git a/nms-patches/LoginListener.patch b/nms-patches/LoginListener.patch index ceee1d4e..795b5424 100644 --- a/nms-patches/LoginListener.patch +++ b/nms-patches/LoginListener.patch @@ -99,7 +99,7 @@ + } + } + // CraftBukkit end - LoginListener.c.info("UUID of player {} is {}", new Object[] { LoginListener.this.i.getName(), LoginListener.this.i.getId()}); + LoginListener.c.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId()); LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT; } else if (LoginListener.this.server.R()) { @@ -171,6 +217,11 @@ diff --git a/nms-patches/MethodProfiler.patch b/nms-patches/MethodProfiler.patch index 9c9108ff..883f9d9a 100644 --- a/nms-patches/MethodProfiler.patch +++ b/nms-patches/MethodProfiler.patch @@ -21,7 +21,7 @@ public void a(String s) { + if (!ENABLED) return; // CraftBukkit if (this.a) { - if (this.e.length() > 0) { + if (!this.e.isEmpty()) { this.e = this.e + "."; @@ -40,6 +43,7 @@ } @@ -51,7 +51,7 @@ public String c() { + if (!ENABLED) return "[DISABLED]"; // CraftBukkit - return this.c.size() == 0 ? "[UNKNOWN]" : (String) this.c.get(this.c.size() - 1); + return this.c.isEmpty() ? "[UNKNOWN]" : (String) this.c.get(this.c.size() - 1); } @@ -152,7 +158,7 @@ diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index 9806f0f7..664f9ded 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -12,7 +12,7 @@ +import org.bukkit.craftbukkit.Main; +// CraftBukkit end - public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics { + public abstract class MinecraftServer implements ICommandListener, Runnable, IAsyncTaskHandler, IMojangStatistics { @@ -97,19 +104,61 @@ private Thread serverThread; @@ -343,7 +343,7 @@ if (k > 2000L && this.ab - this.R >= 15000L) { + if (server.getWarnOnOverload()) // CraftBukkit - MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)}); + MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", Long.valueOf(k), Long.valueOf(k / 50L)); k = 2000L; this.R = this.ab; @@ -385,11 +544,12 @@ @@ -453,7 +453,7 @@ } this.methodProfiler.c("connection"); -@@ -597,10 +782,11 @@ +@@ -599,10 +784,11 @@ this.o.add(itickable); } @@ -466,7 +466,7 @@ boolean flag = true; String s = null; String s1 = "."; -@@ -645,13 +831,16 @@ +@@ -647,13 +833,16 @@ ++j; } } @@ -484,7 +484,7 @@ if (s != null) { dedicatedserver.i(s); } -@@ -682,6 +871,25 @@ +@@ -684,6 +873,25 @@ dedicatedserver.stop(); } }); @@ -510,7 +510,7 @@ } catch (Exception exception) { MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); } -@@ -689,8 +897,10 @@ +@@ -691,8 +899,10 @@ } public void F() { @@ -521,7 +521,7 @@ } public File d(String s) { -@@ -706,7 +916,14 @@ +@@ -708,7 +918,14 @@ } public WorldServer getWorldServer(int i) { @@ -537,7 +537,7 @@ } public String getVersion() { -@@ -730,7 +947,7 @@ +@@ -732,7 +949,7 @@ } public boolean isDebugging() { @@ -546,7 +546,7 @@ } public void g(String s) { -@@ -745,7 +962,7 @@ +@@ -747,7 +964,7 @@ } public String getServerModName() { @@ -555,7 +555,7 @@ } public CrashReport b(CrashReport crashreport) { -@@ -774,6 +991,7 @@ +@@ -776,6 +993,7 @@ } public List<String> tabCompleteCommand(ICommandListener icommandlistener, String s, @Nullable BlockPosition blockposition, boolean flag) { @@ -563,7 +563,7 @@ ArrayList arraylist = Lists.newArrayList(); boolean flag1 = s.startsWith("/"); -@@ -816,10 +1034,13 @@ +@@ -818,10 +1036,13 @@ return arraylist; } @@ -578,7 +578,7 @@ } public String getName() { -@@ -875,11 +1096,13 @@ +@@ -877,11 +1098,13 @@ } public void a(EnumDifficulty enumdifficulty) { @@ -595,7 +595,7 @@ if (worldserver != null) { if (worldserver.getWorldData().isHardcore()) { -@@ -946,13 +1169,11 @@ +@@ -948,13 +1171,11 @@ int i = 0; if (this.worldServer != null) { @@ -613,7 +613,7 @@ WorldData worlddata = worldserver.getWorldData(); mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimensionManager().getDimensionID())); -@@ -985,7 +1206,7 @@ +@@ -987,7 +1208,7 @@ public abstract boolean aa(); public boolean getOnlineMode() { @@ -622,7 +622,7 @@ } public void setOnlineMode(boolean flag) { -@@ -1065,13 +1286,9 @@ +@@ -1067,13 +1288,9 @@ } public void setGamemode(EnumGamemode enumgamemode) { @@ -639,7 +639,7 @@ } } -@@ -1103,7 +1320,7 @@ +@@ -1097,7 +1314,7 @@ } public World getWorld() { @@ -647,8 +647,8 @@ + return this.worlds.get(0); // CraftBukkit } - public Entity f() { -@@ -1175,8 +1392,10 @@ + public int getSpawnProtection() { +@@ -1157,8 +1374,10 @@ WorldServer[] aworldserver = this.worldServer; int i = aworldserver.length; @@ -661,7 +661,7 @@ if (worldserver != null) { Entity entity = worldserver.getEntity(uuid); -@@ -1191,7 +1410,7 @@ +@@ -1173,7 +1392,7 @@ } public boolean getSendCommandFeedback() { @@ -669,8 +669,8 @@ + return worlds.get(0).getGameRules().getBoolean("sendCommandFeedback"); } - public void a(CommandObjectiveExecutor.EnumCommandResult commandobjectiveexecutor_enumcommandresult, int i) {} -@@ -1206,7 +1425,7 @@ + public MinecraftServer C_() { +@@ -1186,7 +1405,7 @@ public <V> ListenableFuture<V> a(Callable<V> callable) { Validate.notNull(callable); @@ -679,9 +679,32 @@ ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable); Queue queue = this.j; -@@ -1251,4 +1470,11 @@ - public int a(@Nullable WorldServer worldserver) { - return worldserver != null ? worldserver.getGameRules().c("spawnRadius") : 10; +@@ -1229,23 +1448,30 @@ + } + + public AdvancementDataWorld getAdvancementData() { +- return this.worldServer[0].z(); ++ return this.worlds.get(0).z(); // CraftBukkit + } + + public CustomFunctionData aL() { +- return this.worldServer[0].A(); ++ return this.worlds.get(0).A(); // CraftBukkit + } + + public void reload() { + if (this.isMainThread()) { + this.getPlayerList().savePlayers(); +- this.worldServer[0].getLootTableRegistry().reload(); ++ this.worlds.get(0).getLootTableRegistry().reload(); // CraftBukkit + this.getAdvancementData().reload(); + this.aL().f(); + this.getPlayerList().reload(); + } else { +- this.postToMainThread(run<invokedynamic>(this)); ++ this.postToMainThread(() -> reload()); // CraftBukkit - decompile error + } + } + + // CraftBukkit start diff --git a/nms-patches/MobEffectList.patch b/nms-patches/MobEffectList.patch index c7556e15..ea421e5b 100644 --- a/nms-patches/MobEffectList.patch +++ b/nms-patches/MobEffectList.patch @@ -53,8 +53,8 @@ + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end } - } else if ((this != MobEffects.HEAL || entityliving.bT()) && (this != MobEffects.HARM || !entityliving.bT())) { - if (this == MobEffects.HARM && !entityliving.bT() || this == MobEffects.HEAL && entityliving.bT()) { + } else if ((this != MobEffects.HEAL || entityliving.ca()) && (this != MobEffects.HARM || !entityliving.ca())) { + if (this == MobEffects.HARM && !entityliving.ca() || this == MobEffects.HEAL && entityliving.ca()) { entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); } } else { @@ -74,8 +74,8 @@ } @@ -208,5 +224,10 @@ MobEffectList.REGISTRY.a(25, new MinecraftKey("levitation"), (new MobEffectList(true, 13565951)).c("effect.levitation").b(3, 2)); - MobEffectList.REGISTRY.a(26, new MinecraftKey("luck"), (new MobEffectList(false, 3381504)).c("effect.luck").b(5, 2).j().a(GenericAttributes.i, "03C3C89D-7037-4B42-869F-B146BCB64D2E", 1.0D, 0)); - MobEffectList.REGISTRY.a(27, new MinecraftKey("unluck"), (new MobEffectList(true, 12624973)).c("effect.unluck").b(6, 2).a(GenericAttributes.i, "CC5AF142-2BD2-4215-B636-2605AED11727", -1.0D, 0)); + MobEffectList.REGISTRY.a(26, new MinecraftKey("luck"), (new MobEffectList(false, 3381504)).c("effect.luck").b(5, 2).j().a(GenericAttributes.j, "03C3C89D-7037-4B42-869F-B146BCB64D2E", 1.0D, 0)); + MobEffectList.REGISTRY.a(27, new MinecraftKey("unluck"), (new MobEffectList(true, 12624973)).c("effect.unluck").b(6, 2).a(GenericAttributes.j, "CC5AF142-2BD2-4215-B636-2605AED11727", -1.0D, 0)); + // CraftBukkit start + for (Object effect : REGISTRY) { + org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType((MobEffectList) effect)); diff --git a/nms-patches/NameReferencingFileConverter.patch b/nms-patches/NameReferencingFileConverter.patch index b591ecbb..c7bd0f7e 100644 --- a/nms-patches/NameReferencingFileConverter.patch +++ b/nms-patches/NameReferencingFileConverter.patch @@ -5,10 +5,10 @@ try { gameprofilebanlist.load(); - } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { gameprofilebanlist.c().getName(), filenotfoundexception}); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace +- NameReferencingFileConverter.e.warn("Could not load existing file {}", gameprofilebanlist.c().getName(), filenotfoundexception); ++ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace + } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { gameprofilebanlist.c().getName()}); ++ NameReferencingFileConverter.e.warn("Could not load existing file {}", gameprofilebanlist.c().getName()); } } @@ -17,10 +17,10 @@ try { ipbanlist.load(); - } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { ipbanlist.c().getName(), filenotfoundexception}); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace +- NameReferencingFileConverter.e.warn("Could not load existing file {}", ipbanlist.c().getName(), filenotfoundexception); ++ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace + } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { ipbanlist.c().getName()}); ++ NameReferencingFileConverter.e.warn("Could not load existing file {}", ipbanlist.c().getName()); } } @@ -29,10 +29,10 @@ try { oplist.load(); - } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { oplist.c().getName(), filenotfoundexception}); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace +- NameReferencingFileConverter.e.warn("Could not load existing file {}", oplist.c().getName(), filenotfoundexception); ++ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace + } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { oplist.c().getName()}); ++ NameReferencingFileConverter.e.warn("Could not load existing file {}", oplist.c().getName()); } } @@ -41,10 +41,10 @@ try { whitelist.load(); - } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { whitelist.c().getName(), filenotfoundexception}); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace +- NameReferencingFileConverter.e.warn("Could not load existing file {}", whitelist.c().getName(), filenotfoundexception); ++ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace + } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.e.warn("Could not load existing file {}", new Object[] { whitelist.c().getName()}); ++ NameReferencingFileConverter.e.warn("Could not load existing file {}", whitelist.c().getName()); } } diff --git a/nms-patches/NetworkManager.patch b/nms-patches/NetworkManager.patch index 2bb9e252..6e69467c 100644 --- a/nms-patches/NetworkManager.patch +++ b/nms-patches/NetworkManager.patch @@ -9,7 +9,7 @@ } catch (CancelledPacketHandleException cancelledpackethandleexception) { ; } -@@ -233,7 +233,7 @@ +@@ -236,7 +236,7 @@ public void close(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { @@ -18,7 +18,7 @@ this.n = ichatbasecomponent; } -@@ -310,7 +310,7 @@ +@@ -313,7 +313,7 @@ } } diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch index d257ef48..4348da94 100644 --- a/nms-patches/PacketDataSerializer.patch +++ b/nms-patches/PacketDataSerializer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PacketDataSerializer.java +++ b/net/minecraft/server/PacketDataSerializer.java -@@ -21,6 +21,8 @@ +@@ -23,6 +23,8 @@ import java.util.UUID; import javax.annotation.Nullable; @@ -9,7 +9,7 @@ public class PacketDataSerializer extends ByteBuf { private final ByteBuf a; -@@ -128,7 +130,7 @@ +@@ -130,7 +132,7 @@ } public <T extends Enum<T>> T a(Class<T> oclass) { @@ -18,7 +18,7 @@ } public PacketDataSerializer a(Enum<?> oenum) { -@@ -205,7 +207,7 @@ +@@ -207,7 +209,7 @@ } else { try { NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); @@ -27,7 +27,7 @@ throw new EncoderException(ioexception); } } -@@ -232,7 +234,7 @@ +@@ -234,7 +236,7 @@ } public PacketDataSerializer a(ItemStack itemstack) { @@ -36,7 +36,7 @@ this.writeShort(-1); } else { this.writeShort(Item.getId(itemstack.getItem())); -@@ -261,6 +263,11 @@ +@@ -263,6 +265,11 @@ ItemStack itemstack = new ItemStack(Item.getById(short0), b0, short1); itemstack.setTag(this.j()); diff --git a/nms-patches/PathfinderGoalBreed.patch b/nms-patches/PathfinderGoalBreed.patch index 1497ba99..2c169110 100644 --- a/nms-patches/PathfinderGoalBreed.patch +++ b/nms-patches/PathfinderGoalBreed.patch @@ -9,23 +9,23 @@ + entityageable.persistent = true; + } + // CraftBukkit end - EntityHuman entityhuman = this.animal.getBreedCause(); + EntityPlayer entityplayer = this.animal.getBreedCause(); - if (entityhuman == null && this.partner.getBreedCause() != null) { - entityhuman = this.partner.getBreedCause(); + if (entityplayer == null && this.partner.getBreedCause() != null) { + entityplayer = this.partner.getBreedCause(); } + // CraftBukkit start - call EntityBreedEvent + int experience = this.animal.getRandom().nextInt(7) + 1; -+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, animal, partner, entityhuman, this.animal.breedItem, experience); ++ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, animal, partner, entityplayer, this.animal.breedItem, experience); + if (entityBreedEvent.isCancelled()) { + return; + } + experience = entityBreedEvent.getExperience(); + // CraftBukkit end - if (entityhuman != null) { - entityhuman.b(StatisticList.C); -@@ -94,7 +107,7 @@ + if (entityplayer != null) { + entityplayer.b(StatisticList.C); +@@ -92,7 +105,7 @@ this.partner.resetLove(); entityageable.setAgeRaw(-24000); entityageable.setPositionRotation(this.animal.locX, this.animal.locY, this.animal.locZ, 0.0F, 0.0F); @@ -34,7 +34,7 @@ Random random = this.animal.getRandom(); for (int i = 0; i < 7; ++i) { -@@ -109,7 +122,11 @@ +@@ -107,7 +120,11 @@ } if (this.a.getGameRules().getBoolean("doMobLoot")) { diff --git a/nms-patches/PathfinderGoalFollowOwner.patch b/nms-patches/PathfinderGoalFollowOwner.patch index 4d9f8f16..64420ba5 100644 --- a/nms-patches/PathfinderGoalFollowOwner.patch +++ b/nms-patches/PathfinderGoalFollowOwner.patch @@ -15,7 +15,7 @@ @@ -79,7 +85,18 @@ for (int l = 0; l <= 4; ++l) { for (int i1 = 0; i1 <= 4; ++i1) { - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a.getType(new BlockPosition(i + l, k - 1, j + i1)).r() && this.a(new BlockPosition(i + l, k, j + i1)) && this.a(new BlockPosition(i + l, k + 1, j + i1))) { + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a(i, j, k, l, i1)) { - this.d.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.d.yaw, this.d.pitch); + // CraftBukkit start + CraftEntity entity = this.d.getBukkitEntity(); @@ -29,6 +29,6 @@ + + this.d.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + // CraftBukkit end - this.g.o(); + this.g.p(); return; } diff --git a/nms-patches/PathfinderGoalHorseTrap.patch b/nms-patches/PathfinderGoalHorseTrap.patch index 84842053..54cb52b0 100644 --- a/nms-patches/PathfinderGoalHorseTrap.patch +++ b/nms-patches/PathfinderGoalHorseTrap.patch @@ -18,7 +18,7 @@ } @@ -42,7 +43,7 @@ - entityhorseskeleton.cS(); + entityhorseskeleton.cU(); entityhorseskeleton.setTamed(true); entityhorseskeleton.setAgeRaw(0); - entityhorseskeleton.world.addEntity(entityhorseskeleton); diff --git a/nms-patches/PathfinderGoalHurtByTarget.patch b/nms-patches/PathfinderGoalHurtByTarget.patch index e0e2e610..97a47f7f 100644 --- a/nms-patches/PathfinderGoalHurtByTarget.patch +++ b/nms-patches/PathfinderGoalHurtByTarget.patch @@ -7,7 +7,7 @@ - this.e.setGoalTarget(this.e.getLastDamager()); + this.e.setGoalTarget(this.e.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason this.g = this.e.getGoalTarget(); - this.b = this.e.bL(); + this.b = this.e.bR(); this.h = 300; @@ -66,6 +66,6 @@ } diff --git a/nms-patches/PathfinderGoalPanic.patch b/nms-patches/PathfinderGoalPanic.patch index fa425967..f5990487 100644 --- a/nms-patches/PathfinderGoalPanic.patch +++ b/nms-patches/PathfinderGoalPanic.patch @@ -5,11 +5,11 @@ public boolean b() { + // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly -+ if ((this.b.ticksLived - this.b.hurtTimestamp) > 100) { -+ this.b.b((EntityLiving) null); ++ if ((this.a.ticksLived - this.a.hurtTimestamp) > 100) { ++ this.a.b((EntityLiving) null); + return false; + } + // CraftBukkit end - return !this.b.getNavigation().n(); + return !this.a.getNavigation().o(); } diff --git a/nms-patches/PathfinderGoalTempt.patch b/nms-patches/PathfinderGoalTempt.patch index df8f4dcb..e0574094 100644 --- a/nms-patches/PathfinderGoalTempt.patch +++ b/nms-patches/PathfinderGoalTempt.patch @@ -17,25 +17,24 @@ private double e; private double f; private double g; -- private EntityHuman h; -+ private EntityLiving h; // CraftBukkit +- private EntityHuman target; ++ private EntityLiving target; // CraftBukkit private int i; private boolean j; private final Set<Item> k; -@@ -39,7 +45,18 @@ +@@ -39,7 +45,17 @@ return false; } else { - this.h = this.a.world.findNearbyPlayer(this.a, 10.0D); -- return this.h == null ? false : this.a(this.h.getItemInMainHand()) || this.a(this.h.getItemInOffHand()); + this.target = this.a.world.findNearbyPlayer(this.a, 10.0D); +- return this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand()); + // CraftBukkit start -+ // PAIL: rename -+ boolean tempt = this.h == null ? false : this.a(this.h.getItemInMainHand()) || this.a(this.h.getItemInOffHand()); ++ boolean tempt = this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand()); + if (tempt) { -+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.a, this.h, EntityTargetEvent.TargetReason.TEMPT); ++ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.a, this.target, EntityTargetEvent.TargetReason.TEMPT); + if (event.isCancelled()) { + return false; + } -+ this.h = ((CraftLivingEntity) event.getTarget()).getHandle(); ++ this.target = ((CraftLivingEntity) event.getTarget()).getHandle(); + } + return tempt; + // CraftBukkit end diff --git a/nms-patches/PathfinderGoalVillagerFarm.patch b/nms-patches/PathfinderGoalVillagerFarm.patch index b24ce69b..542eba3d 100644 --- a/nms-patches/PathfinderGoalVillagerFarm.patch +++ b/nms-patches/PathfinderGoalVillagerFarm.patch @@ -11,7 +11,7 @@ + } + // CraftBukkit end } else if (this.f == 1 && iblockdata.getMaterial() == Material.AIR) { - InventorySubcontainer inventorysubcontainer = this.c.dm(); + InventorySubcontainer inventorysubcontainer = this.c.do_(); @@ -49,19 +53,28 @@ boolean flag = false; diff --git a/nms-patches/PlayerChunk.patch b/nms-patches/PlayerChunk.patch index b4387dda..2dc88641 100644 --- a/nms-patches/PlayerChunk.patch +++ b/nms-patches/PlayerChunk.patch @@ -51,7 +51,7 @@ - public void a(EntityPlayer entityplayer) { + public void a(final EntityPlayer entityplayer) { // CraftBukkit - added final to argument if (this.c.contains(entityplayer)) { - PlayerChunk.a.debug("Failed to add player. {} already is in chunk {}, {}", new Object[] { entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)}); + PlayerChunk.a.debug("Failed to add player. {} already is in chunk {}, {}", entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)); } else { @@ -42,15 +58,32 @@ } diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index e4b9ae11..c31a92b5 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -102,7 +102,7 @@ + private final static HashSet<Integer> invalidItems = new HashSet<Integer>(java.util.Arrays.asList(8, 9, 10, 11, 26, 34, 36, 43, 51, 55, 59, 62, 63, 64, 68, 71, 74, 75, 83, 90, 92, 93, 94, 104, 105, 115, 117, 118, 119, 125, 127, 132, 140, 141, 142, 144)); // TODO: Check after every update. + // CraftBukkit end - public void F_() { + public void e() { this.syncPosition(); @@ -109,15 +182,21 @@ } @@ -121,7 +121,7 @@ --this.j; } - if (this.player.I() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.aw() - this.player.I() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + if (this.player.J() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.aw() - this.player.J() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854 this.disconnect("You have been idle for too long!"); } @@ -212,7 +212,7 @@ + + if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[] { entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)}); + PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)); this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); return; @@ -226,6 +353,62 @@ @@ -278,7 +278,7 @@ this.minecraftServer.getPlayerList().d(this.player); this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2); this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.c(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -@@ -260,7 +443,7 @@ +@@ -271,7 +454,7 @@ } else { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); @@ -287,7 +287,7 @@ if (this.e == 0) { this.syncPosition(); } -@@ -270,13 +453,21 @@ +@@ -281,13 +464,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -310,7 +310,7 @@ double d0 = this.player.locX; double d1 = this.player.locY; double d2 = this.player.locZ; -@@ -301,15 +492,33 @@ +@@ -312,15 +503,33 @@ ++this.receivedMovePackets; int i = this.receivedMovePackets - this.processedMovePackets; @@ -321,7 +321,7 @@ + this.lastTick = (int) (System.currentTimeMillis() / 50); + + if (i > Math.max(this.allowedPlayerTicks, 5)) { - PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", new Object[] { this.player.getName(), Integer.valueOf(i)}); + PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName(), Integer.valueOf(i)); i = 1; } @@ -337,16 +337,16 @@ + speed = player.abilities.walkSpeed * 10f; + } + - if (!this.player.K() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cH())) { - float f2 = this.player.cH() ? 300.0F : 100.0F; + if (!this.player.L() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cN())) { + float f2 = this.player.cN() ? 300.0F : 100.0F; - if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) { + if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[] { this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)}); + PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)); this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch); return; -@@ -355,6 +564,69 @@ +@@ -366,6 +575,69 @@ } } @@ -415,8 +415,8 @@ + this.B = d12 >= -0.03125D; this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly; - this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cH() && !worldserver.c(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -@@ -372,10 +644,76 @@ + this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cN() && !worldserver.c(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); +@@ -383,10 +655,76 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -494,7 +494,7 @@ double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D; double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D; double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D; -@@ -392,6 +730,14 @@ +@@ -403,6 +741,14 @@ f3 = f1 + this.player.pitch; } @@ -509,7 +509,7 @@ if (++this.teleportAwait == Integer.MAX_VALUE) { this.teleportAwait = 0; } -@@ -403,6 +749,7 @@ +@@ -414,6 +760,7 @@ public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x()); @@ -517,7 +517,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinblockdig.a(); -@@ -412,7 +759,15 @@ +@@ -423,7 +770,15 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); @@ -534,7 +534,7 @@ this.player.a(EnumHand.MAIN_HAND, itemstack); } -@@ -420,6 +775,21 @@ +@@ -431,6 +786,21 @@ case DROP_ITEM: if (!this.player.isSpectator()) { @@ -556,7 +556,7 @@ this.player.a(false); } -@@ -453,7 +823,15 @@ +@@ -464,7 +834,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b()); } else { @@ -572,7 +572,7 @@ } } else { if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -473,10 +851,12 @@ +@@ -484,10 +862,12 @@ default: throw new IllegalArgumentException("Invalid player action"); } @@ -585,9 +585,9 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); EnumHand enumhand = packetplayinuseitem.c(); ItemStack itemstack = this.player.b(enumhand); -@@ -490,6 +870,13 @@ +@@ -501,6 +881,13 @@ chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage, (byte) 2)); + this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage, ChatMessageType.GAME_INFO)); } else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { + // CraftBukkit start - Check if we can actually do something over this large a distance + Location eyeLoc = this.getPlayer().getEyeLocation(); @@ -599,7 +599,7 @@ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f()); } -@@ -499,13 +886,52 @@ +@@ -510,13 +897,52 @@ public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x()); @@ -653,7 +653,7 @@ } } -@@ -516,8 +942,8 @@ +@@ -527,8 +953,8 @@ WorldServer[] aworldserver = this.minecraftServer.worldServer; int i = aworldserver.length; @@ -664,7 +664,7 @@ if (worldserver != null) { entity = packetplayinspectate.a(worldserver); -@@ -530,6 +956,8 @@ +@@ -541,6 +967,8 @@ if (entity != null) { this.player.setSpectatorTarget(this.player); this.player.stopRiding(); @@ -673,7 +673,7 @@ if (entity.world == this.player.world) { this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); } else { -@@ -555,12 +983,20 @@ +@@ -566,12 +994,20 @@ this.minecraftServer.getPlayerList().b(this.player, worldserver2); this.minecraftServer.getPlayerList().updateClient(this.player); } @@ -695,11 +695,11 @@ public void a(PacketPlayInBoatMove packetplayinboatmove) { PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x()); -@@ -573,14 +1009,29 @@ +@@ -584,14 +1020,29 @@ } public void a(IChatBaseComponent ichatbasecomponent) { -- PlayerConnection.LOGGER.info("{} lost connection: {}", new Object[] { this.player.getName(), ichatbasecomponent}); +- PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName(), ichatbasecomponent); + // CraftBukkit start - Rarely it would send a disconnect line twice + if (this.processedDisconnect) { + return; @@ -707,7 +707,7 @@ + this.processedDisconnect = true; + } + // CraftBukkit end -+ PlayerConnection.LOGGER.info("{} lost connection: {}", new Object[] { this.player.getName(), ichatbasecomponent.toPlainText()});// CraftBukkit - Don't toString(). ++ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName(), ichatbasecomponent.toPlainText()); // CraftBukkit - Don't toString(). + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* this.minecraftServer.aD(); @@ -717,7 +717,7 @@ this.minecraftServer.getPlayerList().sendMessage(chatmessage); + */ + - this.player.t(); + this.player.s(); - this.minecraftServer.getPlayerList().disconnect(this.player); + String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); + if ((quitMessage != null) && (quitMessage.length() > 0)) { @@ -727,7 +727,7 @@ if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); -@@ -602,6 +1053,15 @@ +@@ -613,6 +1064,15 @@ } } @@ -743,7 +743,7 @@ try { this.networkManager.sendPacket(packet); } catch (Throwable throwable) { -@@ -623,17 +1083,32 @@ +@@ -634,17 +1094,32 @@ public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x()); @@ -760,7 +760,7 @@ this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a(); this.player.resetIdleTimer(); } else { - PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", new Object[] { this.player.getName()}); + PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName()); + this.disconnect("Nope!"); // CraftBukkit } } @@ -778,7 +778,7 @@ ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -@@ -646,39 +1121,249 @@ +@@ -657,39 +1132,249 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -871,8 +871,6 @@ } } -- private void handleCommand(String s) { -- this.minecraftServer.getCommandHandler().a(this.player, s); + // CraftBukkit start - add method + public void chat(String s, boolean async) { + if (s.isEmpty() || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { @@ -947,7 +945,8 @@ + } + // CraftBukkit end + -+ private void handleCommand(String s) { + private void handleCommand(String s) { +- this.minecraftServer.getCommandHandler().b(this.player, s); + // CraftBukkit start - whole method + this.LOGGER.info(this.player.getName() + " issued server command: " + s); + @@ -969,7 +968,7 @@ + java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + return; + } -+ // this.minecraftServer.getCommandHandler().a(this.player, s); ++ // this.minecraftServer.getCommandHandler().b(this.player, s); + // CraftBukkit end } @@ -1036,7 +1035,7 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -750,6 +1435,7 @@ +@@ -761,6 +1446,7 @@ public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x()); @@ -1044,7 +1043,7 @@ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -765,20 +1451,68 @@ +@@ -776,20 +1462,68 @@ if (this.player.h(entity) < d0) { EnumHand enumhand; @@ -1114,7 +1113,7 @@ } } } -@@ -794,7 +1528,8 @@ +@@ -805,7 +1539,8 @@ case PERFORM_RESPAWN: if (this.player.viewingCredits) { this.player.viewingCredits = false; @@ -1124,7 +1123,7 @@ } else { if (this.player.getHealth() > 0.0F) { return; -@@ -820,14 +1555,20 @@ +@@ -827,14 +1562,20 @@ public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x()); @@ -1132,7 +1131,7 @@ + if (this.player.isFrozen()) return; // CraftBukkit + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit + - this.player.s(); + this.player.r(); } public void a(PacketPlayInWindowClick packetplayinwindowclick) { @@ -1147,7 +1146,7 @@ NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { -@@ -836,8 +1577,274 @@ +@@ -843,8 +1584,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { @@ -1423,7 +1422,7 @@ if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); this.player.f = true; -@@ -866,6 +1873,7 @@ +@@ -946,6 +1953,7 @@ public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x()); @@ -1431,7 +1430,7 @@ this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { this.player.activeContainer.a(this.player, packetplayinenchantitem.b()); -@@ -899,7 +1907,46 @@ +@@ -979,7 +1987,46 @@ } boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45; @@ -1479,7 +1478,7 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -923,6 +1970,7 @@ +@@ -1003,6 +2050,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); @@ -1487,7 +1486,7 @@ Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -933,6 +1981,7 @@ +@@ -1013,6 +2061,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x()); @@ -1495,7 +1494,7 @@ this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.a(); -@@ -949,14 +1998,30 @@ +@@ -1029,14 +2078,30 @@ if (!tileentitysign.a() || tileentitysign.e() != this.player) { this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); @@ -1527,7 +1526,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -979,11 +2044,27 @@ +@@ -1059,11 +2124,27 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x()); @@ -1556,7 +1555,7 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator(); -@@ -1009,6 +2090,13 @@ +@@ -1089,6 +2170,13 @@ ItemStack itemstack1; if ("MC|BEdit".equals(s)) { @@ -1570,7 +1569,7 @@ packetdataserializer = packetplayincustompayload.b(); try { -@@ -1027,15 +2115,25 @@ +@@ -1107,15 +2195,25 @@ } if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { @@ -1596,7 +1595,7 @@ packetdataserializer = packetplayincustompayload.b(); try { -@@ -1069,10 +2167,11 @@ +@@ -1149,10 +2247,11 @@ } itemstack2.a("pages", (NBTBase) nbttaglist); @@ -1609,7 +1608,7 @@ } } else if ("MC|TrSel".equals(s)) { try { -@@ -1084,6 +2183,7 @@ +@@ -1164,6 +2263,7 @@ } } catch (Exception exception2) { PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2); @@ -1617,7 +1616,7 @@ } } else { TileEntity tileentity; -@@ -1133,6 +2233,7 @@ +@@ -1213,6 +2313,7 @@ } } catch (Exception exception3) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3); @@ -1625,7 +1624,7 @@ } } else if ("MC|AutoCmd".equals(s)) { if (!this.minecraftServer.getEnableCommandBlock()) { -@@ -1200,6 +2301,7 @@ +@@ -1280,6 +2381,7 @@ } } catch (Exception exception4) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4); @@ -1633,7 +1632,7 @@ } } else { int k; -@@ -1223,6 +2325,7 @@ +@@ -1303,6 +2405,7 @@ } } catch (Exception exception5) { PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5); @@ -1641,7 +1640,7 @@ } } } else if ("MC|ItemName".equals(s)) { -@@ -1309,6 +2412,7 @@ +@@ -1389,6 +2492,7 @@ } } catch (Exception exception6) { PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6); @@ -1649,7 +1648,7 @@ } } else if ("MC|PickItem".equals(s)) { packetdataserializer = packetplayincustompayload.b(); -@@ -1321,11 +2425,49 @@ +@@ -1401,11 +2505,49 @@ this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); } catch (Exception exception7) { PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7); diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch index 3db81a13..126642b7 100644 --- a/nms-patches/PlayerInteractManager.patch +++ b/nms-patches/PlayerInteractManager.patch @@ -207,7 +207,7 @@ + } + // CraftBukkit end + - if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.dk()) { + if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) { this.world.notify(blockposition, iblockdata, iblockdata, 3); return false; @@ -238,6 +371,12 @@ @@ -247,16 +247,16 @@ + } - if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) { -- itileinventory = ((BlockChest) block).c(world, blockposition); +- itileinventory = ((BlockChest) block).getInventory(world, blockposition); - } -+ if (entityhuman.di().a(itemstack.getItem())) { ++ if (entityhuman.getCooldownTracker().a(itemstack.getItem())) { + cancelledBlock = true; + } - if (itileinventory != null) { - entityhuman.openContainer(itileinventory); - return EnumInteractionResult.SUCCESS; -+ if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) { // PAIL: creativeAndOp ++ if (itemstack.getItem() instanceof ItemBlock && !entityhuman.isCreativeAndOp()) { + Block block1 = ((ItemBlock) itemstack.getItem()).getBlock(); + + if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) { @@ -294,7 +294,7 @@ - if (iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2)) { + if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) { -+ itileinventory = ((BlockChest) block).c(world, blockposition); // PAIL: rename ++ itileinventory = ((BlockChest) block).getInventory(world, blockposition); + } + + if (itileinventory != null) { @@ -309,10 +309,10 @@ - if (itemstack.isEmpty()) { - return EnumInteractionResult.PASS; -- } else if (entityhuman.di().a(itemstack.getItem())) { +- } else if (entityhuman.getCooldownTracker().a(itemstack.getItem())) { return EnumInteractionResult.PASS; } else { -- if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) { +- if (itemstack.getItem() instanceof ItemBlock && !entityhuman.isCreativeAndOp()) { - Block block1 = ((ItemBlock) itemstack.getItem()).getBlock(); + if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) { + IBlockData iblockdata = world.getType(blockposition); diff --git a/nms-patches/PlayerInventory.patch b/nms-patches/PlayerInventory.patch index 543011b5..0510e6ea 100644 --- a/nms-patches/PlayerInventory.patch +++ b/nms-patches/PlayerInventory.patch @@ -96,7 +96,7 @@ public int getFirstEmptySlotIndex() { for (int i = 0; i < this.items.size(); ++i) { if (((ItemStack) this.items.get(i)).isEmpty()) { -@@ -477,7 +546,7 @@ +@@ -512,7 +581,7 @@ } public int getMaxStackSize() { @@ -105,7 +105,7 @@ } public boolean b(IBlockData iblockdata) { -@@ -533,6 +602,11 @@ +@@ -568,6 +637,11 @@ } public ItemStack getCarried() { diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch index 8e815d8c..95309563 100644 --- a/nms-patches/PlayerList.patch +++ b/nms-patches/PlayerList.patch @@ -39,9 +39,9 @@ private final Map<UUID, EntityPlayer> j = Maps.newHashMap(); private final GameProfileBanList k; private final IpBanList l; -@@ -43,7 +66,15 @@ - private boolean t; - private int u; +@@ -44,7 +67,15 @@ + private boolean u; + private int v; + // CraftBukkit start + private CraftServer cserver; @@ -55,7 +55,7 @@ this.k = new GameProfileBanList(PlayerList.a); this.l = new IpBanList(PlayerList.b); this.operators = new OpList(PlayerList.c); -@@ -63,6 +94,12 @@ +@@ -65,6 +96,12 @@ usercache.a(gameprofile); NBTTagCompound nbttagcompound = this.a(entityplayer); @@ -68,17 +68,17 @@ entityplayer.spawnIn(this.server.getWorldServer(entityplayer.dimension)); entityplayer.playerInteractManager.a((WorldServer) entityplayer.world); -@@ -72,7 +109,8 @@ +@@ -74,7 +111,8 @@ s1 = networkmanager.getSocketAddress().toString(); } -- PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[] { entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)}); +- PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)); + // CraftBukkit - Moved message to after join -+ // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[] { entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)}); ++ // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)); WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); WorldData worlddata = worldserver.getWorldData(); -@@ -80,6 +118,7 @@ +@@ -82,6 +120,7 @@ PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer); playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getDimensionID(), worldserver.getDifficulty(), this.getMaxPlayers(), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo"))); @@ -86,8 +86,8 @@ playerconnection.sendPacket(new PacketPlayOutCustomPayload("MC|Brand", (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); -@@ -89,17 +128,23 @@ - entityplayer.getStatisticManager().updateStatistics(entityplayer); +@@ -91,17 +130,23 @@ + entityplayer.F().a(entityplayer); this.sendScoreboard((ScoreboardServer) worldserver.getScoreboard(), entityplayer); this.server.aD(); - ChatMessage chatmessage; @@ -116,7 +116,7 @@ playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); this.b(entityplayer, worldserver); if (!this.server.getResourcePack().isEmpty()) { -@@ -151,6 +196,8 @@ +@@ -153,6 +198,8 @@ } entityplayer.syncInventory(); @@ -125,7 +125,7 @@ } public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -183,26 +230,27 @@ +@@ -185,26 +232,27 @@ } public void setPlayerFileData(WorldServer[] aworldserver) { @@ -158,7 +158,7 @@ } public void b(WorldBorder worldborder, double d0) {} -@@ -228,7 +276,7 @@ +@@ -237,7 +285,7 @@ @Nullable public NBTTagCompound a(EntityPlayer entityplayer) { @@ -167,7 +167,7 @@ NBTTagCompound nbttagcompound1; if (entityplayer.getName().equals(this.server.Q()) && nbttagcompound != null) { -@@ -252,28 +300,73 @@ +@@ -267,28 +315,73 @@ } @@ -247,8 +247,8 @@ this.savePlayerFile(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getVehicle(); -@@ -305,13 +398,61 @@ - this.o.remove(uuid); +@@ -322,13 +415,61 @@ + this.p.remove(uuid); } - this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[] { entityplayer})); @@ -312,7 +312,7 @@ GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile); s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason(); -@@ -319,10 +460,12 @@ +@@ -336,10 +477,12 @@ s = s + "\nYour ban will be removed on " + PlayerList.g.format(gameprofilebanentry.getExpires()); } @@ -328,7 +328,7 @@ IpBanEntry ipbanentry = this.l.get(socketaddress); s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason(); -@@ -330,13 +473,25 @@ +@@ -347,13 +490,25 @@ s = s + "\nYour ban will be removed on " + PlayerList.g.format(ipbanentry.getExpires()); } @@ -357,7 +357,7 @@ UUID uuid = EntityHuman.a(gameprofile); ArrayList arraylist = Lists.newArrayList(); -@@ -371,17 +526,27 @@ +@@ -388,17 +543,27 @@ } return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object); @@ -386,7 +386,7 @@ entityplayer.dimension = i; Object object; -@@ -392,6 +557,11 @@ +@@ -409,6 +574,11 @@ } EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object); @@ -397,9 +397,9 @@ + // CraftBukkit end entityplayer1.playerConnection = entityplayer.playerConnection; - entityplayer1.copyTo(entityplayer, flag); -@@ -406,43 +576,157 @@ - entityplayer1.a(s); + entityplayer1.copyFrom(entityplayer, flag); +@@ -423,43 +593,163 @@ + entityplayer1.addScoreboardTag(s); } - WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); @@ -429,13 +429,13 @@ + entityplayer1.setRespawnPosition(null, true); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F)); + } - } ++ } + + if (location == null) { + cworld = (CraftWorld) this.server.server.getWorlds().get(0); + blockposition = cworld.getHandle().getSpawn(); + location = new Location(cworld, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F)); -+ } + } + + Player respawnPlayer = cserver.getPlayer(entityplayer1); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn); @@ -497,6 +497,12 @@ + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect)); + } + ++ // Fire advancement trigger ++ CriterionTriggers.u.a(entityplayer, ((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager(), worldserver.worldProvider.getDimensionManager()); ++ if (worldserver.worldProvider.getDimensionManager() == DimensionManager.NETHER && ((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && entityplayer.Q() != null) { ++ CriterionTriggers.B.a(entityplayer, entityplayer.Q()); ++ } ++ + // Don't fire on respawn + if (fromWorld != location.getWorld()) { + PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld); @@ -573,7 +579,7 @@ public void f(EntityPlayer entityplayer) { GameProfile gameprofile = entityplayer.getProfile(); int i = this.isOp(gameprofile) ? this.operators.a(gameprofile) : 0; -@@ -481,12 +765,111 @@ +@@ -498,12 +788,111 @@ } public void changeWorld(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) { @@ -595,13 +601,13 @@ + double d1 = enter.getZ(); + double d2 = 8.0D; + /* -+ double d0 = entity.locX; -+ double d1 = entity.locZ; -+ double d2 = 8.0D; -+ float f = entity.yaw; + double d0 = entity.locX; + double d1 = entity.locZ; + double d2 = 8.0D; + float f = entity.yaw; + */ -+ -+ worldserver.methodProfiler.a("moving"); + + worldserver.methodProfiler.a("moving"); + if (worldserver1.dimension == -1) { + d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b()+ 16.0D, worldserver1.getWorldBorder().d() - 16.0D); + d1 = MathHelper.a(d1 / d2, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); @@ -670,13 +676,13 @@ + int i = worldserver.dimension; + + /* - double d0 = entity.locX; - double d1 = entity.locZ; - double d2 = 8.0D; - float f = entity.yaw; ++ double d0 = entity.locX; ++ double d1 = entity.locZ; ++ double d2 = 8.0D; ++ float f = entity.yaw; + */ - - worldserver.methodProfiler.a("moving"); ++ ++ worldserver.methodProfiler.a("moving"); + entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); + if (entity.isAlive()) { + worldserver.entityJoinedWorld(entity, false); @@ -685,7 +691,7 @@ if (entity.dimension == -1) { d0 = MathHelper.a(d0 / 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); d1 = MathHelper.a(d1 / 8.0D, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); -@@ -505,6 +888,8 @@ +@@ -522,6 +911,8 @@ BlockPosition blockposition; if (i == 1) { @@ -694,7 +700,7 @@ blockposition = worldserver1.getSpawn(); } else { blockposition = worldserver1.getDimensionSpawn(); -@@ -518,16 +903,27 @@ +@@ -535,16 +926,27 @@ worldserver.entityJoinedWorld(entity, false); } } @@ -725,7 +731,7 @@ worldserver1.entityJoinedWorld(entity, false); } -@@ -535,11 +931,23 @@ +@@ -552,11 +954,23 @@ } entity.spawnIn(worldserver1); @@ -733,7 +739,7 @@ } public void tick() { - if (++this.u > 600) { + if (++this.v > 600) { - this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players)); + // CraftBukkit start + for (int i = 0; i < this.players.size(); ++i) { @@ -747,10 +753,10 @@ + }))); + } + // CraftBukkit end - this.u = 0; + this.v = 0; } -@@ -552,6 +960,25 @@ +@@ -569,6 +983,25 @@ } @@ -776,7 +782,7 @@ public void a(Packet<?> packet, int i) { for (int j = 0; j < this.players.size(); ++j) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); -@@ -650,11 +1077,23 @@ +@@ -667,11 +1100,23 @@ this.operators.add(new OpListEntry(gameprofile, this.server.q(), this.operators.b(gameprofile))); this.b(this.a(gameprofile.getId()), i); @@ -800,16 +806,16 @@ } private void b(EntityPlayer entityplayer, int i) { -@@ -679,7 +1118,7 @@ +@@ -696,7 +1141,7 @@ } public boolean isOp(GameProfile gameprofile) { -- return this.operators.d(gameprofile) || this.server.R() && this.server.worldServer[0].getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.t; -+ return this.operators.d(gameprofile) || this.server.R() && this.server.worlds.get(0).getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.t; // CraftBukkit +- return this.operators.d(gameprofile) || this.server.R() && this.server.worldServer[0].getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.u; ++ return this.operators.d(gameprofile) || this.server.R() && this.server.worlds.get(0).getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.u; // CraftBukkit } @Nullable -@@ -703,6 +1142,12 @@ +@@ -720,6 +1165,12 @@ for (int j = 0; j < this.players.size(); ++j) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); @@ -822,7 +828,7 @@ if (entityplayer != entityhuman && entityplayer.dimension == i) { double d4 = d0 - entityplayer.locX; double d5 = d1 - entityplayer.locY; -@@ -750,7 +1195,7 @@ +@@ -767,7 +1218,7 @@ public void reloadWhitelist() {} public void b(EntityPlayer entityplayer, WorldServer worldserver) { @@ -831,10 +837,10 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))); -@@ -758,16 +1203,21 @@ +@@ -775,16 +1226,21 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition)); - if (worldserver.W()) { + if (worldserver.Y()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F))); - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F))); @@ -857,7 +863,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); } -@@ -780,7 +1230,7 @@ +@@ -797,7 +1253,7 @@ } public String[] getSeenPlayers() { @@ -866,7 +872,7 @@ } public boolean getHasWhitelist() { -@@ -829,17 +1279,29 @@ +@@ -846,17 +1302,29 @@ } public void u() { @@ -890,16 +896,16 @@ + public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { this.server.sendMessage(ichatbasecomponent); - int i = flag ? 1 : 0; + ChatMessageType chatmessagetype = flag ? ChatMessageType.SYSTEM : ChatMessageType.CHAT; -- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, (byte) i)); +- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, chatmessagetype)); + // CraftBukkit start - we run this through our processor first so we can get web links etc -+ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), (byte) i)); ++ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), chatmessagetype)); + // CraftBukkit end } public void sendMessage(IChatBaseComponent ichatbasecomponent) { -@@ -876,8 +1338,10 @@ +@@ -909,8 +1377,10 @@ WorldServer[] aworldserver = this.server.worldServer; int j = aworldserver.length; diff --git a/nms-patches/PortalTravelAgent.patch b/nms-patches/PortalTravelAgent.patch index 94995280..0c1c4e78 100644 --- a/nms-patches/PortalTravelAgent.patch +++ b/nms-patches/PortalTravelAgent.patch @@ -120,7 +120,7 @@ - for (int i1 = -128; i1 <= 128; ++i1) { + for (int i1 = -radius; i1 <= radius; ++i1) { - for (BlockPosition blockposition2 = blockposition.a(l, this.world.Z() - 1 - blockposition.getY(), i1); blockposition2.getY() >= 0; blockposition2 = blockposition1) { + for (BlockPosition blockposition2 = blockposition.a(l, this.world.ab() - 1 - blockposition.getY(), i1); blockposition2.getY() >= 0; blockposition2 = blockposition1) { blockposition1 = blockposition2.down(); if (this.world.getType(blockposition2).getBlock() == Blocks.PORTAL) { @@ -95,6 +158,29 @@ @@ -243,7 +243,7 @@ + d2 = (double) j2 + 0.5D - z; // CraftBukkit label271: - for (k2 = this.world.Z() - 1; k2 >= 0; --k2) { + for (k2 = this.world.ab() - 1; k2 >= 0; --k2) { @@ -215,7 +330,7 @@ } } @@ -265,7 +265,7 @@ + d2 = (double) j2 + 0.5D - z; // CraftBukkit label219: - for (k2 = this.world.Z() - 1; k2 >= 0; --k2) { + for (k2 = this.world.ab() - 1; k2 >= 0; --k2) { @@ -260,7 +375,7 @@ } } diff --git a/nms-patches/RecipeArmorDye.patch b/nms-patches/RecipeArmorDye.patch index da5dd043..86408202 100644 --- a/nms-patches/RecipeArmorDye.patch +++ b/nms-patches/RecipeArmorDye.patch @@ -4,13 +4,13 @@ import com.google.common.collect.Lists; import java.util.ArrayList; --public class RecipeArmorDye implements IRecipe { -+public class RecipeArmorDye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipeArmorDye extends IRecipe { ++public class RecipeArmorDye extends ShapelessRecipes { // CraftBukkit - public RecipeArmorDye() {} + // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeArmorDye() { -+ super(new ItemStack(Items.LEATHER_HELMET, 0, 0), java.util.Arrays.asList(new ItemStack(Items.DYE, 0, 5))); ++ super("", new ItemStack(Items.LEATHER_HELMET, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE))); + } + // CraftBukkit end diff --git a/nms-patches/RecipeBookClone.patch b/nms-patches/RecipeBookClone.patch index 022d5e7f..f2260d1b 100644 --- a/nms-patches/RecipeBookClone.patch +++ b/nms-patches/RecipeBookClone.patch @@ -3,12 +3,12 @@ @@ -1,8 +1,11 @@ package net.minecraft.server; --public class RecipeBookClone implements IRecipe { -+public class RecipeBookClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipeBookClone extends IRecipe { ++public class RecipeBookClone extends ShapelessRecipes { // CraftBukkit - public RecipeBookClone() {} + public RecipeBookClone() { -+ super(new ItemStack(Items.WRITTEN_BOOK, 0, -1), java.util.Arrays.asList(new ItemStack(Items.WRITABLE_BOOK, 0, 0))); ++ super("", new ItemStack(Items.WRITTEN_BOOK, 0, -1), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WRITABLE_BOOK))); + } + // CraftBukkit end diff --git a/nms-patches/RecipeFireworks.patch b/nms-patches/RecipeFireworks.patch index f4ed6fbf..2105cfcf 100644 --- a/nms-patches/RecipeFireworks.patch +++ b/nms-patches/RecipeFireworks.patch @@ -4,17 +4,17 @@ import com.google.common.collect.Lists; import java.util.ArrayList; --public class RecipeFireworks implements IRecipe { -+public class RecipeFireworks extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipeFireworks extends IRecipe { ++public class RecipeFireworks extends ShapelessRecipes { // CraftBukkit - private ItemStack a; + private ItemStack b; + // CraftBukkit start - Delegate to new parent class with bogus info public RecipeFireworks() { -+ super(new ItemStack(Items.FIREWORKS, 0, 0), java.util.Arrays.asList(new ItemStack(Items.GUNPOWDER, 0, 5))); - this.a = ItemStack.a; ++ super("", new ItemStack(Items.FIREWORKS, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.GUNPOWDER))); + this.b = ItemStack.a; } + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { - this.a = ItemStack.a; + this.b = ItemStack.a; diff --git a/nms-patches/RecipeMapClone.patch b/nms-patches/RecipeMapClone.patch index 23496349..3f2a5426 100644 --- a/nms-patches/RecipeMapClone.patch +++ b/nms-patches/RecipeMapClone.patch @@ -3,13 +3,13 @@ @@ -1,8 +1,12 @@ package net.minecraft.server; --public class RecipeMapClone implements IRecipe { -+public class RecipeMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipeMapClone extends IRecipe { ++public class RecipeMapClone extends ShapelessRecipes { // CraftBukkit - public RecipeMapClone() {} + // CraftBukkit start - Delegate to new parent class + public RecipeMapClone() { -+ super(new ItemStack(Items.MAP, 0, -1), java.util.Arrays.asList(new ItemStack(Items.MAP, 0, 0))); ++ super("", new ItemStack(Items.MAP, 0, -1), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.MAP))); + } + // CraftBukkit end diff --git a/nms-patches/RecipeRepair.patch b/nms-patches/RecipeRepair.patch index 1d0f9144..4b01fe2a 100644 --- a/nms-patches/RecipeRepair.patch +++ b/nms-patches/RecipeRepair.patch @@ -4,31 +4,32 @@ import com.google.common.collect.Lists; import java.util.ArrayList; --public class RecipeRepair implements IRecipe { -+public class RecipeRepair extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipeRepair extends IRecipe { ++public class RecipeRepair extends ShapelessRecipes { // CraftBukkit - public RecipeRepair() {} + // CraftBukkit start - Delegate to new parent class + public RecipeRepair() { -+ super(new ItemStack(Items.LEATHER_HELMET), java.util.Arrays.asList(new ItemStack(Items.LEATHER_HELMET))); ++ super("", new ItemStack(Items.LEATHER_HELMET), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.LEATHER_HELMET))); + } + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { ArrayList arraylist = Lists.newArrayList(); -@@ -62,7 +66,17 @@ +@@ -62,7 +66,18 @@ i1 = 0; } - return new ItemStack(itemstack2.getItem(), 1, i1); + // CraftBukkit start - Construct a dummy repair recipe + ItemStack result = new ItemStack(itemstack.getItem(), 1, i1); -+ java.util.List<ItemStack> ingredients = new ArrayList<ItemStack>(); -+ ingredients.add(itemstack2.cloneItemStack()); -+ ingredients.add(itemstack.cloneItemStack()); -+ ShapelessRecipes recipe = new ShapelessRecipes(result.cloneItemStack(), ingredients); ++ NonNullList<RecipeItemStack> ingredients = NonNullList.a(); ++ ingredients.add(new RecipeItemStack(itemstack2.cloneItemStack())); ++ ingredients.add(new RecipeItemStack(itemstack.cloneItemStack())); ++ ShapelessRecipes recipe = new ShapelessRecipes(this.a, result.cloneItemStack(), ingredients); ++ recipe.key = new MinecraftKey("repairitem"); + inventorycrafting.currentRecipe = recipe; -+ result = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, result, CraftingManager.getInstance().lastCraftView, true); ++ result = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, result, inventorycrafting.container.getBukkitView(), true); + return result; + // return new ItemStack(itemstack2.getItem(), 1, i1); + // CraftBukkit end diff --git a/nms-patches/RecipeShulkerBox.patch b/nms-patches/RecipeShulkerBox.patch index 7f602345..e38557c7 100644 --- a/nms-patches/RecipeShulkerBox.patch +++ b/nms-patches/RecipeShulkerBox.patch @@ -1,16 +1,18 @@ --- a/net/minecraft/server/RecipeShulkerBox.java +++ b/net/minecraft/server/RecipeShulkerBox.java -@@ -9,9 +9,13 @@ - craftingmanager.a(new RecipeShulkerBox.Dye(null)); - } +@@ -1,8 +1,15 @@ + package net.minecraft.server; -- static class Dye implements IRecipe { -+ static class Dye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipeShulkerBox { public static class Dye extends IRecipe { ++// CraftBukkit - decompile weirdness ++public class RecipeShulkerBox { -- private Dye() {} +- public Dye() {} ++ public static class Dye extends ShapelessRecipes { // CraftBukkit ++ + // CraftBukkit start - Delegate to new parent class with bogus info + public Dye() { -+ super(new ItemStack(Blocks.WHITE_SHULKER_BOX, 0, 0), java.util.Arrays.asList(new ItemStack(Items.DYE, 0, 5))); ++ super("", new ItemStack(Blocks.WHITE_SHULKER_BOX, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE))); + } + // CraftBukkit end diff --git a/nms-patches/RecipeTippedArrow.patch b/nms-patches/RecipeTippedArrow.patch index c828203e..79e4312d 100644 --- a/nms-patches/RecipeTippedArrow.patch +++ b/nms-patches/RecipeTippedArrow.patch @@ -4,17 +4,17 @@ import java.util.Collection; --public class RecipeTippedArrow implements IRecipe { -+public class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit +-public class RecipeTippedArrow extends IRecipe { ++public class RecipeTippedArrow extends ShapedRecipes { // CraftBukkit - public RecipeTippedArrow() {} + // CraftBukkit start + public RecipeTippedArrow() { -+ super(3, 3, new ItemStack[]{ -+ new ItemStack(Items.ARROW, 0), new ItemStack(Items.ARROW, 0), new ItemStack(Items.ARROW, 0), -+ new ItemStack(Items.ARROW, 0), new ItemStack(Items.LINGERING_POTION, 0), new ItemStack(Items.ARROW, 0), -+ new ItemStack(Items.ARROW, 0), new ItemStack(Items.ARROW, 0), new ItemStack(Items.ARROW, 0) -+ }, new ItemStack(Items.TIPPED_ARROW, 8)); ++ super("", 3, 3, NonNullList.a(RecipeItemStack.a, ++ RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), ++ RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.LINGERING_POTION), RecipeItemStack.a(Items.ARROW), ++ RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW)), ++ new ItemStack(Items.TIPPED_ARROW, 8)); + } + // CraftBukkit end diff --git a/nms-patches/RecipesBanner.patch b/nms-patches/RecipesBanner.patch index 3de6f89e..06e3cbee 100644 --- a/nms-patches/RecipesBanner.patch +++ b/nms-patches/RecipesBanner.patch @@ -1,32 +1,35 @@ --- a/net/minecraft/server/RecipesBanner.java +++ b/net/minecraft/server/RecipesBanner.java -@@ -20,9 +20,13 @@ - craftingmanager.a(new RecipesBanner.AddRecipe(null)); - } +@@ -2,9 +2,16 @@ + + import javax.annotation.Nullable; -- static class AddRecipe implements IRecipe { -+ static class AddRecipe extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipesBanner { public static class AddRecipe extends IRecipe { ++// CraftBukkit - decompile weirdness ++public class RecipesBanner { -- private AddRecipe() {} +- public AddRecipe() {} ++ public static class AddRecipe extends ShapelessRecipes { // CraftBukkit ++ + // CraftBukkit start - Delegate to new parent class with bogus info -+ private AddRecipe() { -+ super(new ItemStack(Items.BANNER, 0, 0), java.util.Arrays.asList(new ItemStack(Items.BANNER))); ++ public AddRecipe() { ++ super("", new ItemStack(Items.BANNER, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BANNER))); + } + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { boolean flag = false; -@@ -208,9 +212,13 @@ +@@ -186,9 +193,13 @@ } } -- static class DuplicateRecipe implements IRecipe { -+ static class DuplicateRecipe extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +- public static class DuplicateRecipe extends IRecipe { ++ public static class DuplicateRecipe extends ShapelessRecipes { // CraftBukkit - added extends -- private DuplicateRecipe() {} +- public DuplicateRecipe() {} + // CraftBukkit start - Delegate to new parent class with bogus info -+ private DuplicateRecipe() { -+ super(new ItemStack(Items.BANNER, 0, 0), java.util.Arrays.asList(new ItemStack(Items.DYE, 0, 5))); ++ public DuplicateRecipe() { ++ super("", new ItemStack(Items.BANNER, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE))); + } + // CraftBukkit end diff --git a/nms-patches/RecipesFurnace.patch b/nms-patches/RecipesFurnace.patch index cc0d13be..ccc7b333 100644 --- a/nms-patches/RecipesFurnace.patch +++ b/nms-patches/RecipesFurnace.patch @@ -12,8 +12,8 @@ public static RecipesFurnace getInstance() { return RecipesFurnace.a; -@@ -78,6 +80,13 @@ - this.a(Items.GOLDEN_HORSE_ARMOR, new ItemStack(Items.GOLD_NUGGET), 0.1F); +@@ -94,6 +96,13 @@ + this.a(new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, EnumColor.BLACK.getColorIndex()), new ItemStack(Blocks.dQ), 0.1F); } + // CraftBukkit start - add method @@ -26,7 +26,7 @@ public void registerRecipe(Block block, ItemStack itemstack, float f) { this.a(Item.getItemOf(block), itemstack, f); } -@@ -92,13 +101,23 @@ +@@ -108,13 +117,23 @@ } public ItemStack getResult(ItemStack itemstack) { @@ -52,7 +52,7 @@ } entry = (Entry) iterator.next(); -@@ -116,13 +135,23 @@ +@@ -132,13 +151,23 @@ } public float b(ItemStack itemstack) { diff --git a/nms-patches/RecipiesShield.patch b/nms-patches/RecipiesShield.patch index 236e726a..e0c90497 100644 --- a/nms-patches/RecipiesShield.patch +++ b/nms-patches/RecipiesShield.patch @@ -1,16 +1,18 @@ --- a/net/minecraft/server/RecipiesShield.java +++ b/net/minecraft/server/RecipiesShield.java -@@ -9,9 +9,13 @@ - craftingmanager.a(new RecipiesShield.Decoration(null)); - } +@@ -1,8 +1,15 @@ + package net.minecraft.server; -- static class Decoration implements IRecipe { -+ static class Decoration extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends +-public class RecipiesShield { public static class Decoration extends IRecipe { ++// CraftBukkit - decompile weirdness ++public class RecipiesShield { -- private Decoration() {} +- public Decoration() {} ++ public static class Decoration extends ShapelessRecipes { // CraftBukkit ++ + // CraftBukkit start - Delegate to new parent class with bogus info -+ private Decoration() { -+ super(new ItemStack(Items.SHIELD, 0 ,0), java.util.Arrays.asList(new ItemStack(Items.BANNER, 0, 0))); ++ public Decoration() { ++ super("", new ItemStack(Items.SHIELD, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BANNER))); + } + // CraftBukkit end diff --git a/nms-patches/RegionFile.patch b/nms-patches/RegionFile.patch deleted file mode 100644 index a1abb025..00000000 --- a/nms-patches/RegionFile.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/server/RegionFile.java -+++ b/net/minecraft/server/RegionFile.java -@@ -224,11 +224,11 @@ - return i < 0 || i >= 32 || j < 0 || j >= 32; - } - -- private int e(int i, int j) { -+ private synchronized int e(int i, int j) { // CraftBukkit - return this.d[i + j * 32]; - } - -- public boolean c(int i, int j) { -+ public boolean c(int i, int j) { // PAIL chunkExists - return this.e(i, j) != 0; - } - diff --git a/nms-patches/RegionFileCache.patch b/nms-patches/RegionFileCache.patch index fe90d577..84697d79 100644 --- a/nms-patches/RegionFileCache.patch +++ b/nms-patches/RegionFileCache.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/RegionFileCache.java +++ b/net/minecraft/server/RegionFileCache.java -@@ -74,19 +74,29 @@ +@@ -74,17 +74,27 @@ RegionFileCache.a.clear(); } @@ -30,8 +30,5 @@ } + // CraftBukkit end -- public static boolean f(File file, int i, int j) { -+ public static synchronized boolean f(File file, int i, int j) { // PAIL chunkExists; CraftBukkit + public static synchronized boolean chunkExists(File file, int i, int j) { RegionFile regionfile = b(file, i, j); - - return regionfile != null ? regionfile.c(i & 31, j & 31) : false; diff --git a/nms-patches/RemoteControlCommandListener.patch b/nms-patches/RemoteControlCommandListener.patch index bcbbeb0c..22369f89 100644 --- a/nms-patches/RemoteControlCommandListener.patch +++ b/nms-patches/RemoteControlCommandListener.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/RemoteControlCommandListener.java +++ b/net/minecraft/server/RemoteControlCommandListener.java -@@ -25,6 +25,12 @@ - return new ChatComponentText(this.getName()); +@@ -21,6 +21,12 @@ + return "Rcon"; } + // CraftBukkit start - Send a String diff --git a/nms-patches/SecondaryWorldServer.patch b/nms-patches/SecondaryWorldServer.patch index d3786952..f05e64bb 100644 --- a/nms-patches/SecondaryWorldServer.patch +++ b/nms-patches/SecondaryWorldServer.patch @@ -26,8 +26,8 @@ + // protected void a() {} // CraftBukkit public World b() { - this.worldMaps = this.a.X(); -@@ -55,7 +59,7 @@ + this.worldMaps = this.a.Z(); +@@ -56,7 +60,7 @@ this.villages.a((World) this); } diff --git a/nms-patches/ShapedRecipes.patch b/nms-patches/ShapedRecipes.patch index 9f7c4969..b86fd148 100644 --- a/nms-patches/ShapedRecipes.patch +++ b/nms-patches/ShapedRecipes.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/ShapedRecipes.java +++ b/net/minecraft/server/ShapedRecipes.java -@@ -1,5 +1,10 @@ - package net.minecraft.server; - +@@ -12,6 +12,10 @@ + import java.util.Map; + import java.util.Map.Entry; + import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; +// CraftBukkit end -+ - public class ShapedRecipes implements IRecipe { - private final int width; -@@ -22,6 +27,62 @@ + public class ShapedRecipes extends IRecipe { + +@@ -28,6 +32,63 @@ this.result = itemstack; } @@ -61,8 +61,9 @@ + break; + } + char c = 'a'; -+ for (ItemStack stack : this.items) { -+ if (stack != null) { ++ for (RecipeItemStack list : this.items) { ++ if (list != null && list.choices.length > 0) { ++ net.minecraft.server.ItemStack stack = list.choices[0]; + recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), stack.getData()); + } + c++; diff --git a/nms-patches/ShapelessRecipes.patch b/nms-patches/ShapelessRecipes.patch index 0ed46af4..ff95bff6 100644 --- a/nms-patches/ShapelessRecipes.patch +++ b/nms-patches/ShapelessRecipes.patch @@ -1,19 +1,24 @@ --- a/net/minecraft/server/ShapelessRecipes.java +++ b/net/minecraft/server/ShapelessRecipes.java -@@ -5,6 +5,11 @@ +@@ -5,11 +5,16 @@ + import com.google.gson.JsonObject; + import java.util.ArrayList; import java.util.Iterator; - import java.util.List; - +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; +// CraftBukkit end -+ - public class ShapelessRecipes implements IRecipe { + + public class ShapelessRecipes extends IRecipe { private final ItemStack result; -@@ -15,6 +20,20 @@ - this.ingredients = list; + private final NonNullList<RecipeItemStack> ingredients; ++ public MinecraftKey key; // CraftBukkit + + public ShapelessRecipes(String s, ItemStack itemstack, NonNullList<RecipeItemStack> nonnulllist) { + super(s); +@@ -17,6 +22,21 @@ + this.ingredients = nonnulllist; } + // CraftBukkit start @@ -21,8 +26,9 @@ + public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this); -+ for (ItemStack stack : (List<ItemStack>) this.ingredients) { -+ if (stack != null) { ++ for (RecipeItemStack list : this.ingredients) { ++ if (list != null) { ++ net.minecraft.server.ItemStack stack = list.choices[0]; + recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), stack.getData()); + } + } diff --git a/nms-patches/SpawnerCreature.patch b/nms-patches/SpawnerCreature.patch index d8e40847..ce90948f 100644 --- a/nms-patches/SpawnerCreature.patch +++ b/nms-patches/SpawnerCreature.patch @@ -84,7 +84,7 @@ int j2 = blockposition1.getY(); int k2 = blockposition1.getZ(); @@ -125,8 +158,11 @@ - if (entityinsentient.cM() && entityinsentient.canSpawn()) { + if (entityinsentient.P() && entityinsentient.canSpawn()) { groupdataentity = entityinsentient.prepare(worldserver.D(new BlockPosition(entityinsentient)), groupdataentity); if (entityinsentient.canSpawn()) { - ++l2; diff --git a/nms-patches/StatisticManager.patch b/nms-patches/StatisticManager.patch index c9359086..93e6895a 100644 --- a/nms-patches/StatisticManager.patch +++ b/nms-patches/StatisticManager.patch @@ -1,24 +1,15 @@ --- a/net/minecraft/server/StatisticManager.java +++ b/net/minecraft/server/StatisticManager.java -@@ -19,6 +19,12 @@ +@@ -10,6 +10,12 @@ + public StatisticManager() {} public void b(EntityHuman entityhuman, Statistic statistic, int i) { - if (!statistic.d() || this.b((Achievement) statistic)) { -+ // CraftBukkit start - fire Statistic events -+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), i); -+ if (cancellable != null && cancellable.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.setStatistic(entityhuman, statistic, this.getStatisticValue(statistic) + i); - } ++ // CraftBukkit start - fire Statistic events ++ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), i); ++ if (cancellable != null && cancellable.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.setStatistic(entityhuman, statistic, this.getStatisticValue(statistic) + i); } -@@ -43,7 +49,7 @@ - public <T extends IJsonStatistic> T b(Statistic statistic) { - StatisticWrapper statisticwrapper = (StatisticWrapper) this.a.get(statistic); -- return statisticwrapper != null ? statisticwrapper.b() : null; -+ return statisticwrapper != null ? (T) statisticwrapper.b() : null; // CraftBukkit - fix decompile error - } - - public <T extends IJsonStatistic> T a(Statistic statistic, T t0) { diff --git a/nms-patches/TileEntity.patch b/nms-patches/TileEntity.patch index 6024fdbc..6ebe08e9 100644 --- a/nms-patches/TileEntity.patch +++ b/nms-patches/TileEntity.patch @@ -9,9 +9,9 @@ public abstract class TileEntity { private static final Logger a = LogManager.getLogger(); -@@ -250,4 +252,13 @@ - a("command_block", TileEntityCommand.class); +@@ -251,4 +253,13 @@ a("shulker_box", TileEntityShulkerBox.class); + a("bed", TileEntityBed.class); } + + // CraftBukkit start - add method diff --git a/nms-patches/TileEntityBeacon.patch b/nms-patches/TileEntityBeacon.patch index 91779ec9..ccb0c5a6 100644 --- a/nms-patches/TileEntityBeacon.patch +++ b/nms-patches/TileEntityBeacon.patch @@ -141,4 +141,4 @@ + // CraftBukkit end private void F() { - int i = this.levels; + int i = this.position.getX(); diff --git a/nms-patches/TileEntityBrewingStand.patch b/nms-patches/TileEntityBrewingStand.patch index fa5a2ab8..11833f96 100644 --- a/nms-patches/TileEntityBrewingStand.patch +++ b/nms-patches/TileEntityBrewingStand.patch @@ -19,7 +19,7 @@ @@ -14,6 +23,31 @@ private Item k; private String l; - private int m; + private int fuelLevel; + // CraftBukkit start - add fields and methods + private int lastTick = MinecraftServer.currentTick; + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); @@ -51,8 +51,8 @@ @@ -55,8 +89,19 @@ ItemStack itemstack = (ItemStack) this.items.get(4); - if (this.m <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) { -- this.m = 20; + if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) { +- this.fuelLevel = 20; - itemstack.subtract(1); + // CraftBukkit start + BrewingStandFuelEvent event = new BrewingStandFuelEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), CraftItemStack.asCraftMirror(itemstack), 20); @@ -62,8 +62,8 @@ + return; + } + -+ this.m = event.getFuelPower(); // PAIL fuelLevel -+ if (this.m > 0 && event.isConsuming()) { ++ this.fuelLevel = event.getFuelPower(); // PAIL fuelLevel ++ if (this.fuelLevel > 0 && event.isConsuming()) { + itemstack.subtract(1); + } + // CraftBukkit end @@ -93,7 +93,7 @@ ItemStack itemstack = (ItemStack) this.items.get(3); + // CraftBukkit start + if (getOwner() != null) { -+ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory(), this.m); ++ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory(), this.fuelLevel); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; @@ -112,12 +112,3 @@ } public boolean a(EntityHuman entityhuman) { -@@ -227,7 +286,7 @@ - } else { - Item item = itemstack.getItem(); - -- return i == 4 ? item == Items.BLAZE_POWDER : (item == Items.POTION || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE) && this.getItem(i) == ItemStack.a; -+ return i == 4 ? item == Items.BLAZE_POWDER : (item == Items.POTION || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE) && this.getItem(i).isEmpty(); // CraftBukkit - MC-111753 - } - } - diff --git a/nms-patches/TileEntityEndGateway.patch b/nms-patches/TileEntityEndGateway.patch index 35bfeee3..7fc375f1 100644 --- a/nms-patches/TileEntityEndGateway.patch +++ b/nms-patches/TileEntityEndGateway.patch @@ -15,7 +15,7 @@ @@ -111,6 +117,26 @@ if (this.exitPortal != null) { - BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.i(); + BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.j(); + // CraftBukkit start - Fire PlayerTeleportEvent + if (entity instanceof EntityPlayer) { @@ -31,7 +31,7 @@ + } + + ((EntityPlayer) entity).playerConnection.teleport(teleEvent.getTo()); -+ this.i(); ++ this.h(); // CraftBukkit - call at end of method + return; + + } diff --git a/nms-patches/TileEntityFurnace.patch b/nms-patches/TileEntityFurnace.patch index 35723db1..c3e32116 100644 --- a/nms-patches/TileEntityFurnace.patch +++ b/nms-patches/TileEntityFurnace.patch @@ -52,7 +52,7 @@ @@ -119,11 +154,29 @@ } - public void F_() { + public void e() { - boolean flag = this.isBurning(); + boolean flag = (this.getBlock() == Blocks.LIT_FURNACE); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time boolean flag1 = false; diff --git a/nms-patches/TileEntityHopper.patch b/nms-patches/TileEntityHopper.patch index 9393ad7a..17005f2a 100644 --- a/nms-patches/TileEntityHopper.patch +++ b/nms-patches/TileEntityHopper.patch @@ -55,7 +55,7 @@ + return maxStack; // CraftBukkit } - public void F_() { + public void e() { @@ -163,10 +197,35 @@ for (int i = 0; i < this.getSize(); ++i) { if (!this.getItem(i).isEmpty()) { diff --git a/nms-patches/TileEntityNote.patch b/nms-patches/TileEntityNote.patch index c7f003e0..e0498c39 100644 --- a/nms-patches/TileEntityNote.patch +++ b/nms-patches/TileEntityNote.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/TileEntityNote.java +++ b/net/minecraft/server/TileEntityNote.java -@@ -47,7 +47,12 @@ - b0 = 4; +@@ -70,7 +70,12 @@ + b0 = 9; } - world.playBlockAction(blockposition, Blocks.NOTEBLOCK, b0, this.note); diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch index ec5bfd9e..4e8f902f 100644 --- a/nms-patches/TileEntitySign.patch +++ b/nms-patches/TileEntitySign.patch @@ -13,7 +13,7 @@ this.i.b(nbttagcompound); return nbttagcompound; } -@@ -74,14 +80,34 @@ +@@ -58,14 +64,34 @@ } }; @@ -52,13 +52,13 @@ } } -@@ -171,7 +197,14 @@ +@@ -155,7 +181,14 @@ ChatClickable chatclickable = chatmodifier.h(); if (chatclickable.a() == ChatClickable.EnumClickAction.RUN_COMMAND) { -- entityhuman.B_().getCommandHandler().a(icommandlistener, chatclickable.b()); +- entityhuman.C_().getCommandHandler().b(icommandlistener, chatclickable.b()); + // CraftBukkit start -+ // entityhuman.B_().getCommandHandler().a(icommandlistener, chatclickable.b()); ++ // entityhuman.C_().getCommandHandler().b(icommandlistener, chatclickable.b()); + CommandBlockListenerAbstract.executeSafely(icommandlistener, new org.bukkit.craftbukkit.command.ProxiedNativeCommandSender( + icommandlistener, + new org.bukkit.craftbukkit.command.CraftBlockCommandSender(icommandlistener), diff --git a/nms-patches/UserCache.patch b/nms-patches/UserCache.patch index 70ebb1ed..d04921fc 100644 --- a/nms-patches/UserCache.patch +++ b/nms-patches/UserCache.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/UserCache.java +++ b/net/minecraft/server/UserCache.java -@@ -45,7 +45,7 @@ +@@ -46,7 +46,7 @@ private static boolean c; private final Map<String, UserCache.UserCacheEntry> d = Maps.newHashMap(); private final Map<UUID, UserCache.UserCacheEntry> e = Maps.newHashMap(); @@ -9,7 +9,7 @@ private final GameProfileRepository g; protected final Gson b; private final File h; -@@ -336,11 +336,11 @@ +@@ -337,11 +337,11 @@ } } diff --git a/nms-patches/World.patch b/nms-patches/World.patch index 29f65c51..50b3b765 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -22,9 +22,9 @@ public abstract class World implements IBlockAccess { private int a = 63; -@@ -56,7 +71,51 @@ - private final WorldBorder N; - int[] H; +@@ -58,7 +73,51 @@ + private final WorldBorder P; + int[] J; - protected World(IDataManager idatamanager, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag) { + // CraftBukkit start Added the following @@ -73,12 +73,12 @@ + this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit + // CraftBukkit end this.u = Lists.newArrayList(new IWorldAccess[] { this.t}); - this.L = Calendar.getInstance(); + this.N = Calendar.getInstance(); this.scoreboard = new Scoreboard(); -@@ -69,6 +128,36 @@ +@@ -71,6 +130,36 @@ this.worldProvider = worldprovider; this.isClientSide = flag; - this.N = worldprovider.getWorldBorder(); + this.P = worldprovider.getWorldBorder(); + // CraftBukkit start + getWorldBorder().world = (WorldServer) this; + // From PlayerList.setPlayerFileData @@ -112,7 +112,7 @@ } public World b() { -@@ -206,6 +295,27 @@ +@@ -208,6 +297,27 @@ } public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { @@ -140,7 +140,7 @@ if (this.E(blockposition)) { return false; } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { -@@ -213,9 +323,23 @@ +@@ -215,9 +325,23 @@ } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); Block block = iblockdata.getBlock(); @@ -164,7 +164,7 @@ return false; } else { if (iblockdata.c() != iblockdata1.c() || iblockdata.d() != iblockdata1.d()) { -@@ -224,6 +348,7 @@ +@@ -226,6 +350,7 @@ this.methodProfiler.b(); } @@ -172,7 +172,7 @@ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && chunk.isReady()) { this.notify(blockposition, iblockdata1, iblockdata, i); } -@@ -236,12 +361,37 @@ +@@ -238,12 +363,37 @@ } else if (!this.isClientSide && (i & 16) == 0) { this.c(blockposition, block); } @@ -210,7 +210,7 @@ public boolean setAir(BlockPosition blockposition) { return this.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); } -@@ -275,6 +425,11 @@ +@@ -277,6 +427,11 @@ public void update(BlockPosition blockposition, Block block, boolean flag) { if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { @@ -222,7 +222,7 @@ this.applyPhysics(blockposition, block, flag); } -@@ -363,6 +518,17 @@ +@@ -365,6 +520,17 @@ IBlockData iblockdata = this.getType(blockposition); try { @@ -240,7 +240,7 @@ iblockdata.doPhysics(this, blockposition, block, blockposition1); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -580,6 +746,17 @@ +@@ -582,6 +748,17 @@ } public IBlockData getType(BlockPosition blockposition) { @@ -258,7 +258,7 @@ if (this.E(blockposition)) { return Blocks.AIR.getBlockData(); } else { -@@ -785,6 +962,13 @@ +@@ -787,6 +964,13 @@ } public boolean addEntity(Entity entity) { @@ -272,7 +272,7 @@ int i = MathHelper.floor(entity.locX / 16.0D); int j = MathHelper.floor(entity.locZ / 16.0D); boolean flag = entity.attachedToPlayer; -@@ -793,6 +977,37 @@ +@@ -795,6 +979,37 @@ flag = true; } @@ -310,7 +310,7 @@ if (!flag && !this.isChunkLoaded(i, j, false)) { return false; } else { -@@ -815,6 +1030,7 @@ +@@ -817,6 +1032,7 @@ ((IWorldAccess) this.u.get(i)).a(entity); } @@ -318,7 +318,7 @@ } protected void c(Entity entity) { -@@ -822,6 +1038,7 @@ +@@ -824,6 +1040,7 @@ ((IWorldAccess) this.u.get(i)).b(entity); } @@ -326,7 +326,7 @@ } public void kill(Entity entity) { -@@ -857,7 +1074,15 @@ +@@ -859,7 +1076,15 @@ this.getChunkAt(i, j).b(entity); } @@ -343,7 +343,7 @@ this.c(entity); } -@@ -974,7 +1199,7 @@ +@@ -976,7 +1201,7 @@ } public boolean a(AxisAlignedBB axisalignedbb) { @@ -352,7 +352,7 @@ } public int a(float f) { -@@ -1044,6 +1269,11 @@ +@@ -1046,6 +1271,11 @@ for (i = 0; i < this.j.size(); ++i) { entity = (Entity) this.j.get(i); @@ -364,7 +364,7 @@ try { ++entity.ticksLived; -@@ -1092,8 +1322,10 @@ +@@ -1094,8 +1324,10 @@ CrashReportSystemDetails crashreportsystemdetails1; CrashReport crashreport1; @@ -374,10 +374,10 @@ + for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) { + entity = (Entity) this.entityList.get(this.tickPosition); + // CraftBukkit end - Entity entity1 = entity.bB(); + Entity entity1 = entity.bH(); if (entity1 != null) { -@@ -1126,7 +1358,7 @@ +@@ -1128,7 +1360,7 @@ this.getChunkAt(j, l).b(entity); } @@ -386,10 +386,10 @@ this.c(entity); } -@@ -1135,6 +1367,13 @@ +@@ -1137,6 +1369,13 @@ this.methodProfiler.c("blockEntities"); - this.M = true; + this.O = true; + // CraftBukkit start - From below, clean up tile entities before ticking them + if (!this.tileEntityListUnload.isEmpty()) { + this.tileEntityListTick.removeAll(this.tileEntityListUnload); @@ -400,19 +400,19 @@ Iterator iterator = this.tileEntityListTick.iterator(); while (iterator.hasNext()) { -@@ -1145,7 +1384,7 @@ +@@ -1147,7 +1386,7 @@ - if (this.isLoaded(blockposition) && this.N.a(blockposition)) { + if (this.isLoaded(blockposition) && this.P.a(blockposition)) { try { - this.methodProfiler.a(tileentity.getClass().getSimpleName()); + this.methodProfiler.a("ticking"/*tileentity.getClass().getSimpleName()*/); // CraftBukkit: SPIGOT-1900 - ((ITickable) tileentity).F_(); + ((ITickable) tileentity).e(); this.methodProfiler.b(); } catch (Throwable throwable2) { -@@ -1167,11 +1406,13 @@ +@@ -1169,11 +1408,13 @@ } - this.M = false; + this.O = false; + /* CraftBukkit start - Moved up if (!this.tileEntityListUnload.isEmpty()) { this.tileEntityListTick.removeAll(this.tileEntityListUnload); @@ -423,7 +423,7 @@ this.methodProfiler.c("pendingBlockEntities"); if (!this.b.isEmpty()) { -@@ -1179,9 +1420,11 @@ +@@ -1181,9 +1422,11 @@ TileEntity tileentity1 = (TileEntity) this.b.get(i1); if (!tileentity1.y()) { @@ -435,7 +435,7 @@ if (this.isLoaded(tileentity1.getPosition())) { Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -1189,6 +1432,12 @@ +@@ -1191,6 +1434,12 @@ chunk.a(tileentity1.getPosition(), tileentity1); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); @@ -448,7 +448,7 @@ } } } -@@ -1243,7 +1492,10 @@ +@@ -1245,7 +1494,10 @@ int j = MathHelper.floor(entity.locZ); boolean flag1 = true; @@ -460,15 +460,15 @@ entity.M = entity.locX; entity.N = entity.locY; entity.O = entity.locZ; -@@ -1255,6 +1507,7 @@ - entity.aw(); +@@ -1257,6 +1509,7 @@ + entity.leaveVehicle(); } else { - entity.A_(); + entity.B_(); + entity.postTick(); // CraftBukkit } } -@@ -1547,11 +1800,18 @@ +@@ -1549,11 +1802,18 @@ } } @@ -486,8 +486,8 @@ + TileEntity tileentity = null; - if (this.M) { -@@ -1586,6 +1846,14 @@ + if (this.O) { +@@ -1588,6 +1848,14 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { if (!this.E(blockposition)) { if (tileentity != null && !tileentity.y()) { @@ -499,10 +499,10 @@ + return; + } + // CraftBukkit end - if (this.M) { + if (this.O) { tileentity.setPosition(blockposition); Iterator iterator = this.b.iterator(); -@@ -1745,6 +2013,14 @@ +@@ -1747,6 +2015,14 @@ } this.o = MathHelper.a(this.o, 0.0F, 1.0F); @@ -517,7 +517,7 @@ } } } -@@ -1876,7 +2152,10 @@ +@@ -1878,7 +2154,10 @@ } public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { @@ -529,7 +529,7 @@ return false; } else { int i = 0; -@@ -2043,7 +2322,7 @@ +@@ -2045,7 +2324,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -538,7 +538,7 @@ arraylist.add(entity); } } -@@ -2058,7 +2337,7 @@ +@@ -2060,7 +2339,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -547,7 +547,7 @@ arraylist.add(entity); } } -@@ -2107,7 +2386,7 @@ +@@ -2109,7 +2388,7 @@ } } @@ -556,12 +556,10 @@ } @Nullable -@@ -2128,8 +2407,17 @@ +@@ -2130,8 +2409,17 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); -- -- if ((!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) && oclass.isAssignableFrom(entity.getClass())) { + // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs + if (entity instanceof EntityInsentient) { + EntityInsentient entityinsentient = (EntityInsentient) entity; @@ -569,14 +567,15 @@ + continue; + } + } -+ + +- if ((!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) && oclass.isAssignableFrom(entity.getClass())) { + if (oclass.isAssignableFrom(entity.getClass())) { + // if ((!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) && oclass.isAssignableFrom(entity.getClass())) { + // CraftBukkit end ++i; } } -@@ -2138,12 +2426,18 @@ +@@ -2140,12 +2428,18 @@ } public void a(Collection<Entity> collection) { @@ -596,7 +595,7 @@ this.b(entity); } -@@ -2157,7 +2451,13 @@ +@@ -2159,7 +2453,13 @@ IBlockData iblockdata = this.getType(blockposition); AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().c(this, blockposition); @@ -610,8 +609,8 @@ + // CraftBukkit end } - public int K() { -@@ -2267,6 +2567,11 @@ + public int getSeaLevel() { +@@ -2269,6 +2569,11 @@ for (int i = 0; i < this.players.size(); ++i) { EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); @@ -623,7 +622,7 @@ if (predicate.apply(entityhuman1)) { double d5 = entityhuman1.d(d0, d1, d2); -@@ -2435,6 +2740,16 @@ +@@ -2437,6 +2742,16 @@ public void everyoneSleeping() {} @@ -640,7 +639,7 @@ public float h(float f) { return (this.p + (this.q - this.p) * f) * this.j(f); } -@@ -2652,7 +2967,7 @@ +@@ -2654,7 +2969,7 @@ int l = j * 16 + 8 - blockposition.getZ(); boolean flag = true; diff --git a/nms-patches/WorldGenRegistration.patch b/nms-patches/WorldGenRegistration.patch index cd4e2ca9..96462f92 100644 --- a/nms-patches/WorldGenRegistration.patch +++ b/nms-patches/WorldGenRegistration.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/WorldGenRegistration.java +++ b/net/minecraft/server/WorldGenRegistration.java @@ -157,7 +157,7 @@ - entitywitch.cS(); + entitywitch.cU(); entitywitch.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); entitywitch.prepare(world.D(new BlockPosition(i, j, k)), (GroupDataEntity) null); - world.addEntity(entitywitch); diff --git a/nms-patches/WorldGenVillagePieces.patch b/nms-patches/WorldGenVillagePieces.patch index 6f5ae761..7a3e2c53 100644 --- a/nms-patches/WorldGenVillagePieces.patch +++ b/nms-patches/WorldGenVillagePieces.patch @@ -29,7 +29,7 @@ @@ -1672,14 +1672,14 @@ entityzombievillager.prepare(world.D(new BlockPosition(entityzombievillager)), (GroupDataEntity) null); entityzombievillager.setProfession(this.c(i1, 0)); - entityzombievillager.cS(); + entityzombievillager.cU(); - world.addEntity(entityzombievillager); + world.addEntity(entityzombievillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } else { diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index caf5664b..f9271fd7 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -28,10 +28,10 @@ + private final HashTreeSet<NextTickListEntry> nextTickList = new HashTreeSet<NextTickListEntry>(); // CraftBukkit - HashTreeSet private final Map<UUID, Entity> entitiesByUUID = Maps.newHashMap(); public boolean savingDisabled; - private boolean O; + private boolean Q; @@ -38,14 +50,22 @@ - private int T; - private final List<NextTickListEntry> U = Lists.newArrayList(); + private int V; + private final List<NextTickListEntry> W = Lists.newArrayList(); - public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, WorldData worlddata, int i, MethodProfiler methodprofiler) { - super(idatamanager, worlddata, DimensionManager.a(i).d(), methodprofiler, false); @@ -52,8 +52,8 @@ this.chunkProvider = this.n(); - this.portalTravelAgent = new PortalTravelAgent(this); + this.portalTravelAgent = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit - this.H(); - this.I(); + this.J(); + this.K(); this.getWorldBorder().a(minecraftserver.aE()); @@ -64,6 +84,7 @@ this.villages.a((World) this); @@ -63,19 +63,32 @@ this.scoreboard = new ScoreboardServer(this.server); PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard.class, "scoreboard"); -@@ -74,6 +95,11 @@ +@@ -74,9 +95,21 @@ persistentscoreboard.a(this.scoreboard); ((ScoreboardServer) this.scoreboard).a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard))); +- this.B = new LootTableRegistry(new File(new File(this.dataManager.getDirectory(), "data"), "loot_tables")); +- this.C = new AdvancementDataWorld(new File(new File(this.dataManager.getDirectory(), "data"), "advancements")); +- this.D = new CustomFunctionData(new File(new File(this.dataManager.getDirectory(), "data"), "functions"), this.server); + // CraftBukkit start + } else { + this.scoreboard = getServer().getScoreboardManager().getMainScoreboard().getHandle(); + } ++ ++ if (this.B == null) { ++ this.B = new LootTableRegistry(new File(new File(this.dataManager.getDirectory(), "data"), "loot_tables")); ++ } ++ if (this.C == null) { ++ this.C = new AdvancementDataWorld(new File(new File(this.dataManager.getDirectory(), "data"), "advancements")); ++ } ++ if (this.D == null) { ++ this.D = new CustomFunctionData(new File(new File(this.dataManager.getDirectory(), "data"), "functions"), this.server); ++ } + // CraftBukkit end - this.B = new LootTableRegistry(new File(new File(this.dataManager.getDirectory(), "data"), "loot_tables")); this.getWorldBorder().setCenter(this.worldData.B(), this.worldData.C()); this.getWorldBorder().setDamageAmount(this.worldData.H()); -@@ -86,9 +112,98 @@ + this.getWorldBorder().setDamageBuffer(this.worldData.G()); +@@ -88,9 +121,98 @@ this.getWorldBorder().setSize(this.worldData.D()); } @@ -174,7 +187,7 @@ public void doTick() { super.doTick(); if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) { -@@ -107,8 +222,11 @@ +@@ -109,8 +231,11 @@ } this.methodProfiler.a("mobSpawner"); @@ -188,16 +201,16 @@ } this.methodProfiler.c("chunkSource"); -@@ -137,6 +255,8 @@ +@@ -139,6 +264,8 @@ this.portalTravelAgent.a(this.getTime()); this.methodProfiler.b(); - this.ao(); + this.aq(); + + this.getWorld().processChunkGC(); // CraftBukkit } @Nullable -@@ -164,7 +284,7 @@ +@@ -166,7 +293,7 @@ if (entityhuman.isSpectator()) { ++i; @@ -206,7 +219,7 @@ ++j; } } -@@ -193,25 +313,46 @@ +@@ -195,25 +322,46 @@ } private void c() { @@ -231,7 +244,7 @@ } public boolean everyoneDeeplySleeping() { - if (this.O && !this.isClientSide) { + if (this.Q && !this.isClientSide) { Iterator iterator = this.players.iterator(); + // CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers @@ -257,7 +270,7 @@ return false; } else { -@@ -281,7 +422,7 @@ +@@ -283,7 +431,7 @@ entityhorseskeleton.p(true); entityhorseskeleton.setAgeRaw(0); entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); @@ -266,7 +279,7 @@ this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), true)); } else { this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), false)); -@@ -297,11 +438,11 @@ +@@ -299,11 +447,11 @@ BlockPosition blockposition1 = blockposition.down(); if (this.v(blockposition1)) { @@ -280,7 +293,7 @@ } if (flag && this.getBiome(blockposition1).d()) { -@@ -376,7 +517,7 @@ +@@ -378,7 +526,7 @@ public boolean b(BlockPosition blockposition, Block block) { NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, block); @@ -289,7 +302,7 @@ } public void a(BlockPosition blockposition, Block block, int i) { -@@ -415,8 +556,8 @@ +@@ -412,8 +560,8 @@ nextticklistentry.a(j); } @@ -300,7 +313,7 @@ this.nextTickList.add(nextticklistentry); } } -@@ -438,15 +579,15 @@ +@@ -430,15 +578,15 @@ nextticklistentry.a((long) i + this.worldData.getTime()); } @@ -319,7 +332,7 @@ if (this.emptyTime++ >= 300) { return; } -@@ -516,11 +657,17 @@ +@@ -508,11 +656,17 @@ } else { int i = this.nextTickList.size(); @@ -339,7 +352,7 @@ } this.methodProfiler.a("cleaning"); -@@ -533,8 +680,9 @@ +@@ -525,8 +679,9 @@ break; } @@ -347,10 +360,10 @@ this.nextTickList.remove(nextticklistentry); - this.nextTickListHash.remove(nextticklistentry); + // this.nextTickListHash.remove(nextticklistentry); - this.U.add(nextticklistentry); + this.W.add(nextticklistentry); } -@@ -604,7 +752,7 @@ +@@ -596,7 +751,7 @@ if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) { if (flag) { if (i == 0) { @@ -359,7 +372,7 @@ } iterator.remove(); -@@ -622,6 +770,7 @@ +@@ -614,6 +769,7 @@ return arraylist; } @@ -367,7 +380,7 @@ public void entityJoinedWorld(Entity entity, boolean flag) { if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { entity.die(); -@@ -633,6 +782,7 @@ +@@ -625,6 +781,7 @@ super.entityJoinedWorld(entity, flag); } @@ -375,7 +388,7 @@ private boolean getSpawnNPCs() { return this.server.getSpawnNPCs(); -@@ -645,7 +795,54 @@ +@@ -637,7 +794,54 @@ protected IChunkProvider n() { IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider); @@ -431,7 +444,7 @@ } public boolean a(EntityHuman entityhuman, BlockPosition blockposition) { -@@ -707,6 +904,23 @@ +@@ -699,6 +903,23 @@ int j = this.worldProvider.getSeaLevel(); int k = 8; @@ -455,7 +468,7 @@ if (blockposition != null) { i = blockposition.getX(); k = blockposition.getZ(); -@@ -716,7 +930,7 @@ +@@ -708,7 +929,7 @@ int l = 0; @@ -464,7 +477,7 @@ i += random.nextInt(64) - random.nextInt(64); k += random.nextInt(64) - random.nextInt(64); ++l; -@@ -758,6 +972,7 @@ +@@ -750,6 +971,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkProviderServer(); if (chunkproviderserver.e()) { @@ -472,7 +485,7 @@ if (iprogressupdate != null) { iprogressupdate.a("Saving level"); } -@@ -768,7 +983,8 @@ +@@ -760,7 +982,8 @@ } chunkproviderserver.a(flag); @@ -482,7 +495,7 @@ Iterator iterator = arraylist.iterator(); while (iterator.hasNext()) { -@@ -803,6 +1019,12 @@ +@@ -795,6 +1018,12 @@ } } @@ -495,7 +508,7 @@ this.worldData.a(this.getWorldBorder().getSize()); this.worldData.d(this.getWorldBorder().getCenterX()); this.worldData.c(this.getWorldBorder().getCenterZ()); -@@ -816,9 +1038,13 @@ +@@ -808,9 +1037,13 @@ this.worldMaps.a(); } @@ -511,25 +524,25 @@ public void a(Collection<Entity> collection) { ArrayList arraylist = Lists.newArrayList(collection); -@@ -837,7 +1063,7 @@ +@@ -829,7 +1062,7 @@ private boolean j(Entity entity) { if (entity.dead) { -- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.a(entity)}); -+ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.a(entity)}); // CraftBukkit +- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity)); ++ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity)); // CraftBukkit return false; } else { UUID uuid = entity.getUniqueID(); -@@ -849,7 +1075,7 @@ +@@ -841,7 +1074,7 @@ this.f.remove(entity1); } else { if (!(entity instanceof EntityHuman)) { -- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.a(entity1), uuid.toString()}); -+ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.a(entity1), uuid.toString()}); // CraftBukkit +- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.a(entity1), uuid.toString()); ++ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.a(entity1), uuid.toString()); // CraftBukkit return false; } -@@ -902,8 +1128,16 @@ +@@ -894,8 +1127,16 @@ } public boolean strikeLightning(Entity entity) { @@ -547,7 +560,7 @@ return true; } else { return false; -@@ -919,10 +1153,20 @@ +@@ -911,10 +1152,20 @@ } public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { @@ -568,7 +581,7 @@ if (!flag1) { explosion.clearBlocks(); } -@@ -968,7 +1212,8 @@ +@@ -960,7 +1211,8 @@ BlockActionData blockactiondata = (BlockActionData) iterator.next(); if (this.a(blockactiondata)) { @@ -578,20 +591,20 @@ } } -@@ -991,6 +1236,7 @@ - boolean flag = this.W(); +@@ -983,6 +1235,7 @@ + boolean flag = this.Y(); super.t(); + /* CraftBukkit start if (this.n != this.o) { this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID()); } -@@ -1009,6 +1255,21 @@ +@@ -1001,6 +1254,21 @@ this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o)); this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q)); } + // */ -+ if (flag != this.W()) { ++ if (flag != this.X()) { + // Only send weather packets to those affected + for (int i = 0; i < this.players.size(); ++i) { + if (((EntityPlayer) this.players.get(i)).world == this) { @@ -608,7 +621,7 @@ } -@@ -1038,10 +1299,20 @@ +@@ -1030,10 +1298,20 @@ } public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) { @@ -4,20 +4,20 @@ <groupId>org.bukkit</groupId> <artifactId>craftbukkit</artifactId> <packaging>jar</packaging> - <version>1.11.2-R0.1-SNAPSHOT</version> + <version>1.12-pre2-SNAPSHOT</version> <name>CraftBukkit</name> <url>http://www.bukkit.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <api.version>unknown</api.version> - <minecraft.version>1.11.2</minecraft.version> - <minecraft_version>1_11_R1</minecraft_version> + <minecraft.version>1.12-pre2</minecraft.version> + <minecraft_version>1_12_R1</minecraft_version> <buildtag.prefix>git-Bukkit-</buildtag.prefix> <buildtag.suffix></buildtag.suffix> <maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format> - <maven.compiler.source>1.6</maven.compiler.source> - <maven.compiler.target>1.6</maven.compiler.target> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> @@ -36,7 +36,7 @@ <dependency> <groupId>net.sf.jopt-simple</groupId> <artifactId>jopt-simple</artifactId> - <version>4.9</version> + <version>5.0.3</version> <scope>compile</scope> </dependency> <dependency> @@ -54,7 +54,7 @@ <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> - <version>5.1.40</version> + <version>6.0.6</version> <scope>compile</scope> </dependency> <!-- testing --> @@ -152,15 +152,15 @@ <configuration> <signature> <groupId>org.codehaus.mojo.signature</groupId> - <artifactId>java16</artifactId> - <version>1.1</version> + <artifactId>java18</artifactId> + <version>1.0</version> </signature> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> - <version>2.4.3</version> + <version>3.0.0</version> <executions> <execution> <phase>package</phase> @@ -178,12 +178,8 @@ <shadedPattern>org.bukkit.craftbukkit.libs.jline</shadedPattern> </relocation> <relocation> - <pattern>org.ibex</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.ibex</shadedPattern> - </relocation> - <relocation> - <pattern>org.gjt</pattern> - <shadedPattern>org.bukkit.craftbukkit.libs.org.gjt</shadedPattern> + <pattern>it.unimi</pattern> + <shadedPattern>org.bukkit.craftbukkit.libs.it.unimi</shadedPattern> </relocation> <relocation> <pattern>org.bukkit.craftbukkit</pattern> diff --git a/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java deleted file mode 100644 index 341eaa33..00000000 --- a/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache license, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the license for the specific language governing permissions and - * limitations under the license. - */ -package org.apache.logging.log4j.core.appender; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Constructor; -import java.nio.charset.Charset; - -import org.apache.logging.log4j.core.Filter; -import org.apache.logging.log4j.core.Layout; -import org.apache.logging.log4j.core.config.plugins.Plugin; -import org.apache.logging.log4j.core.config.plugins.PluginAttribute; -import org.apache.logging.log4j.core.config.plugins.PluginElement; -import org.apache.logging.log4j.core.config.plugins.PluginFactory; -import org.apache.logging.log4j.core.helpers.Booleans; -import org.apache.logging.log4j.core.helpers.Loader; -import org.apache.logging.log4j.core.layout.PatternLayout; -import org.apache.logging.log4j.util.PropertiesUtil; - -/** - * ConsoleAppender appends log events to <code>System.out</code> or - * <code>System.err</code> using a layout specified by the user. The - * default target is <code>System.out</code>. - * @doubt accessing System.out or .err as a byte stream instead of a writer - * bypasses the JVM's knowledge of the proper encoding. (RG) Encoding - * is handled within the Layout. Typically, a Layout will generate a String - * and then call getBytes which may use a configured encoding or the system - * default. OTOH, a Writer cannot print byte streams. - */ -@Plugin(name = "Console", category = "Core", elementType = "appender", printObject = true) -public final class ConsoleAppender extends AbstractOutputStreamAppender { - - private static final String JANSI_CLASS = "org.fusesource.jansi.WindowsAnsiOutputStream"; - private static ConsoleManagerFactory factory = new ConsoleManagerFactory(); - - /** - * Enumeration of console destinations. - */ - public enum Target { - /** Standard output. */ - SYSTEM_OUT, - /** Standard error output. */ - SYSTEM_ERR - } - - private ConsoleAppender(final String name, final Layout<? extends Serializable> layout, final Filter filter, - final OutputStreamManager manager, - final boolean ignoreExceptions) { - super(name, layout, filter, ignoreExceptions, true, manager); - } - - /** - * Create a Console Appender. - * @param layout The layout to use (required). - * @param filter The Filter or null. - * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT". - * @param follow If true will follow changes to the underlying output stream. - * @param name The name of the Appender (required). - * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise - * they are propagated to the caller. - * @return The ConsoleAppender. - */ - @PluginFactory - public static ConsoleAppender createAppender( - @PluginElement("Layout") Layout<? extends Serializable> layout, - @PluginElement("Filters") final Filter filter, - @PluginAttribute("target") final String t, - @PluginAttribute("name") final String name, - @PluginAttribute("follow") final String follow, - @PluginAttribute("ignoreExceptions") final String ignore) { - if (name == null) { - LOGGER.error("No name provided for ConsoleAppender"); - return null; - } - if (layout == null) { - layout = PatternLayout.createLayout(null, null, null, null, null); - } - final boolean isFollow = Boolean.parseBoolean(follow); - final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true); - final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t); - return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions); - } - - private static OutputStreamManager getManager(final boolean follow, final Target target, final Layout<? extends Serializable> layout) { - final String type = target.name(); - final OutputStream os = getOutputStream(follow, target); - return OutputStreamManager.getManager(target.name() + "." + follow, new FactoryData(os, type, layout), factory); - } - - private static OutputStream getOutputStream(final boolean follow, final Target target) { - final String enc = Charset.defaultCharset().name(); - PrintStream printStream = null; - try { - printStream = target == Target.SYSTEM_OUT ? - follow ? new PrintStream(new SystemOutStream(), true, enc) : System.out : - follow ? new PrintStream(new SystemErrStream(), true, enc) : System.err; - } catch (final UnsupportedEncodingException ex) { // should never happen - throw new IllegalStateException("Unsupported default encoding " + enc, ex); - } - final PropertiesUtil propsUtil = PropertiesUtil.getProperties(); - if (!propsUtil.getStringProperty("os.name").startsWith("Windows") || - propsUtil.getBooleanProperty("log4j.skipJansi")) { - return printStream; - } - try { - final ClassLoader loader = Loader.getClassLoader(); - // We type the parameter as a wildcard to avoid a hard reference to Jansi. - final Class<?> clazz = loader.loadClass(JANSI_CLASS); - final Constructor<?> constructor = clazz.getConstructor(OutputStream.class); - return (OutputStream) constructor.newInstance(printStream); - } catch (final ClassNotFoundException cnfe) { - LOGGER.debug("Jansi is not installed, cannot find {}", JANSI_CLASS); - } catch (final NoSuchMethodException nsme) { - LOGGER.warn("{} is missing the proper constructor", JANSI_CLASS); - } catch (final Throwable ex) { // CraftBukkit - Exception -> Throwable - LOGGER.warn("Unable to instantiate {}", JANSI_CLASS); - } - return printStream; - } - - /** - * An implementation of OutputStream that redirects to the current System.err. - */ - private static class SystemErrStream extends OutputStream { - public SystemErrStream() { - } - - @Override - public void close() { - // do not close sys err! - } - - @Override - public void flush() { - System.err.flush(); - } - - @Override - public void write(final byte[] b) throws IOException { - System.err.write(b); - } - - @Override - public void write(final byte[] b, final int off, final int len) - throws IOException { - System.err.write(b, off, len); - } - - @Override - public void write(final int b) { - System.err.write(b); - } - } - - /** - * An implementation of OutputStream that redirects to the current System.out. - */ - private static class SystemOutStream extends OutputStream { - public SystemOutStream() { - } - - @Override - public void close() { - // do not close sys out! - } - - @Override - public void flush() { - System.out.flush(); - } - - @Override - public void write(final byte[] b) throws IOException { - System.out.write(b); - } - - @Override - public void write(final byte[] b, final int off, final int len) - throws IOException { - System.out.write(b, off, len); - } - - @Override - public void write(final int b) throws IOException { - System.out.write(b); - } - } - - /** - * Data to pass to factory method. - */ - private static class FactoryData { - private final OutputStream os; - private final String type; - private final Layout<? extends Serializable> layout; - - /** - * Constructor. - * @param os The OutputStream. - * @param type The name of the target. - * @param layout A Serializable layout - */ - public FactoryData(final OutputStream os, final String type, final Layout<? extends Serializable> layout) { - this.os = os; - this.type = type; - this.layout = layout; - } - } - - /** - * Factory to create the Appender. - */ - private static class ConsoleManagerFactory implements ManagerFactory<OutputStreamManager, FactoryData> { - - /** - * Create an OutputStreamManager. - * @param name The name of the entity to manage. - * @param data The data required to create the entity. - * @return The OutputStreamManager - */ - @Override - public OutputStreamManager createManager(final String name, final FactoryData data) { - return new OutputStreamManager(data.os, data.type, data.layout); - } - } - -} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 50e1349a..b7f0ef94 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -114,12 +114,9 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.error.MarkedYAMLException; import org.apache.commons.lang.Validate; -import com.avaje.ebean.config.DataSourceConfig; -import com.avaje.ebean.config.ServerConfig; -import com.avaje.ebean.config.dbplatform.SQLitePlatform; -import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation; import com.google.common.base.Charsets; import com.google.common.base.Function; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; @@ -130,6 +127,8 @@ import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; import io.netty.handler.codec.base64.Base64; import jline.console.ConsoleReader; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.event.server.TabCompleteEvent; public final class CraftServer implements Server { @@ -150,7 +149,7 @@ public final class CraftServer implements Server { private YamlConfiguration configuration; private YamlConfiguration commandsConfiguration; private final Yaml yaml = new Yaml(new SafeConstructor()); - private final Map<UUID, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap(); + private final Map<UUID, OfflinePlayer> offlinePlayers = new MapMaker().weakValues().makeMap(); private final EntityMetadataStore entityMetadata = new EntityMetadataStore(); private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore(); private final WorldMetadataStore worldMetadata = new WorldMetadataStore(); @@ -380,13 +379,6 @@ public final class CraftServer implements Server { } @Override - @Deprecated - @SuppressWarnings("unchecked") - public Player[] _INVALID_getOnlinePlayers() { - return getOnlinePlayers().toArray(EMPTY_PLAYER_ARRAY); - } - - @Override public List<CraftPlayer> getOnlinePlayers() { return this.playerView; } @@ -698,6 +690,7 @@ public final class CraftServer implements Server { pluginManager.clearPlugins(); commandMap.clearCommands(); resetRecipes(); + reloadData(); overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*"); int pollCount = 0; @@ -729,6 +722,11 @@ public final class CraftServer implements Server { enablePlugins(PluginLoadOrder.POSTWORLD); } + @Override + public void reloadData() { + console.reload(); + } + private void loadIcon() { icon = new CraftIconCache(null); try { @@ -832,7 +830,7 @@ public final class CraftServer implements Server { generator = getGenerator(name); } - Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().getDataConverterManager()); + Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().dataConverterManager); if (converter.isConvertable(name)) { getLogger().info("Converting world '" + name + "'"); converter.convert(name, new IProgressUpdate() { @@ -865,7 +863,7 @@ public final class CraftServer implements Server { } while(used); boolean hardcore = false; - IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().getDataConverterManager()); + IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().dataConverterManager); WorldData worlddata = sdm.getWorldData(); WorldSettings worldSettings = null; if (worlddata == null) { @@ -1025,25 +1023,6 @@ public final class CraftServer implements Server { } @Override - public void configureDbConfig(ServerConfig config) { - Validate.notNull(config, "Config cannot be null"); - - DataSourceConfig ds = new DataSourceConfig(); - ds.setDriver(configuration.getString("database.driver")); - ds.setUrl(configuration.getString("database.url")); - ds.setUsername(configuration.getString("database.username")); - ds.setPassword(configuration.getString("database.password")); - ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation"))); - - if (ds.getDriver().contains("sqlite")) { - config.setDatabasePlatform(new SQLitePlatform()); - config.getDatabasePlatform().getDbDdlSyntax().setIdentity(""); - } - - config.setDataSourceConfig(ds); - } - - @Override public boolean addRecipe(Recipe recipe) { CraftRecipe toAdd; if (recipe instanceof CraftRecipe) { @@ -1060,7 +1039,6 @@ public final class CraftServer implements Server { } } toAdd.addToCraftingManager(); - CraftingManager.getInstance().sort(); return true; } @@ -1090,7 +1068,7 @@ public final class CraftServer implements Server { @Override public void clearRecipes() { - CraftingManager.getInstance().recipes.clear(); + CraftingManager.recipes = new RegistryMaterials(); RecipesFurnace.getInstance().recipes.clear(); RecipesFurnace.getInstance().customRecipes.clear(); RecipesFurnace.getInstance().customExperience.clear(); @@ -1098,7 +1076,8 @@ public final class CraftServer implements Server { @Override public void resetRecipes() { - CraftingManager.getInstance().recipes = new CraftingManager().recipes; + CraftingManager.recipes = new RegistryMaterials(); + CraftingManager.init(); RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes; RecipesFurnace.getInstance().customRecipes.clear(); RecipesFurnace.getInstance().customExperience.clear(); @@ -1674,6 +1653,14 @@ public final class CraftServer implements Server { return entity == null ? null : entity.getBukkitEntity(); } + @Override + public org.bukkit.advancement.Advancement getAdvancement(NamespacedKey key) { + Preconditions.checkArgument(key != null, "key"); + + Advancement advancement = console.getAdvancementData().a(CraftNamespacedKey.toMinecraft(key)); + return (advancement == null) ? null : advancement.bukkit; + } + @Deprecated @Override public UnsafeValues getUnsafe() { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index 82ab6491..9588ba11 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -37,6 +37,8 @@ public enum CraftSound { BLOCK_ENDERCHEST_CLOSE("block.enderchest.close"), BLOCK_ENDERCHEST_OPEN("block.enderchest.open"), BLOCK_END_GATEWAY_SPAWN("block.end_gateway.spawn"), + BLOCK_END_PORTAL_FRAME_FILL("block.end_portal_frame.fill"), + BLOCK_END_PORTAL_SPAWN("block.end_portal.spawn"), BLOCK_FENCE_GATE_CLOSE("block.fence_gate.close"), BLOCK_FENCE_GATE_OPEN("block.fence_gate.open"), BLOCK_FIRE_AMBIENT("block.fire.ambient"), @@ -79,10 +81,15 @@ public enum CraftSound { BLOCK_METAL_STEP("block.metal.step"), BLOCK_NOTE_BASEDRUM("block.note.basedrum"), BLOCK_NOTE_BASS("block.note.bass"), + BLOCK_NOTE_BELL("block.note.bell"), + BLOCK_NOTE_CHIME("block.note.chime"), + BLOCK_NOTE_FLUTE("block.note.flute"), + BLOCK_NOTE_GUITAR("block.note.guitar"), BLOCK_NOTE_HARP("block.note.harp"), BLOCK_NOTE_HAT("block.note.hat"), BLOCK_NOTE_PLING("block.note.pling"), BLOCK_NOTE_SNARE("block.note.snare"), + BLOCK_NOTE_XYLOPHONE("block.note.xylophone"), BLOCK_PISTON_CONTRACT("block.piston.contract"), BLOCK_PISTON_EXTEND("block.piston.extend"), BLOCK_PORTAL_AMBIENT("block.portal.ambient"), @@ -152,6 +159,9 @@ public enum CraftSound { ENTITY_BLAZE_DEATH("entity.blaze.death"), ENTITY_BLAZE_HURT("entity.blaze.hurt"), ENTITY_BLAZE_SHOOT("entity.blaze.shoot"), + ENTITY_BOAT_PADDLE_LAND("entity.boat.paddle_land"), + ENTITY_BOAT_PADDLE_WATER("entity.boat.paddle_water"), + ENTITY_BOBBER_RETRIEVE("entity.bobber.retrieve"), ENTITY_BOBBER_SPLASH("entity.bobber.splash"), ENTITY_BOBBER_THROW("entity.bobber.throw"), ENTITY_CAT_AMBIENT("entity.cat.ambient"), @@ -194,6 +204,7 @@ public enum CraftSound { ENTITY_ENDERDRAGON_GROWL("entity.enderdragon.growl"), ENTITY_ENDERDRAGON_HURT("entity.enderdragon.hurt"), ENTITY_ENDERDRAGON_SHOOT("entity.enderdragon.shoot"), + ENTITY_ENDEREYE_DEATH("entity.endereye.death"), ENTITY_ENDEREYE_LAUNCH("entity.endereye.launch"), ENTITY_ENDERMEN_AMBIENT("entity.endermen.ambient"), ENTITY_ENDERMEN_DEATH("entity.endermen.death"), @@ -272,6 +283,13 @@ public enum CraftSound { ENTITY_HUSK_DEATH("entity.husk.death"), ENTITY_HUSK_HURT("entity.husk.hurt"), ENTITY_HUSK_STEP("entity.husk.step"), + ENTITY_ILLUSION_ILLAGER_AMBIENT("entity.illusion_illager.ambient"), + ENTITY_ILLUSION_ILLAGER_CAST_SPELL("entity.illusion_illager.cast_spell"), + ENTITY_ILLUSION_ILLAGER_DEATH("entity.illusion_illager.death"), + ENTITY_ILLUSION_ILLAGER_HURT("entity.illusion_illager.hurt"), + ENTITY_ILLUSION_ILLAGER_MIRROR_MOVE("entity.illusion_illager.mirror_move"), + ENTITY_ILLUSION_ILLAGER_PREPARE_BLINDNESS("entity.illusion_illager.prepare_blindness"), + ENTITY_ILLUSION_ILLAGER_PREPARE_MIRROR("entity.illusion_illager.prepare_mirror"), ENTITY_IRONGOLEM_ATTACK("entity.irongolem.attack"), ENTITY_IRONGOLEM_DEATH("entity.irongolem.death"), ENTITY_IRONGOLEM_HURT("entity.irongolem.hurt"), @@ -310,6 +328,39 @@ public enum CraftSound { ENTITY_MULE_HURT("entity.mule.hurt"), ENTITY_PAINTING_BREAK("entity.painting.break"), ENTITY_PAINTING_PLACE("entity.painting.place"), + ENTITY_PARROT_AMBIENT("entity.parrot.ambient"), + ENTITY_PARROT_DEATH("entity.parrot.death"), + ENTITY_PARROT_EAT("entity.parrot.eat"), + ENTITY_PARROT_FLY("entity.parrot.fly"), + ENTITY_PARROT_HURT("entity.parrot.hurt"), + ENTITY_PARROT_IMITATE_BLAZE("entity.parrot.imitate.blaze"), + ENTITY_PARROT_IMITATE_CREEPER("entity.parrot.imitate.creeper"), + ENTITY_PARROT_IMITATE_ELDER_GUARDIAN("entity.parrot.imitate.elder_guardian"), + ENTITY_PARROT_IMITATE_ENDERDRAGON("entity.parrot.imitate.enderdragon"), + ENTITY_PARROT_IMITATE_ENDERMAN("entity.parrot.imitate.enderman"), + ENTITY_PARROT_IMITATE_ENDERMITE("entity.parrot.imitate.endermite"), + ENTITY_PARROT_IMITATE_EVOCATION_ILLAGER("entity.parrot.imitate.evocation_illager"), + ENTITY_PARROT_IMITATE_GHAST("entity.parrot.imitate.ghast"), + ENTITY_PARROT_IMITATE_HUSK("entity.parrot.imitate.husk"), + ENTITY_PARROT_IMITATE_ILLUSION_ILLAGER("entity.parrot.imitate.illusion_illager"), + ENTITY_PARROT_IMITATE_MAGMACUBE("entity.parrot.imitate.magmacube"), + ENTITY_PARROT_IMITATE_POLAR_BEAR("entity.parrot.imitate.polar_bear"), + ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"), + ENTITY_PARROT_IMITATE_SILVERFISH("entity.parrot.imitate.silverfish"), + ENTITY_PARROT_IMITATE_SKELETON("entity.parrot.imitate.skeleton"), + ENTITY_PARROT_IMITATE_SLIME("entity.parrot.imitate.slime"), + ENTITY_PARROT_IMITATE_SPIDER("entity.parrot.imitate.spider"), + ENTITY_PARROT_IMITATE_STRAY("entity.parrot.imitate.stray"), + ENTITY_PARROT_IMITATE_VEX("entity.parrot.imitate.vex"), + ENTITY_PARROT_IMITATE_VINDICATION_ILLAGER("entity.parrot.imitate.vindication_illager"), + ENTITY_PARROT_IMITATE_WITCH("entity.parrot.imitate.witch"), + ENTITY_PARROT_IMITATE_WITHER("entity.parrot.imitate.wither"), + ENTITY_PARROT_IMITATE_WITHER_SKELETON("entity.parrot.imitate.wither_skeleton"), + ENTITY_PARROT_IMITATE_WOLF("entity.parrot.imitate.wolf"), + ENTITY_PARROT_IMITATE_ZOMBIE("entity.parrot.imitate.zombie"), + ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN("entity.parrot.imitate.zombie_pigman"), + ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER("entity.parrot.imitate.zombie_villager"), + ENTITY_PARROT_STEP("entity.parrot.step"), ENTITY_PIG_AMBIENT("entity.pig.ambient"), ENTITY_PIG_DEATH("entity.pig.death"), ENTITY_PIG_HURT("entity.pig.hurt"), @@ -326,6 +377,8 @@ public enum CraftSound { ENTITY_PLAYER_BURP("entity.player.burp"), ENTITY_PLAYER_DEATH("entity.player.death"), ENTITY_PLAYER_HURT("entity.player.hurt"), + ENTITY_PLAYER_HURT_DROWN("entity.player.hurt_drown"), + ENTITY_PLAYER_HURT_ON_FIRE("entity.player.hurt_on_fire"), ENTITY_PLAYER_LEVELUP("entity.player.levelup"), ENTITY_PLAYER_SMALL_FALL("entity.player.small_fall"), ENTITY_PLAYER_SPLASH("entity.player.splash"), diff --git a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index 4281004f..5c069586 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -4,7 +4,6 @@ import net.minecraft.server.EntityTypes; import net.minecraft.server.EntityTypes.MonsterEggInfo; import net.minecraft.server.StatisticList; -import org.bukkit.Achievement; import org.bukkit.Statistic; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -12,7 +11,6 @@ import org.bukkit.entity.EntityType; import com.google.common.base.CaseFormat; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; -import com.google.common.collect.ImmutableMap; import net.minecraft.server.Block; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; @@ -20,21 +18,9 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftStatistic { private static final BiMap<String, org.bukkit.Statistic> statistics; - private static final BiMap<String, org.bukkit.Achievement> achievements; static { - ImmutableMap<String, org.bukkit.Achievement> specialCases = ImmutableMap.<String, org.bukkit.Achievement> builder() - .put("achievement.buildWorkBench", Achievement.BUILD_WORKBENCH) - .put("achievement.diamonds", Achievement.GET_DIAMONDS) - .put("achievement.portal", Achievement.NETHER_PORTAL) - .put("achievement.ghast", Achievement.GHAST_RETURN) - .put("achievement.theEnd", Achievement.END_PORTAL) - .put("achievement.theEnd2", Achievement.THE_END) - .put("achievement.blazeRod", Achievement.GET_BLAZE_ROD) - .put("achievement.potion", Achievement.BREW_POTION) - .build(); ImmutableBiMap.Builder<String, org.bukkit.Statistic> statisticBuilder = ImmutableBiMap.<String, org.bukkit.Statistic>builder(); - ImmutableBiMap.Builder<String, org.bukkit.Achievement> achievementBuilder = ImmutableBiMap.<String, org.bukkit.Achievement>builder(); for (Statistic statistic : Statistic.values()) { if (statistic == Statistic.PLAY_ONE_TICK) { statisticBuilder.put("stat.playOneMinute", statistic); @@ -42,29 +28,12 @@ public class CraftStatistic { statisticBuilder.put("stat." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, statistic.name()), statistic); } } - for (Achievement achievement : Achievement.values()) { - if (specialCases.values().contains(achievement)) { - continue; - } - achievementBuilder.put("achievement." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, achievement.name()), achievement); - } - - achievementBuilder.putAll(specialCases); statistics = statisticBuilder.build(); - achievements = achievementBuilder.build(); } private CraftStatistic() {} - public static org.bukkit.Achievement getBukkitAchievement(net.minecraft.server.Achievement achievement) { - return getBukkitAchievementByName(achievement.name); - } - - public static org.bukkit.Achievement getBukkitAchievementByName(String name) { - return achievements.get(name); - } - public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic statistic) { return getBukkitStatisticByName(statistic.name); } @@ -101,10 +70,6 @@ public class CraftStatistic { return StatisticList.getStatistic(statistics.inverse().get(statistic)); } - public static net.minecraft.server.Achievement getNMSAchievement(org.bukkit.Achievement achievement) { - return (net.minecraft.server.Achievement) StatisticList.getStatistic(achievements.inverse().get(achievement)); - } - public static net.minecraft.server.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) { try { if (stat == Statistic.MINE_BLOCK) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 191501ec..2574bee4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -599,7 +599,7 @@ public class CraftWorld implements World { byte[] biomevals = chunk.getBiomeIndex(); biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte) BiomeBase.REGISTRY_ID.a(bb); - chunk.e(); // SPIGOT-2890 // PAIL: markDirty + chunk.markDirty(); // SPIGOT-2890 } } } @@ -1041,6 +1041,8 @@ public class CraftWorld implements World { entity = new EntityWolf(world); } else if (Ocelot.class.isAssignableFrom(clazz)) { entity = new EntityOcelot(world); + } else if (Parrot.class.isAssignableFrom(clazz)) { + entity = new EntityParrot(world); } } else if (PigZombie.class.isAssignableFrom(clazz)) { entity = new EntityPigZombie(world); @@ -1088,12 +1090,18 @@ public class CraftWorld implements World { entity = new EntityArmorStand(world, x, y, z); } else if (PolarBear.class.isAssignableFrom(clazz)) { entity = new EntityPolarBear(world); - } else if (Evoker.class.isAssignableFrom(clazz)) { - entity = new EntityEvoker(world); } else if (Vex.class.isAssignableFrom(clazz)) { entity = new EntityVex(world); - } else if (Vindicator.class.isAssignableFrom(clazz)) { - entity = new EntityVindicator(world); + } else if (Illager.class.isAssignableFrom(clazz)) { + if (Spellcaster.class.isAssignableFrom(clazz)) { + if (Evoker.class.isAssignableFrom(clazz)) { + entity = new EntityEvoker(world); + } else if (Illusioner.class.isAssignableFrom(clazz)) { + entity = new EntityIllagerIllusioner(world); + } + } else if (Vindicator.class.isAssignableFrom(clazz)) { + entity = new EntityVindicator(world); + } } if (entity != null) { @@ -1227,7 +1235,7 @@ public class CraftWorld implements World { } public int getSeaLevel() { - return world.K(); // PAIL: rename + return world.getSeaLevel(); } public boolean getKeepSpawnInMemory() { diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index f4e1ca79..959a63b9 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -169,11 +169,11 @@ public class Main { useConsole = false; } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { Date buildDate = new SimpleDateFormat("yyyyMMdd-HHmm").parse(Main.class.getPackage().getImplementationVendor()); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -14); + deadline.add(Calendar.DAY_OF_YEAR, -3); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/ ***"); diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java new file mode 100644 index 00000000..a5aadf28 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.advancement; + +import java.util.Collection; +import java.util.Collections; +import net.minecraft.server.Advancement; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; + +public class CraftAdvancement implements org.bukkit.advancement.Advancement { + + private final Advancement handle; + + public CraftAdvancement(Advancement handle) { + this.handle = handle; + } + + public Advancement getHandle() { + return handle; + } + + @Override + public NamespacedKey getKey() { + return CraftNamespacedKey.fromMinecraft(handle.getName()); + } + + @Override + public Collection<String> getCriteria() { + return Collections.unmodifiableCollection(handle.getCriteria().keySet()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementProgress.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementProgress.java new file mode 100644 index 00000000..60fc5aff --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementProgress.java @@ -0,0 +1,59 @@ +package org.bukkit.craftbukkit.advancement; + +import com.google.common.collect.Lists; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import net.minecraft.server.AdvancementDataPlayer; +import net.minecraft.server.CriterionProgress; +import org.bukkit.advancement.Advancement; +import org.bukkit.advancement.AdvancementProgress; + +public class CraftAdvancementProgress implements AdvancementProgress { + + private final CraftAdvancement advancement; + private final AdvancementDataPlayer playerData; + private final net.minecraft.server.AdvancementProgress handle; + + public CraftAdvancementProgress(CraftAdvancement advancement, AdvancementDataPlayer player, net.minecraft.server.AdvancementProgress handle) { + this.advancement = advancement; + this.playerData = player; + this.handle = handle; + } + + @Override + public Advancement getAdvancement() { + return advancement; + } + + @Override + public boolean isDone() { + return handle.isDone(); + } + + @Override + public boolean awardCriteria(String criteria) { + return playerData.grantCriteria(advancement.getHandle(), criteria); + } + + @Override + public boolean revokeCriteria(String criteria) { + return playerData.revokeCritera(advancement.getHandle(), criteria); + } + + @Override + public Date getDateAwarded(String criteria) { + CriterionProgress criterion = handle.getCriterionProgress(criteria); + return (criterion == null) ? null : criterion.getDate(); + } + + @Override + public Collection<String> getRemainingCriteria() { + return Collections.unmodifiableCollection(Lists.newArrayList(handle.getRemainingCriteria())); + } + + @Override + public Collection<String> getAwardedCriteria() { + return Collections.unmodifiableCollection(Lists.newArrayList(handle.getAwardedCriteria())); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index 049bae34..a679221a 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -96,6 +96,6 @@ public class CraftBeacon extends CraftContainer implements Beacon { @Override public void setCustomName(String name) { - beacon.a(name); // PAIL: setCustomName + beacon.setCustomName(name); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java new file mode 100644 index 00000000..f6083565 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java @@ -0,0 +1,60 @@ +package org.bukkit.craftbukkit.block; + +import com.google.common.base.Preconditions; +import net.minecraft.server.EnumColor; +import net.minecraft.server.TileEntity; +import net.minecraft.server.TileEntityBed; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.block.Bed; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.CraftWorld; + +public class CraftBed extends CraftBlockState implements Bed { + + private final TileEntityBed bed; + private DyeColor color; + + public CraftBed(Block block) { + super(block); + + bed = (TileEntityBed) ((CraftWorld) block.getWorld()).getTileEntityAt(getX(), getY(), getZ()); + color = DyeColor.getByWoolData((byte) bed.a().getColorIndex()); + } + + public CraftBed(Material material, TileEntityBed te) { + super(material); + + bed = te; + color = DyeColor.getByWoolData((byte) bed.a().getColorIndex()); + } + + @Override + public TileEntity getTileEntity() { + return bed; + } + + @Override + public DyeColor getColor() { + return color; + } + + @Override + public void setColor(DyeColor color) { + Preconditions.checkArgument(color != null, "color"); + + this.color = color; + } + + @Override + public boolean update(boolean force, boolean applyPhysics) { + boolean result = super.update(force, applyPhysics); + + if (result) { + bed.a(EnumColor.fromColorIndex(color.getWoolData())); + bed.update(); + } + + return result; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index e7d164f4..a2d63379 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -333,6 +333,8 @@ public class CraftBlock implements Block { case REDSTONE_COMPARATOR_OFF: case REDSTONE_COMPARATOR_ON: return new CraftComparator(this); + case BED_BLOCK: + return new CraftBed(this); default: return new CraftBlockState(this); } @@ -351,7 +353,7 @@ public class CraftBlock implements Block { return null; } - return Biome.valueOf(BiomeBase.REGISTRY_ID.b(base).a().toUpperCase(java.util.Locale.ENGLISH)); + return Biome.valueOf(BiomeBase.REGISTRY_ID.b(base).getKey().toUpperCase(java.util.Locale.ENGLISH)); } public static BiomeBase biomeToBiomeBase(Biome bio) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java index e8a66359..78e8c9c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java @@ -67,6 +67,6 @@ public class CraftBrewingStand extends CraftContainer implements BrewingStand { @Override public void setCustomName(String name) { - brewingStand.a(name); // PAIL: setCustomName + brewingStand.setCustomName(name); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index a9ce5904..6aad6663 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -31,11 +31,11 @@ public class CraftContainer extends CraftBlockState implements Lockable { @Override public String getLock() { - return container.getLock().b(); // PAIL: getKey + return container.getLock().getKey(); } @Override public void setLock(String key) { - container.a(key == null ? ChestLock.a : new ChestLock(key)); // PAIL: setLock + container.setLock(key == null ? ChestLock.a : new ChestLock(key)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 2d070f8e..1596b9cc 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -25,7 +25,7 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa public EntityType getSpawnedType() { MinecraftKey key = spawner.getSpawner().getMobName(); - return (key == null) ? EntityType.PIG : EntityType.fromName(key.a()); + return (key == null) ? EntityType.PIG : EntityType.fromName(key.getKey()); } public void setSpawnedType(EntityType entityType) { @@ -37,7 +37,7 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa } public String getCreatureTypeName() { - return spawner.getSpawner().getMobName().a(); + return spawner.getSpawner().getMobName().getKey(); } public void setCreatureTypeByName(String creatureType) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java index 31236f5c..e20bb498 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java @@ -38,6 +38,6 @@ public class CraftEnchantingTable extends CraftBlockState implements EnchantingT @Override public void setCustomName(String name) { - enchant.a(name); // PAIL: setCustomName + enchant.setCustomName(name); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index 89b7a029..9865ff06 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -60,7 +60,7 @@ public class CraftFurnace extends CraftContainer implements Furnace { @Override public void setCustomName(String name) { - furnace.a(name); // PAIL: setCustomName + furnace.setCustomName(name); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java index 1941dfd4..c75b1024 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java @@ -29,6 +29,6 @@ public class CraftLootable extends CraftContainer implements Nameable { @Override public void setCustomName(String name) { - te.a(name); // PAIL: setCustomName + te.setCustomName(name); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java index 8a7ce92b..788c6026 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java @@ -42,6 +42,6 @@ public class CraftShulkerBox extends CraftLootable implements ShulkerBox { @Override public DyeColor getColor() { - return DyeColor.getByWoolData((byte) ((BlockShulkerBox) box.getBlock()).b.getColorIndex()); + return DyeColor.getByWoolData((byte) ((BlockShulkerBox) box.getBlock()).color.getColorIndex()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index 5f683b94..14115fb5 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -9,18 +9,18 @@ import org.apache.commons.lang.Validate; import org.apache.logging.log4j.Level; import org.bukkit.Location; import org.bukkit.command.BlockCommandSender; +import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ProxiedCommandSender; import org.bukkit.command.RemoteConsoleCommandSender; -import org.bukkit.command.defaults.*; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftMinecartCommand; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.entity.minecart.CommandMinecart; -public final class VanillaCommandWrapper extends VanillaCommand { +public final class VanillaCommandWrapper extends Command { protected final CommandAbstract vanillaCommand; public VanillaCommandWrapper(CommandAbstract vanillaCommand, String usage) { diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 728e0c5e..647e3917 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -61,7 +61,7 @@ public class CraftEnchantment extends Enchantment { @Override public boolean isCursed() { - return target.d(); // PAIL isCursed + return target.isCursed(); } @Override @@ -107,7 +107,7 @@ public class CraftEnchantment extends Enchantment { case 21: return "LOOT_BONUS_MOBS"; case 22: - return "SWEEPING"; + return "SWEEPING_EDGE"; case 32: return "DIG_SPEED"; case 33: diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java index 80e555e5..39620e06 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java @@ -24,6 +24,6 @@ public abstract class CraftChestedHorse extends CraftAbstractHorse implements Ch public void setCarryingChest(boolean chest) { if (chest == isCarryingChest()) return; getHandle().setCarryingChest(chest); - getHandle().dx(); + getHandle().loadChest(); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index a8923154..f1cfc7ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -65,6 +65,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityTameableAnimal) { if (entity instanceof EntityWolf) { return new CraftWolf(server, (EntityWolf) entity); } else if (entity instanceof EntityOcelot) { return new CraftOcelot(server, (EntityOcelot) entity); } + else if (entity instanceof EntityParrot) { return new CraftParrot(server, (EntityParrot) entity); } } else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); } else if (entity instanceof EntityHorseAbstract) { @@ -109,9 +110,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntityGuardianElder) { return new CraftElderGuardian(server, (EntityGuardianElder) entity); } else { return new CraftGuardian(server, (EntityGuardian) entity); } } - else if (entity instanceof EntityEvoker) { return new CraftEvoker(server, (EntityEvoker) entity); } else if (entity instanceof EntityVex) { return new CraftVex(server, (EntityVex) entity); } - else if (entity instanceof EntityVindicator) { return new CraftVindicator(server, (EntityVindicator) entity); } + else if (entity instanceof EntityIllagerAbstract) { + if (entity instanceof EntityIllagerWizard) { + if (entity instanceof EntityEvoker) { return new CraftEvoker(server, (EntityEvoker) entity); } + else if (entity instanceof EntityIllagerIllusioner) { return new CraftIllusioner(server, (EntityIllagerIllusioner) entity); } + else { return new CraftSpellcaster(server, (EntityIllagerWizard) entity); } + } + else if (entity instanceof EntityVindicator) { return new CraftVindicator(server, (EntityVindicator) entity); } + else { return new CraftIllager(server, (EntityIllagerAbstract) entity); } + } else { return new CraftMonster(server, (EntityMonster) entity); } } @@ -383,7 +391,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return false; } - getHandle().az(); // PAIL: rename + getHandle().leaveVehicle(); return true; } @@ -657,17 +665,26 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @Override public Set<String> getScoreboardTags() { - return getHandle().P(); // PAIL: getScoreboardTags + return getHandle().getScoreboardTags(); } @Override public boolean addScoreboardTag(String tag) { - return getHandle().a(tag); // PAIL: addScoreboardTag + return getHandle().addScoreboardTag(tag); } @Override public boolean removeScoreboardTag(String tag) { - return getHandle().b(tag); // PAIL: removeScoreboardTag + return getHandle().removeScoreboardTag(tag); + } + + protected NBTTagCompound save() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + nbttagcompound.setString("id", getHandle().getSaveID()); + getHandle().save(nbttagcompound); + + return nbttagcompound; } private static PermissibleBase getPermissibleBase() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java index 6e888d57..0636d264 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java @@ -1,11 +1,12 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityEvoker; +import net.minecraft.server.EntityIllagerWizard; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Evoker; -public class CraftEvoker extends CraftMonster implements Evoker { +public class CraftEvoker extends CraftSpellcaster implements Evoker { public CraftEvoker(CraftServer server, EntityEvoker entity) { super(server, entity); @@ -27,12 +28,12 @@ public class CraftEvoker extends CraftMonster implements Evoker { } @Override - public Spell getCurrentSpell() { - return Spell.values()[getHandle().getSpell()]; + public Evoker.Spell getCurrentSpell() { + return Evoker.Spell.values()[getHandle().getSpell().ordinal()]; } @Override - public void setCurrentSpell(Spell spell) { - getHandle().a(spell == null ? 0 : spell.ordinal()); + public void setCurrentSpell(Evoker.Spell spell) { + getHandle().setSpell(spell == null ? EntityIllagerWizard.Spell.NONE : EntityIllagerWizard.Spell.a(spell.ordinal())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java index 249756f5..14e0accf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java @@ -30,7 +30,7 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs { @Override public LivingEntity getOwner() { - EntityLiving owner = getHandle().j(); // PAIL: rename + EntityLiving owner = getHandle().getOwner(); return (owner == null) ? null : (LivingEntity) owner.getBukkitEntity(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 62aab50b..6422c4ad 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -422,15 +422,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public boolean hasCooldown(Material material) { Preconditions.checkArgument(material != null, "material"); - return getHandle().di().a(CraftMagicNumbers.getItem(material)); // PAIL: getCooldownTracker + return getHandle().getCooldownTracker().a(CraftMagicNumbers.getItem(material)); } @Override public int getCooldown(Material material) { Preconditions.checkArgument(material != null, "material"); - ItemCooldown.Info cooldown = getHandle().di().a.get(CraftMagicNumbers.getItem(material)); - return (cooldown == null) ? 0 : Math.max(0, cooldown.b - getHandle().di().b); + ItemCooldown.Info cooldown = getHandle().getCooldownTracker().cooldowns.get(CraftMagicNumbers.getItem(material)); + return (cooldown == null) ? 0 : Math.max(0, cooldown.endTick - getHandle().getCooldownTracker().currentTick); } @Override @@ -438,6 +438,44 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { Preconditions.checkArgument(material != null, "material"); Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown"); - getHandle().di().a(CraftMagicNumbers.getItem(material), ticks); + getHandle().getCooldownTracker().a(CraftMagicNumbers.getItem(material), ticks); + } + + @Override + public org.bukkit.entity.Entity getShoulderEntityLeft() { + if (getHandle().getShoulderEntityLeft() != null) { + Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().world); + + return (shoulder == null) ? null : shoulder.getBukkitEntity(); + } + + return null; + } + + @Override + public void setShoulderEntityLeft(org.bukkit.entity.Entity entity) { + getHandle().setShoulderEntityLeft(entity == null ? null : ((CraftEntity) entity).save()); + if (entity != null) { + entity.remove(); + } + } + + @Override + public org.bukkit.entity.Entity getShoulderEntityRight() { + if (getHandle().getShoulderEntityRight() != null) { + Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().world); + + return (shoulder == null) ? null : shoulder.getBukkitEntity(); + } + + return null; + } + + @Override + public void setShoulderEntityRight(org.bukkit.entity.Entity entity) { + getHandle().setShoulderEntityRight(entity == null ? null : ((CraftEntity) entity).save()); + if (entity != null) { + entity.remove(); + } } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java new file mode 100644 index 00000000..824af578 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java @@ -0,0 +1,22 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityIllagerAbstract; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Illager; + +public class CraftIllager extends CraftMonster implements Illager { + + public CraftIllager(CraftServer server, EntityIllagerAbstract entity) { + super(server, entity); + } + + @Override + public EntityIllagerAbstract getHandle() { + return (EntityIllagerAbstract) super.getHandle(); + } + + @Override + public String toString() { + return "CraftIllager"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java new file mode 100644 index 00000000..2ec1af8b --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityIllagerIllusioner; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Illusioner; + +public class CraftIllusioner extends CraftSpellcaster implements Illusioner { + + public CraftIllusioner(CraftServer server, EntityIllagerIllusioner entity) { + super(server, entity); + } + + @Override + public EntityIllagerIllusioner getHandle() { + return (EntityIllagerIllusioner) super.getHandle(); + } + + @Override + public String toString() { + return "CraftIllusioner"; + } + + @Override + public EntityType getType() { + return EntityType.ILLUSIONER; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 45e17db5..23ab78da 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -39,15 +39,15 @@ public class CraftLlama extends CraftChestedHorse implements Llama { @Override public int getStrength() { - return getHandle().dL(); + return getHandle().getStrength(); } @Override public void setStrength(int strength) { Preconditions.checkArgument(1 <= strength && strength <= 5, "strength must be [1,5]"); if (strength == getStrength()) return; - getHandle().p(strength); - getHandle().dx(); + getHandle().setStrength(strength); + getHandle().loadChest(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java index c3a20cb8..68d10c23 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java @@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityLlamaSpit; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LlamaSpit; import org.bukkit.projectiles.ProjectileSource; @@ -29,21 +28,11 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit { } @Override - public LivingEntity _INVALID_getShooter() { - return (getHandle().shooter != null) ? (LivingEntity) getHandle().shooter.getBukkitEntity() : null; - } - - @Override public ProjectileSource getShooter() { return (getHandle().shooter != null) ? (ProjectileSource) getHandle().shooter.getBukkitEntity() : null; } @Override - public void _INVALID_setShooter(LivingEntity shooter) { - getHandle().shooter = (shooter != null) ? ((CraftLivingEntity) shooter).getHandle() : null; - } - - @Override public void setShooter(ProjectileSource source) { getHandle().shooter = (source != null) ? ((CraftLivingEntity) source).getHandle() : null; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java index 37cc315c..e73c2c9f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java @@ -7,8 +7,8 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Ocelot; public class CraftOcelot extends CraftTameableAnimal implements Ocelot { - public CraftOcelot(CraftServer server, EntityOcelot wolf) { - super(server, wolf); + public CraftOcelot(CraftServer server, EntityOcelot ocelot) { + super(server, ocelot); } @Override @@ -26,6 +26,11 @@ public class CraftOcelot extends CraftTameableAnimal implements Ocelot { } @Override + public String toString() { + return "CraftOcelot"; + } + + @Override public EntityType getType() { return EntityType.OCELOT; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java new file mode 100644 index 00000000..5b2405cf --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftParrot.java @@ -0,0 +1,41 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.server.EntityParrot; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Parrot; + +public class CraftParrot extends CraftTameableAnimal implements Parrot { + + public CraftParrot(CraftServer server, EntityParrot parrot) { + super(server, parrot); + } + + @Override + public EntityParrot getHandle() { + return (EntityParrot) entity; + } + + @Override + public Variant getVariant() { + return Variant.values()[getHandle().getVariant()]; + } + + @Override + public void setVariant(Variant variant) { + Preconditions.checkArgument(variant != null, "variant"); + + getHandle().setVariant(variant.ordinal()); + } + + @Override + public String toString() { + return "CraftParrot"; + } + + @Override + public EntityType getType() { + return EntityType.PARROT; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index edf583b6..92b4bc9a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -47,6 +47,8 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.CraftStatistic; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.advancement.CraftAdvancement; +import org.bukkit.craftbukkit.advancement.CraftAdvancementProgress; import org.bukkit.craftbukkit.map.CraftMapView; import org.bukkit.craftbukkit.map.RenderData; import org.bukkit.craftbukkit.scoreboard.CraftScoreboard; @@ -559,29 +561,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void awardAchievement(Achievement achievement) { - Validate.notNull(achievement, "Achievement cannot be null"); - if (achievement.hasParent() && !hasAchievement(achievement.getParent())) { - awardAchievement(achievement.getParent()); - } - getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 1); - getHandle().getStatisticManager().updateStatistics(getHandle()); + throw new UnsupportedOperationException("Not supported in this Minecraft version."); } @Override public void removeAchievement(Achievement achievement) { - Validate.notNull(achievement, "Achievement cannot be null"); - for (Achievement achieve : Achievement.values()) { - if (achieve.getParent() == achievement && hasAchievement(achieve)) { - removeAchievement(achieve); - } - } - getHandle().getStatisticManager().setStatistic(getHandle(), CraftStatistic.getNMSAchievement(achievement), 0); + throw new UnsupportedOperationException("Not supported in this Minecraft version."); } @Override public boolean hasAchievement(Achievement achievement) { - Validate.notNull(achievement, "Achievement cannot be null"); - return getHandle().getStatisticManager().hasAchievement(CraftStatistic.getNMSAchievement(achievement)); + throw new UnsupportedOperationException("Not supported in this Minecraft version."); } @Override @@ -755,15 +745,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } @Override - public void setBanned(boolean value) { - if (value) { - server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null); - } else { - server.getBanList(BanList.Type.NAME).pardon(getName()); - } - } - - @Override public boolean isWhitelisted() { return server.getHandle().getWhitelist().isWhitelisted(getProfile()); } @@ -1454,4 +1435,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().playerConnection.sendPacket(packetplayoutworldparticles); } + + @Override + public org.bukkit.advancement.AdvancementProgress getAdvancementProgress(org.bukkit.advancement.Advancement advancement) { + Preconditions.checkArgument(advancement != null, "advancement"); + + CraftAdvancement craft = (CraftAdvancement) advancement; + AdvancementDataPlayer data = getHandle().getAdvancementData(); + AdvancementProgress progress = data.getProgress(craft.getHandle()); + + return new CraftAdvancementProgress(craft, data, progress); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java index e8cb697a..72f99fdc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java @@ -25,13 +25,13 @@ public class CraftShulker extends CraftGolem implements Shulker { @Override public DyeColor getColor() { - return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.bw)); + return DyeColor.getByWoolData(getHandle().getDataWatcher().get(EntityShulker.COLOR)); } @Override public void setColor(DyeColor color) { Preconditions.checkArgument(color != null, "color"); - getHandle().getDataWatcher().set(EntityShulker.bw, color.getWoolData()); + getHandle().getDataWatcher().set(EntityShulker.COLOR, color.getWoolData()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java new file mode 100644 index 00000000..db1ba5b2 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSpellcaster.java @@ -0,0 +1,35 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.server.EntityIllagerWizard; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Spellcaster; + +public class CraftSpellcaster extends CraftIllager implements Spellcaster { + + public CraftSpellcaster(CraftServer server, EntityIllagerWizard entity) { + super(server, entity); + } + + @Override + public EntityIllagerWizard getHandle() { + return (EntityIllagerWizard) super.getHandle(); + } + + @Override + public String toString() { + return "CraftSpellcaster"; + } + + @Override + public Spell getSpell() { + return Spell.valueOf(getHandle().getSpell().name()); + } + + @Override + public void setSpell(Spell spell) { + Preconditions.checkArgument(spell != null, "Use Spell.NONE"); + + getHandle().setSpell(EntityIllagerWizard.Spell.a(spell.ordinal())); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java index 955954fc..435203b8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java @@ -123,11 +123,11 @@ public class CraftTippedArrow extends CraftArrow implements TippedArrow { @Override public void setColor(Color color) { - getHandle().d(color.asRGB()); + getHandle().setColor(color.asRGB()); } @Override public Color getColor() { - return Color.fromRGB(getHandle().o()); + return Color.fromRGB(getHandle().getColor()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java index 3835897c..951d4792 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Vindicator; -public class CraftVindicator extends CraftMonster implements Vindicator { +public class CraftVindicator extends CraftIllager implements Vindicator { public CraftVindicator(CraftServer server, EntityVindicator entity) { super(server, entity); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 95f602e1..1c0dc7d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -953,12 +953,7 @@ public class CraftEventFactory { public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int incrementation) { Player player = ((EntityPlayer) entityHuman).getBukkitEntity(); Event event; - if (statistic instanceof net.minecraft.server.Achievement) { - if (current != 0) { - return null; - } - event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.server.Achievement) statistic)); - } else { + if (true) { org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic); if (stat == null) { System.err.println("Unhandled statistic: " + statistic); diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 0acad719..9942f0c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -221,6 +221,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override + public boolean a(World world, String type, BlockPosition position) { + return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.b(position) : false; + } + + @Override public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position, boolean flag) { return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, position, flag) : null; } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java index 1ea56024..be07fb8e 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java @@ -60,4 +60,9 @@ public class NormalChunkGenerator extends InternalChunkGenerator { public void recreateStructures(Chunk chunk, int i, int i1) { generator.recreateStructures(chunk, i, i1); } + + @Override + public boolean a(World world, String string, BlockPosition bp) { + return generator.a(world, string, bp); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java index 7dd5afef..c7daccd5 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java +++ b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java @@ -6,7 +6,6 @@ import com.google.common.collect.Collections2; import org.bukkit.command.*; import org.bukkit.command.defaults.BukkitCommand; -import org.bukkit.command.defaults.VanillaCommand; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.command.VanillaCommandWrapper; import org.bukkit.help.*; @@ -184,7 +183,7 @@ public class SimpleHelpMap implements HelpMap { if (command instanceof VanillaCommandWrapper) { return "Minecraft"; } - if (command instanceof BukkitCommand || command instanceof VanillaCommand) { + if (command instanceof BukkitCommand) { return "Bukkit"; } if (command instanceof PluginIdentifiableCommand) { @@ -194,7 +193,7 @@ public class SimpleHelpMap implements HelpMap { } private boolean commandInIgnoredPlugin(Command command, Set<String> ignoredPlugins) { - if ((command instanceof BukkitCommand || command instanceof VanillaCommand) && ignoredPlugins.contains("Bukkit")) { + if ((command instanceof BukkitCommand) && ignoredPlugins.contains("Bukkit")) { return true; } if (command instanceof PluginIdentifiableCommand && ignoredPlugins.contains(((PluginIdentifiableCommand)command).getPlugin().getName())) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java index 6647b167..f9bbd711 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java @@ -59,16 +59,16 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor @Override public String getRenameText() { - return container.l; // PAIL: renameText + return container.renameText; } @Override public int getRepairCost() { - return container.a; // PAIL: levelCost + return container.levelCost; } @Override public void setRepairCost(int i) { - container.a = i; // PAIL:levelCost + container.levelCost = i; } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index da8df638..a1a0ab7d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -202,7 +202,7 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public boolean w_() { + public boolean x_() { Iterator iterator = this.items.iterator(); ItemStack itemstack; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index a72b179c..fe85d6a2 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -28,6 +28,7 @@ public final class CraftItemFactory implements ItemFactory { .add("generic.knockbackResistance") .add("generic.maxHealth") .add("generic.movementSpeed") + .add("generic.flyingSpeed") .add("generic.attackSpeed") .add("generic.luck") .add("horse.jumpStrength") @@ -93,6 +94,8 @@ public final class CraftItemFactory implements ItemFactory { return meta instanceof CraftMetaBanner ? meta : new CraftMetaBanner(meta); case MONSTER_EGG: return meta instanceof CraftMetaSpawnEgg ? meta : new CraftMetaSpawnEgg(meta); + case KNOWLEDGE_BOOK: + return meta instanceof CraftMetaKnowledgeBook ? meta : new CraftMetaKnowledgeBook(meta); case FURNACE: case CHEST: case TRAPPED_CHEST: diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index a54bc7c4..3f11e427 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -353,6 +353,8 @@ public final class CraftItemStack extends ItemStack { return new CraftMetaBanner(item.getTag()); case MONSTER_EGG: return new CraftMetaSpawnEgg(item.getTag()); + case KNOWLEDGE_BOOK: + return new CraftMetaKnowledgeBook(item.getTag()); case FURNACE: case CHEST: case TRAPPED_CHEST: diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 51e8d1e9..527e7ba9 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -49,7 +49,7 @@ public class CraftMerchantCustom extends CraftMerchant { @Override public void a(MerchantRecipe merchantrecipe) { // increase recipe's uses - merchantrecipe.g(); // PAIL: rename + merchantrecipe.increaseUses(); } @Override @@ -62,12 +62,12 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public World t_() { + public World u_() { return null; } @Override - public BlockPosition u_() { + public BlockPosition v_() { return null; } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 65b58448..7882e889 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -119,6 +119,7 @@ class CraftMetaItem implements ItemMeta, Repairable { .put(CraftMetaEnchantedBook.class, "ENCHANTED") .put(CraftMetaFirework.class, "FIREWORK") .put(CraftMetaCharge.class, "FIREWORK_EFFECT") + .put(CraftMetaKnowledgeBook.class, "KNOWLEDGE_BOOK") .put(CraftMetaItem.class, "UNSPECIFIC") .build(); @@ -890,7 +891,8 @@ class CraftMetaItem implements ItemMeta, Repairable { CraftMetaFirework.FIREWORKS.NBT, CraftMetaEnchantedBook.STORED_ENCHANTMENTS.NBT, CraftMetaCharge.EXPLOSION.NBT, - CraftMetaBlockState.BLOCK_ENTITY_TAG.NBT + CraftMetaBlockState.BLOCK_ENTITY_TAG.NBT, + CraftMetaKnowledgeBook.BOOK_RECIPES.NBT )); } return HANDLED_TAGS; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java new file mode 100644 index 00000000..e68a7d06 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java @@ -0,0 +1,173 @@ +package org.bukkit.craftbukkit.inventory; + +import com.google.common.collect.ImmutableMap.Builder; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import net.minecraft.server.NBTTagCompound; +import net.minecraft.server.NBTTagList; +import net.minecraft.server.NBTTagString; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.configuration.serialization.DelegateDeserialization; +import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.meta.KnowledgeBookMeta; + +@DelegateDeserialization(SerializableMeta.class) +public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBookMeta { + + static final ItemMetaKey BOOK_RECIPES = new ItemMetaKey("Recipes"); + static final int MAX_RECIPES = Short.MAX_VALUE; + + protected List<NamespacedKey> recipes = new ArrayList<NamespacedKey>(); + + CraftMetaKnowledgeBook(CraftMetaItem meta) { + super(meta); + + if (meta instanceof CraftMetaKnowledgeBook) { + CraftMetaKnowledgeBook bookMeta = (CraftMetaKnowledgeBook) meta; + this.recipes.addAll(bookMeta.recipes); + } + } + + CraftMetaKnowledgeBook(NBTTagCompound tag) { + super(tag); + + if (tag.hasKey(BOOK_RECIPES.NBT)) { + NBTTagList pages = tag.getList(BOOK_RECIPES.NBT, 8); + + for (int i = 0; i < pages.size(); i++) { + String recipe = pages.getString(i); + + addRecipe(CraftNamespacedKey.fromString(recipe)); + } + } + } + + CraftMetaKnowledgeBook(Map<String, Object> map) { + super(map); + + Iterable<?> pages = SerializableMeta.getObject(Iterable.class, map, BOOK_RECIPES.BUKKIT, true); + if (pages != null) { + for (Object page : pages) { + if (page instanceof String) { + addRecipe(CraftNamespacedKey.fromString((String) page)); + } + } + } + } + + void applyToItem(NBTTagCompound itemData) { + super.applyToItem(itemData); + + if (hasRecipes()) { + NBTTagList list = new NBTTagList(); + for (NamespacedKey recipe : this.recipes) { + list.add(new NBTTagString(recipe.toString())); + } + itemData.set(BOOK_RECIPES.NBT, list); + } + } + + @Override + boolean isEmpty() { + return super.isEmpty() && isBookEmpty(); + } + + boolean isBookEmpty() { + return !(hasRecipes()); + } + + @Override + boolean applicableTo(Material type) { + switch (type) { + case KNOWLEDGE_BOOK: + return true; + default: + return false; + } + } + + @Override + public boolean hasRecipes() { + return !recipes.isEmpty(); + } + + @Override + public void addRecipe(NamespacedKey... recipes) { + for (NamespacedKey recipe : recipes) { + if (recipe != null) { + if (this.recipes.size() >= MAX_RECIPES) { + return; + } + + this.recipes.add(recipe); + } + } + } + + @Override + public List<NamespacedKey> getRecipes() { + return Collections.unmodifiableList(recipes); + } + + @Override + public void setRecipes(List<NamespacedKey> recipes) { + this.recipes.clear(); + for (NamespacedKey recipe : this.recipes) { + addRecipe(recipe); + } + } + + @Override + public CraftMetaKnowledgeBook clone() { + CraftMetaKnowledgeBook meta = (CraftMetaKnowledgeBook) super.clone(); + meta.recipes = new ArrayList<NamespacedKey>(recipes); + return meta; + } + + @Override + int applyHash() { + final int original; + int hash = original = super.applyHash(); + if (hasRecipes()) { + hash = 61 * hash + 17 * this.recipes.hashCode(); + } + return original != hash ? CraftMetaKnowledgeBook.class.hashCode() ^ hash : hash; + } + + @Override + boolean equalsCommon(CraftMetaItem meta) { + if (!super.equalsCommon(meta)) { + return false; + } + if (meta instanceof CraftMetaKnowledgeBook) { + CraftMetaKnowledgeBook that = (CraftMetaKnowledgeBook) meta; + + return (hasRecipes() ? that.hasRecipes() && this.recipes.equals(that.recipes) : !that.hasRecipes()); + } + return true; + } + + @Override + boolean notUncommon(CraftMetaItem meta) { + return super.notUncommon(meta) && (meta instanceof CraftMetaKnowledgeBook || isBookEmpty()); + } + + @Override + Builder<String, Object> serialize(Builder<String, Object> builder) { + super.serialize(builder); + + if (hasRecipes()) { + List<String> recipesString = new ArrayList<String>(); + for (NamespacedKey recipe : recipes) { + recipesString.add(recipe.toString()); + } + builder.put(BOOK_RECIPES.BUKKIT, recipesString); + } + + return builder; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index 360f95f7..782a781e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java @@ -40,7 +40,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { entityTag = tag.getCompound(ENTITY_TAG.NBT); if (entityTag.hasKey(ENTITY_ID.NBT)) { - this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).a()); // PAIL: rename + this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey()); } } } @@ -58,10 +58,10 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { if (tag.hasKey(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); - MinecraftServer.getServer().getDataConverterManager().a(DataConverterTypes.ENTITY, entityTag); // PAIL: convert + MinecraftServer.getServer().dataConverterManager.a(DataConverterTypes.ENTITY, entityTag); // PAIL: convert if (entityTag.hasKey(ENTITY_ID.NBT)) { - this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).a()); // PAIL: rename + this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey()); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java index baea7597..fd3aa7c0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java @@ -3,9 +3,12 @@ package org.bukkit.craftbukkit.inventory; import java.util.Map; import net.minecraft.server.CraftingManager; +import net.minecraft.server.NonNullList; +import net.minecraft.server.RecipeItemStack; import net.minecraft.server.ShapedRecipes; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapedRecipe; @@ -13,12 +16,12 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { // TODO: Could eventually use this to add a matches() method or some such private ShapedRecipes recipe; - public CraftShapedRecipe(ItemStack result) { - super(result); + public CraftShapedRecipe(NamespacedKey key, ItemStack result) { + super(key, result); } public CraftShapedRecipe(ItemStack result, ShapedRecipes recipe) { - this(result); + this(CraftNamespacedKey.fromMinecraft(CraftingManager.recipes.b(recipe)), result); this.recipe = recipe; } @@ -26,7 +29,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { if (recipe instanceof CraftShapedRecipe) { return (CraftShapedRecipe) recipe; } - CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getResult()); + CraftShapedRecipe ret = new CraftShapedRecipe(recipe.getKey(), recipe.getResult()); String[] shape = recipe.getShape(); ret.shape(shape); Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap(); @@ -40,26 +43,18 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { } public void addToCraftingManager() { - Object[] data; String[] shape = this.getShape(); Map<Character, ItemStack> ingred = this.getIngredientMap(); - int datalen = shape.length; - datalen += ingred.size() * 2; - int i = 0; - data = new Object[datalen]; - for (; i < shape.length; i++) { - data[i] = shape[i]; - } - for (char c : ingred.keySet()) { - ItemStack mdata = ingred.get(c); - if (mdata == null) continue; - data[i] = c; - i++; - int id = mdata.getTypeId(); - short dmg = mdata.getDurability(); - data[i] = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg); - i++; + int width = shape[0].length(); + NonNullList<RecipeItemStack> data = NonNullList.a(shape.length * width, RecipeItemStack.a); + + for (int i = 0; i < shape.length; i++) { + String row = shape[i]; + for (int j = 0; j < row.length(); j++) { + data.set(i * width + j, new RecipeItemStack(CraftItemStack.asNMSCopy(ingred.get(row.charAt(j))))); + } } - CraftingManager.getInstance().registerShapedRecipe(CraftItemStack.asNMSCopy(this.getResult()), data); + + CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapedRecipes("", width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java index 53479c72..93719c50 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -3,9 +3,12 @@ package org.bukkit.craftbukkit.inventory; import java.util.List; import net.minecraft.server.CraftingManager; +import net.minecraft.server.NonNullList; +import net.minecraft.server.RecipeItemStack; import net.minecraft.server.ShapelessRecipes; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapelessRecipe; @@ -13,12 +16,12 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe // TODO: Could eventually use this to add a matches() method or some such private ShapelessRecipes recipe; - public CraftShapelessRecipe(ItemStack result) { - super(result); + public CraftShapelessRecipe(NamespacedKey key, ItemStack result) { + super(key, result); } public CraftShapelessRecipe(ItemStack result, ShapelessRecipes recipe) { - this(result); + this(CraftNamespacedKey.fromMinecraft(recipe.key != null ? recipe.key : CraftingManager.recipes.b(recipe)), result); this.recipe = recipe; } @@ -26,7 +29,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe if (recipe instanceof CraftShapelessRecipe) { return (CraftShapelessRecipe) recipe; } - CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getResult()); + CraftShapelessRecipe ret = new CraftShapelessRecipe(recipe.getKey(), recipe.getResult()); for (ItemStack ingred : recipe.getIngredientList()) { ret.addIngredient(ingred.getType(), ingred.getDurability()); } @@ -35,14 +38,11 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe public void addToCraftingManager() { List<ItemStack> ingred = this.getIngredientList(); - Object[] data = new Object[ingred.size()]; - int i = 0; - for (ItemStack mdata : ingred) { - int id = mdata.getTypeId(); - short dmg = mdata.getDurability(); - data[i] = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg); - i++; + NonNullList<RecipeItemStack> data = NonNullList.a(ingred.size(), RecipeItemStack.a); + for (int i = 0; i < ingred.size(); i++) { + data.set(i, new RecipeItemStack(CraftItemStack.asNMSCopy(ingred.get(i)))); } - CraftingManager.getInstance().registerShapelessRecipe(CraftItemStack.asNMSCopy(this.getResult()), data); + + CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapelessRecipes("", CraftItemStack.asNMSCopy(this.getResult()), data)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java index 5634a22b..d2a00849 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java @@ -180,7 +180,7 @@ public class InventoryWrapper implements IInventory { } @Override - public boolean w_() { + public boolean x_() { return Iterables.any(inventory, Predicates.notNull()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java index 53b53b79..f03f8baa 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java @@ -15,7 +15,7 @@ public class RecipeIterator implements Iterator<Recipe> { private Iterator<?> removeFrom = null; public RecipeIterator() { - this.recipes = CraftingManager.getInstance().getRecipes().iterator(); + this.recipes = CraftingManager.recipes.iterator(); this.smeltingCustom = RecipesFurnace.getInstance().customRecipes.keySet().iterator(); this.smeltingVanilla = RecipesFurnace.getInstance().recipes.keySet().iterator(); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 574ec0ab..a1be7ec4 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -1,26 +1,39 @@ package org.bukkit.craftbukkit.util; +import com.google.common.base.Charsets; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.io.Files; +import java.io.File; +import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import net.minecraft.server.AdvancementDataWorld; import net.minecraft.server.Block; import net.minecraft.server.Blocks; +import net.minecraft.server.ChatDeserializer; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.MojangsonParseException; import net.minecraft.server.MojangsonParser; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.StatisticList; import org.bukkit.Achievement; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.Statistic; import org.bukkit.UnsafeValues; +import org.bukkit.advancement.Advancement; import org.bukkit.craftbukkit.CraftStatistic; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; @@ -131,7 +144,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public Achievement getAchievementFromInternalName(String name) { - return CraftStatistic.getBukkitAchievementByName(name); + throw new UnsupportedOperationException("Not supported in this Minecraft version."); } @Override @@ -147,6 +160,42 @@ public final class CraftMagicNumbers implements UnsafeValues { return matches; } + @Override + public Advancement loadAdvancement(NamespacedKey key, String advancement) { + if (Bukkit.getAdvancement(key) != null) { + throw new IllegalArgumentException("Advancement " + key + " already exists."); + } + + net.minecraft.server.Advancement.SerializedAdvancement nms = (net.minecraft.server.Advancement.SerializedAdvancement) ChatDeserializer.a(AdvancementDataWorld.DESERIALIZER, advancement, net.minecraft.server.Advancement.SerializedAdvancement.class); + if (nms != null) { + AdvancementDataWorld.REGISTRY.a(Maps.newHashMap(Collections.singletonMap(CraftNamespacedKey.toMinecraft(key), nms))); + Advancement bukkit = Bukkit.getAdvancement(key); + + if (bukkit != null) { + File file = new File(MinecraftServer.getServer().getAdvancementData().folder, key.getNamespace() + File.separator + key.getKey() + ".json"); + file.getParentFile().mkdirs(); + + try { + Files.write(advancement, file, Charsets.UTF_8); + } catch (IOException ex) { + Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex); + } + + MinecraftServer.getServer().getPlayerList().reload(); + + return bukkit; + } + } + + return null; + } + + @Override + public boolean removeAdvancement(NamespacedKey key) { + File file = new File(MinecraftServer.getServer().getAdvancementData().folder, key.getNamespace() + File.separator + key.getKey() + ".json"); + return file.delete(); + } + /** * This helper class represents the different NBT Tags. * <p> diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java new file mode 100644 index 00000000..d8831f61 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java @@ -0,0 +1,22 @@ +package org.bukkit.craftbukkit.util; + +import net.minecraft.server.MinecraftKey; +import org.bukkit.NamespacedKey; + +public final class CraftNamespacedKey { + + public CraftNamespacedKey() { + } + + public static NamespacedKey fromString(String string) { + return fromMinecraft(new MinecraftKey(string)); + } + + public static NamespacedKey fromMinecraft(MinecraftKey minecraft) { + return new NamespacedKey(minecraft.b(), minecraft.getKey()); + } + + public static MinecraftKey toMinecraft(NamespacedKey key) { + return new MinecraftKey(key.getNamespace(), key.getKey()); + } +} diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml index 8bbb835f..67ea88a4 100644 --- a/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml @@ -35,9 +35,3 @@ ticks-per: monster-spawns: 1 autosave: 6000 aliases: now-in-commands.yml -database: - username: bukkit - isolation: SERIALIZABLE - driver: org.sqlite.JDBC - password: walrus - url: jdbc:sqlite:{DIR}{NAME}.db diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java index f0b889b3..020714da 100644 --- a/src/test/java/org/bukkit/DyeColorsTest.java +++ b/src/test/java/org/bukkit/DyeColorsTest.java @@ -6,7 +6,6 @@ import static org.hamcrest.Matchers.*; import java.util.ArrayList; import java.util.List; -import net.minecraft.server.EntitySheep; import net.minecraft.server.EnumColor; import net.minecraft.server.ItemDye; @@ -34,7 +33,7 @@ public class DyeColorsTest extends AbstractTestingBase { @Test public void checkColor() { Color color = dye.getColor(); - float[] nmsColorArray = EntitySheep.a(EnumColor.fromColorIndex(dye.getWoolData())); + float[] nmsColorArray = EnumColor.fromColorIndex(dye.getWoolData()).f(); Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255)); assertThat(color, is(nmsColor)); } diff --git a/src/test/java/org/bukkit/SoundTest.java b/src/test/java/org/bukkit/SoundTest.java index ea1d0c84..942cb4ea 100644 --- a/src/test/java/org/bukkit/SoundTest.java +++ b/src/test/java/org/bukkit/SoundTest.java @@ -21,7 +21,7 @@ public class SoundTest { @Test public void testReverse() { for (MinecraftKey effect : SoundEffect.a.keySet()) { - assertNotNull(effect + "", Sound.valueOf(effect.a().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH))); + assertNotNull(effect + "", Sound.valueOf(effect.getKey().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH))); } } diff --git a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java index 0a6c277a..e05e7330 100644 --- a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java +++ b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java @@ -3,10 +3,8 @@ package org.bukkit; import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; -import java.util.Collections; import java.util.List; -import net.minecraft.server.AchievementList; import net.minecraft.server.StatisticList; import org.bukkit.craftbukkit.CraftStatistic; @@ -14,35 +12,14 @@ import org.bukkit.support.AbstractTestingBase; import org.junit.Test; import com.google.common.collect.HashMultiset; -import com.google.common.collect.Lists; public class StatisticsAndAchievementsTest extends AbstractTestingBase { - @Test - @SuppressWarnings("unchecked") - public void verifyAchievementMapping() throws Throwable { - List<Achievement> achievements = Lists.newArrayList(Achievement.values()); - for (net.minecraft.server.Achievement achievement : (List<net.minecraft.server.Achievement>) AchievementList.e) { - String name = achievement.name; - - String message = String.format("org.bukkit.Achievement is missing: '%s'", name); - - Achievement subject = CraftStatistic.getBukkitAchievement(achievement); - assertThat(message, subject, is(not(nullValue()))); - - assertThat(name, achievements.remove(subject), is(true)); - } - - assertThat("org.bukkit.Achievement has too many achievements", achievements, is(empty())); - } @Test @SuppressWarnings("unchecked") public void verifyStatisticMapping() throws Throwable { HashMultiset<Statistic> statistics = HashMultiset.create(); for (net.minecraft.server.Statistic statistic : (List<net.minecraft.server.Statistic>) StatisticList.stats) { - if (statistic instanceof net.minecraft.server.Achievement) { - continue; - } String name = statistic.name; String message = String.format("org.bukkit.Statistic is missing: '%s'", name); diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 69c21f28..1f537d58 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -17,6 +17,7 @@ import org.bukkit.DyeColor; import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.FireworkEffect.Type; +import org.bukkit.NamespacedKey; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.craftbukkit.inventory.ItemStackTest.StackProvider; @@ -33,6 +34,7 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.FireworkEffectMeta; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.KnowledgeBookMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.MapMeta; import org.bukkit.inventory.meta.PotionMeta; @@ -264,6 +266,14 @@ public class ItemMetaTest extends AbstractTestingBase { meta.setSpawnedType(EntityType.ZOMBIE); cleanStack.setItemMeta(meta); return cleanStack; + } + }, + new StackProvider(Material.KNOWLEDGE_BOOK) { + @Override ItemStack operate(ItemStack cleanStack) { + final KnowledgeBookMeta meta = (KnowledgeBookMeta) cleanStack.getItemMeta(); + meta.addRecipe(new NamespacedKey("minecraft", "test"), new NamespacedKey("plugin", "test")); + cleanStack.setItemMeta(meta); + return cleanStack; } } ); diff --git a/src/test/java/org/bukkit/map/MapTest.java b/src/test/java/org/bukkit/map/MapTest.java index 4cb2cf94..f4788a18 100644 --- a/src/test/java/org/bukkit/map/MapTest.java +++ b/src/test/java/org/bukkit/map/MapTest.java @@ -24,13 +24,13 @@ public class MapTest { if (nmsColors[i] == null) { break; } - int rgb = nmsColors[i].L; + int rgb = nmsColors[i].ac; int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; int b = rgb & 0xFF; - if (i > bukkitColors.length/4) { + if (i + 1 > bukkitColors.length / 4) { for (int modi : modifiers) { int mr = (r * modi) / 255; int mg = (g * modi) / 255; |