diff --git a/nms-patches/Advancement.patch b/nms-patches/Advancement.patch index 70b171c77a..57f6fdfdf8 100644 --- a/nms-patches/Advancement.patch +++ b/nms-patches/Advancement.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Advancement.java +++ b/net/minecraft/server/Advancement.java -@@ -27,6 +27,7 @@ +@@ -26,6 +26,7 @@ private final String[][] requirements; private final Set children = Sets.newLinkedHashSet(); private final IChatBaseComponent chatComponent; @@ -8,7 +8,7 @@ public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map map, String[][] astring) { this.key = minecraftkey; -@@ -210,7 +211,7 @@ +@@ -209,7 +210,7 @@ } public Advancement b(MinecraftKey minecraftkey) { diff --git a/nms-patches/AdvancementDataPlayer.patch b/nms-patches/AdvancementDataPlayer.patch index 6a9f24a173..82ceec033d 100644 --- a/nms-patches/AdvancementDataPlayer.patch +++ b/nms-patches/AdvancementDataPlayer.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/server/AdvancementDataPlayer.java +++ b/net/minecraft/server/AdvancementDataPlayer.java -@@ -160,7 +160,11 @@ - Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey()); +@@ -163,7 +163,11 @@ + Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey()); if (advancement == null) { -- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.e); +- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f); + // CraftBukkit start + if (entry.getKey().getNamespace().equals("minecraft")) { -+ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.e); ++ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f); + } + // CraftBukkit end } else { this.a(advancement, (AdvancementProgress) entry.getValue()); } -@@ -275,6 +279,7 @@ - this.i.add(advancement); +@@ -278,6 +282,7 @@ + this.j.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(GameRules.ANNOUNCE_ADVANCEMENTS)) { - this.d.getPlayerList().sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()})); + this.e.sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()}), ChatMessageType.SYSTEM, SystemUtils.b); diff --git a/nms-patches/ArgumentBlock.patch b/nms-patches/ArgumentBlock.patch index 959f0de427..8160fc9f97 100644 --- a/nms-patches/ArgumentBlock.patch +++ b/nms-patches/ArgumentBlock.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/ArgumentBlock.java +++ b/net/minecraft/server/ArgumentBlock.java -@@ -41,7 +41,7 @@ - private static final Function> h = SuggestionsBuilder::buildFuture; +@@ -43,7 +43,7 @@ + }; private final StringReader i; private final boolean j; - private final Map, Comparable> k = Maps.newHashMap(); @@ -9,7 +9,7 @@ private final Map l = Maps.newHashMap(); private MinecraftKey m = new MinecraftKey(""); private BlockStateList n; -@@ -217,7 +217,7 @@ +@@ -219,7 +219,7 @@ Iterator iterator = iblockstate.getValues().iterator(); while (iterator.hasNext()) { @@ -18,7 +18,7 @@ if (t0 instanceof Integer) { suggestionsbuilder.suggest((Integer) t0); -@@ -486,7 +486,7 @@ +@@ -488,7 +488,7 @@ Optional optional = iblockstate.b(s); if (optional.isPresent()) { @@ -27,12 +27,12 @@ this.k.put(iblockstate, optional.get()); } else { this.i.setCursor(i); -@@ -520,7 +520,7 @@ +@@ -522,7 +522,7 @@ private static > void a(StringBuilder stringbuilder, IBlockState iblockstate, Comparable comparable) { - stringbuilder.append(iblockstate.a()); + stringbuilder.append(iblockstate.getName()); stringbuilder.append('='); - stringbuilder.append(iblockstate.a(comparable)); + stringbuilder.append(iblockstate.a((T) comparable)); // CraftBukkit - decompile error } - public CompletableFuture a(SuggestionsBuilder suggestionsbuilder) { + public CompletableFuture a(SuggestionsBuilder suggestionsbuilder, Tags tags) { diff --git a/nms-patches/AttributeRanged.patch b/nms-patches/AttributeRanged.patch index e579b8744b..98be834de6 100644 --- a/nms-patches/AttributeRanged.patch +++ b/nms-patches/AttributeRanged.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/AttributeRanged.java +++ b/net/minecraft/server/AttributeRanged.java -@@ -32,6 +32,8 @@ +@@ -20,6 +20,8 @@ @Override public double a(double d0) { diff --git a/nms-patches/BehaviorCareer.patch b/nms-patches/BehaviorCareer.patch index 4682ea3d7a..7ad04f3248 100644 --- a/nms-patches/BehaviorCareer.patch +++ b/nms-patches/BehaviorCareer.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/BehaviorCareer.java +++ b/net/minecraft/server/BehaviorCareer.java -@@ -1,6 +1,11 @@ - package net.minecraft.server; +@@ -2,6 +2,11 @@ import com.google.common.collect.ImmutableMap; + import java.util.Optional; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftVillager; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -12,10 +12,19 @@ public class BehaviorCareer extends Behavior { -@@ -20,7 +25,14 @@ - IRegistry.VILLAGER_PROFESSION.d().filter((villagerprofession) -> { - return villagerprofession.b() == villageplacetype; - }).findFirst().ifPresent((villagerprofession) -> { +@@ -19,7 +24,7 @@ + GlobalPos globalpos = (GlobalPos) entityvillager.getBehaviorController().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get(); + + entityvillager.getBehaviorController().removeMemory(MemoryModuleType.POTENTIAL_JOB_SITE); +- entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, (Object) globalpos); ++ entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, globalpos); // CraftBukkit - decompile error + if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) { + MinecraftServer minecraftserver = worldserver.getMinecraftServer(); + +@@ -30,7 +35,14 @@ + return villagerprofession.b() == villageplacetype; + }).findFirst(); + }).ifPresent((villagerprofession) -> { - entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(villagerprofession)); + // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed + VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); @@ -25,6 +34,6 @@ + + entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - entityvillager.a(worldserver); + entityvillager.b(worldserver); }); - }); + } diff --git a/nms-patches/BehaviorFarm.patch b/nms-patches/BehaviorFarm.patch index 93f11002dc..1e19d663fe 100644 --- a/nms-patches/BehaviorFarm.patch +++ b/nms-patches/BehaviorFarm.patch @@ -1,70 +1,70 @@ --- a/net/minecraft/server/BehaviorFarm.java +++ b/net/minecraft/server/BehaviorFarm.java -@@ -79,8 +79,8 @@ +@@ -58,8 +58,8 @@ protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) { - if (i > this.d && this.a != null) { -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.a))); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1))); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.a))); // CraftBukkit - decompile error -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1))); // CraftBukkit - decompile error + if (i > this.c && this.farmBlock != null) { +- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.farmBlock))); +- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); ++ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.farmBlock))); // CraftBukkit - decompile error ++ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); // CraftBukkit - decompile error } } -@@ -99,7 +99,11 @@ - Block block1 = worldserver.getType(this.a.down()).getBlock(); +@@ -79,7 +79,11 @@ + Block block1 = worldserver.getType(this.farmBlock.down()).getBlock(); - if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata) && this.c) { -- worldserver.a(this.a, true, entityvillager); -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.a, Blocks.AIR.getBlockData()).isCancelled()) { -+ worldserver.a(this.a, true, entityvillager); -+ } -+ // CraftBukkit end - } + if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata)) { +- worldserver.a(this.farmBlock, true, entityvillager); ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, Blocks.AIR.getBlockData()).isCancelled()) { ++ worldserver.a(this.farmBlock, true, entityvillager); ++ } ++ // CraftBukkit end + } - if (iblockdata.isAir() && block1 instanceof BlockSoil && this.b) { -@@ -110,19 +114,28 @@ - boolean flag = false; + if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.canPlant()) { +@@ -90,19 +94,28 @@ + boolean flag = false; - if (!itemstack.isEmpty()) { -+ // CraftBukkit start -+ Block planted = null; - if (itemstack.getItem() == Items.WHEAT_SEEDS) { -- worldserver.setTypeAndData(this.a, Blocks.WHEAT.getBlockData(), 3); -+ planted = Blocks.WHEAT; - flag = true; - } else if (itemstack.getItem() == Items.POTATO) { -- worldserver.setTypeAndData(this.a, Blocks.POTATOES.getBlockData(), 3); -+ planted = Blocks.POTATOES; - flag = true; - } else if (itemstack.getItem() == Items.CARROT) { -- worldserver.setTypeAndData(this.a, Blocks.CARROTS.getBlockData(), 3); -+ planted = Blocks.CARROTS; - flag = true; - } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) { -- worldserver.setTypeAndData(this.a, Blocks.BEETROOTS.getBlockData(), 3); -+ planted = Blocks.BEETROOTS; - flag = true; - } + if (!itemstack.isEmpty()) { ++ // CraftBukkit start ++ Block planted = null; + if (itemstack.getItem() == Items.WHEAT_SEEDS) { +- worldserver.setTypeAndData(this.farmBlock, Blocks.WHEAT.getBlockData(), 3); ++ planted = Blocks.WHEAT; + flag = true; + } else if (itemstack.getItem() == Items.POTATO) { +- worldserver.setTypeAndData(this.farmBlock, Blocks.POTATOES.getBlockData(), 3); ++ planted = Blocks.POTATOES; + flag = true; + } else if (itemstack.getItem() == Items.CARROT) { +- worldserver.setTypeAndData(this.farmBlock, Blocks.CARROTS.getBlockData(), 3); ++ planted = Blocks.CARROTS; + flag = true; + } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) { +- worldserver.setTypeAndData(this.farmBlock, Blocks.BEETROOTS.getBlockData(), 3); ++ planted = Blocks.BEETROOTS; + flag = true; + } + -+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.a, planted.getBlockData()).isCancelled()) { -+ worldserver.setTypeAndData(this.a, planted.getBlockData(), 3); -+ } else { -+ flag = false; -+ } -+ // CraftBukkit end - } ++ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, planted.getBlockData()).isCancelled()) { ++ worldserver.setTypeAndData(this.farmBlock, planted.getBlockData(), 3); ++ } else { ++ flag = false; ++ } ++ // CraftBukkit end + } - if (flag) { -@@ -141,8 +154,8 @@ - this.a = this.a(worldserver); - if (this.a != null) { - this.d = i + 20L; -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1))); -- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.a))); -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1))); // CraftBukkit - decompile error -+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.a))); // CraftBukkit - decompile error + if (flag) { +@@ -121,8 +134,8 @@ + this.farmBlock = this.a(worldserver); + if (this.farmBlock != null) { + this.c = i + 20L; +- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); +- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.farmBlock))); ++ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); // CraftBukkit - decompile error ++ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.farmBlock))); // CraftBukkit - decompile error + } } } - } diff --git a/nms-patches/BehaviorInteractDoor.patch b/nms-patches/BehaviorInteractDoor.patch index 1c2f409b17..575e7d3340 100644 --- a/nms-patches/BehaviorInteractDoor.patch +++ b/nms-patches/BehaviorInteractDoor.patch @@ -12,7 +12,7 @@ + } + // CaftBukkit end ((BlockDoor) block).setDoor(worldserver, blockposition, flag); - GlobalPos globalpos = GlobalPos.create(worldserver.getWorldProvider().getDimensionManager(), blockposition); + GlobalPos globalpos = GlobalPos.create(worldserver.getDimensionKey(), blockposition); if (!behaviorcontroller.getMemory(MemoryModuleType.OPENED_DOORS).isPresent() && flag) { - behaviorcontroller.setMemory(MemoryModuleType.OPENED_DOORS, (Object) Sets.newHashSet(new GlobalPos[]{globalpos})); diff --git a/nms-patches/BehaviorMakeLove.patch b/nms-patches/BehaviorMakeLove.patch index c40fc3fb76..32154cb3e7 100644 --- a/nms-patches/BehaviorMakeLove.patch +++ b/nms-patches/BehaviorMakeLove.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BehaviorMakeLove.java +++ b/net/minecraft/server/BehaviorMakeLove.java -@@ -100,6 +100,11 @@ +@@ -93,6 +93,11 @@ private Optional a(EntityVillager entityvillager, EntityVillager entityvillager1) { EntityVillager entityvillager2 = entityvillager.createChild(entityvillager1); @@ -12,7 +12,7 @@ if (entityvillager2 == null) { return Optional.empty(); -@@ -108,7 +113,7 @@ +@@ -101,7 +106,7 @@ entityvillager1.setAgeRaw(6000); entityvillager2.setAgeRaw(-24000); entityvillager2.setPositionRotation(entityvillager.locX(), entityvillager.locY(), entityvillager.locZ(), 0.0F, 0.0F); @@ -21,9 +21,9 @@ entityvillager.world.broadcastEntityEffect(entityvillager2, (byte) 12); return Optional.of(entityvillager2); } -@@ -117,6 +122,6 @@ +@@ -110,6 +115,6 @@ private void a(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) { - GlobalPos globalpos = GlobalPos.create(worldserver.getWorldProvider().getDimensionManager(), blockposition); + GlobalPos globalpos = GlobalPos.create(worldserver.getDimensionKey(), blockposition); - entityvillager.getBehaviorController().setMemory(MemoryModuleType.HOME, (Object) globalpos); + entityvillager.getBehaviorController().setMemory(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error diff --git a/nms-patches/BehaviorProfession.patch b/nms-patches/BehaviorProfession.patch index 93dda7c07e..0f08c136c3 100644 --- a/nms-patches/BehaviorProfession.patch +++ b/nms-patches/BehaviorProfession.patch @@ -25,6 +25,6 @@ + + entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - entityvillager.a(worldserver); + entityvillager.b(worldserver); } } diff --git a/nms-patches/BehaviorUtil.patch b/nms-patches/BehaviorUtil.patch index 8531646d58..fa7d6df0f5 100644 --- a/nms-patches/BehaviorUtil.patch +++ b/nms-patches/BehaviorUtil.patch @@ -1,30 +1,39 @@ --- a/net/minecraft/server/BehaviorUtil.java +++ b/net/minecraft/server/BehaviorUtil.java -@@ -31,7 +31,7 @@ +@@ -38,7 +38,7 @@ } - public static void c(EntityLiving entityliving, EntityLiving entityliving1) { -- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entityliving1))); -+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entityliving1))); // CraftBukkit - decompile error + public static void a(EntityLiving entityliving, EntityLiving entityliving1) { +- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entityliving1, true))); ++ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entityliving1, true))); // CraftBukkit - decompile error } - public static void d(EntityLiving entityliving, EntityLiving entityliving1) { -@@ -46,11 +46,12 @@ - BehaviorPositionEntity behaviorpositionentity = new BehaviorPositionEntity(entityliving1); - MemoryTarget memorytarget = new MemoryTarget(behaviorpositionentity, f, i); + private static void b(EntityLiving entityliving, EntityLiving entityliving1, float f) { +@@ -51,18 +51,19 @@ + public static void a(EntityLiving entityliving, Entity entity, float f, int i) { + MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entity, false), f, i); -- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) behaviorpositionentity); +- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entity, true))); - entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget); -+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, behaviorpositionentity); // CraftBukkit - decompile error ++ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entity, true))); // CraftBukkit - decompile error + entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error } - public static void a(EntityLiving entityliving, ItemStack itemstack, EntityLiving entityliving1) { + public static void a(EntityLiving entityliving, BlockPosition blockposition, float f, int i) { + MemoryTarget memorytarget = new MemoryTarget(new BehaviorTarget(blockposition), f, i); + +- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(blockposition))); +- entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget); ++ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(blockposition))); // CraftBukkit - decompile error ++ entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error + } + + public static void a(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) { + if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot double d0 = entityliving.getHeadY() - 0.30000001192092896D; EntityItem entityitem = new EntityItem(entityliving.world, entityliving.locX(), d0, entityliving.locZ(), itemstack); - BlockPosition blockposition = new BlockPosition(entityliving1); -@@ -66,7 +67,7 @@ + float f = 0.3F; +@@ -76,7 +77,7 @@ public static SectionPosition a(WorldServer worldserver, SectionPosition sectionposition, int i) { int j = worldserver.b(sectionposition); diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch index f6bfbec099..d1232830bd 100644 --- a/nms-patches/Block.patch +++ b/nms-patches/Block.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Block.java +++ b/net/minecraft/server/Block.java -@@ -489,7 +489,13 @@ +@@ -217,7 +217,13 @@ EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack); entityitem.defaultPickupDelay(); @@ -15,8 +15,8 @@ } } -@@ -682,6 +688,12 @@ - return "Block{" + IRegistry.BLOCK.getKey(this) + "}"; +@@ -344,6 +350,12 @@ + return this; } + // CraftBukkit start @@ -25,6 +25,6 @@ + } + // CraftBukkit end + - public static enum EnumRandomOffset { + public static final class a { - NONE, XZ, XYZ; + private final IBlockData a; diff --git a/nms-patches/BlockBamboo.patch b/nms-patches/BlockBamboo.patch index 4b8fd8d01f..2ed22225a9 100644 --- a/nms-patches/BlockBamboo.patch +++ b/nms-patches/BlockBamboo.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/BlockBamboo.java +++ b/net/minecraft/server/BlockBamboo.java -@@ -159,14 +159,18 @@ +@@ -168,14 +168,18 @@ BlockPosition blockposition1 = blockposition.down(2); IBlockData iblockdata2 = world.getType(blockposition1); BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE; + boolean shouldUpdateOthers = false; // CraftBukkit if (i >= 1) { - if (iblockdata1.getBlock() == Blocks.BAMBOO && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) { - if (iblockdata1.getBlock() == Blocks.BAMBOO && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) { + if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) { + if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) { blockpropertybamboosize = BlockPropertyBambooSize.LARGE; - if (iblockdata2.getBlock() == Blocks.BAMBOO) { + if (iblockdata2.a(Blocks.BAMBOO)) { - world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); - world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3); + // CraftBukkit start - moved down @@ -21,8 +21,8 @@ } } } else { -@@ -177,7 +181,14 @@ - int j = (Integer) iblockdata.get(BlockBamboo.d) != 1 && iblockdata2.getBlock() != Blocks.BAMBOO ? 0 : 1; +@@ -186,7 +190,14 @@ + int j = (Integer) iblockdata.get(BlockBamboo.d) != 1 && !iblockdata2.a(Blocks.BAMBOO) ? 0 : 1; int k = (i < 11 || random.nextFloat() >= 0.25F) && i != 15 ? 0 : 1; - world.setTypeAndData(blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.d, j)).set(BlockBamboo.e, blockpropertybamboosize)).set(BlockBamboo.f, k), 3); diff --git a/nms-patches/BlockBed.patch b/nms-patches/BlockBed.patch index 5f53477bd5..7cab7a89a8 100644 --- a/nms-patches/BlockBed.patch +++ b/nms-patches/BlockBed.patch @@ -1,54 +1,67 @@ --- a/net/minecraft/server/BlockBed.java +++ b/net/minecraft/server/BlockBed.java -@@ -43,7 +43,8 @@ +@@ -39,7 +39,8 @@ } } -- if (world.worldProvider.canRespawn() && world.getBiome(blockposition) != Biomes.NETHER) { +- if (!a(world)) { + // CraftBukkit - moved world and biome check into EntityHuman -+ if (true || world.worldProvider.canRespawn() && world.getBiome(blockposition) != Biomes.NETHER) { - if ((Boolean) iblockdata.get(BlockBed.OCCUPIED)) { - if (!this.a(world, blockposition)) { - entityhuman.a((IChatBaseComponent) (new ChatMessage("block.minecraft.bed.occupied", new Object[0])), true); -@@ -51,7 +52,16 @@ ++ if (false && !a(world)) { + world.a(blockposition, false); + BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite()); - return EnumInteractionResult.SUCCESS; - } else { -+ // CraftBukkit start -+ IBlockData finaliblockdata = iblockdata; -+ BlockPosition finalblockposition = blockposition; -+ // CraftBukkit end - entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> { -+ // CraftBukkit start - handling bed explosion from below here -+ if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) { -+ this.explodeBed(finaliblockdata, world, finalblockposition); -+ } else -+ // CraftBukkit end - if (entityhuman_enumbedresult != null) { - entityhuman.a(entityhuman_enumbedresult.a(), true); - } -@@ -59,7 +69,14 @@ - }); - return EnumInteractionResult.SUCCESS; - } -+ // CraftBukkit start - moved bed explosion into separate method +@@ -56,7 +57,16 @@ + + return EnumInteractionResult.SUCCESS; } else { ++ // CraftBukkit start ++ IBlockData finaliblockdata = iblockdata; ++ BlockPosition finalblockposition = blockposition; ++ // CraftBukkit end + entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> { ++ // CraftBukkit start - handling bed explosion from below here ++ if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) { ++ this.explodeBed(finaliblockdata, world, finalblockposition); ++ } else ++ // CraftBukkit end + if (entityhuman_enumbedresult != null) { + entityhuman.a(entityhuman_enumbedresult.a(), true); + } +@@ -67,8 +77,27 @@ + } + } + ++ // CraftBukkit start ++ private EnumInteractionResult explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) { ++ { ++ { ++ world.a(blockposition, false); ++ BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite()); ++ ++ if (world.getType(blockposition1).getBlock() == this) { ++ world.a(blockposition1, false); ++ } ++ ++ world.createExplosion((Entity) null, DamageSource.a(), (ExplosionDamageCalculator) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY); + return EnumInteractionResult.SUCCESS; + } + } + } ++ // CraftBukkit end + -+ private EnumInteractionResult explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) { - world.a(blockposition, false); - BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite()); - -@@ -69,8 +86,7 @@ - - world.createExplosion((Entity) null, DamageSource.a(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY); - return EnumInteractionResult.SUCCESS; -- } -- } -+ // CraftBukkit end + public static boolean a(World world) { +- return world.getDimensionManager().isBedWorks(); ++ // CraftBukkit - moved world and biome check into EntityHuman ++ return true || world.getDimensionManager().isBedWorks(); } private boolean a(World world, BlockPosition blockposition) { +@@ -225,7 +254,7 @@ + AxisAlignedBB axisalignedbb = entitytypes.a(vec3d.x, vec3d.y, vec3d.z); + + if (iworldreader.b(axisalignedbb)) { +- Stream stream = iworldreader.a(axisalignedbb.b(0.0D, -0.20000000298023224D, 0.0D)); ++ Stream stream = iworldreader.a(axisalignedbb.b(0.0D, -0.20000000298023224D, 0.0D)); // CraftBukkit - decompile error + + entitytypes.getClass(); + if (stream.noneMatch(entitytypes::a)) { diff --git a/nms-patches/BlockButtonAbstract.patch b/nms-patches/BlockButtonAbstract.patch index 4afb1fff31..4a5c6abd6b 100644 --- a/nms-patches/BlockButtonAbstract.patch +++ b/nms-patches/BlockButtonAbstract.patch @@ -12,7 +12,7 @@ public abstract class BlockButtonAbstract extends BlockAttachable { public static final BlockStateBoolean POWERED = BlockProperties.w; -@@ -71,6 +76,19 @@ +@@ -70,6 +75,19 @@ if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) { return EnumInteractionResult.CONSUME; } else { @@ -31,9 +31,9 @@ + // CraftBukkit end this.d(iblockdata, world, blockposition); this.a(entityhuman, world, blockposition, true); - return EnumInteractionResult.SUCCESS; -@@ -121,6 +139,16 @@ - if (this.D) { + return EnumInteractionResult.a(world.isClientSide); +@@ -120,6 +138,16 @@ + if (this.v) { this.e(iblockdata, (World) worldserver, blockposition); } else { + // CraftBukkit start @@ -47,9 +47,9 @@ + } + // CraftBukkit end worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3); - this.f(iblockdata, worldserver, blockposition); + this.f(iblockdata, (World) worldserver, blockposition); this.a((EntityHuman) null, worldserver, blockposition, false); -@@ -141,7 +169,44 @@ +@@ -140,7 +168,44 @@ boolean flag = !list.isEmpty(); boolean flag1 = (Boolean) iblockdata.get(BlockButtonAbstract.POWERED); diff --git a/nms-patches/BlockCactus.patch b/nms-patches/BlockCactus.patch index 4ba8044aa5..462566bbdc 100644 --- a/nms-patches/BlockCactus.patch +++ b/nms-patches/BlockCactus.patch @@ -8,17 +8,17 @@ + public class BlockCactus extends Block { - public static final BlockStateInteger AGE = BlockProperties.ad; -@@ -32,7 +34,7 @@ - int j = (Integer) iblockdata.get(BlockCactus.AGE); + public static final BlockStateInteger AGE = BlockProperties.aj; +@@ -37,7 +39,7 @@ + int j = (Integer) iblockdata.get(BlockCactus.AGE); - if (j == 15) { -- worldserver.setTypeUpdate(blockposition1, this.getBlockData()); -+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.getBlockData()); // CraftBukkit - IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0); + if (j == 15) { +- worldserver.setTypeUpdate(blockposition1, this.getBlockData()); ++ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.getBlockData()); // CraftBukkit + IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0); - worldserver.setTypeAndData(blockposition, iblockdata1, 4); -@@ -90,7 +92,9 @@ + worldserver.setTypeAndData(blockposition, iblockdata1, 4); +@@ -94,7 +96,9 @@ @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { diff --git a/nms-patches/BlockCampfire.patch b/nms-patches/BlockCampfire.patch index a8368992af..de9715346a 100644 --- a/nms-patches/BlockCampfire.patch +++ b/nms-patches/BlockCampfire.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockCampfire.java +++ b/net/minecraft/server/BlockCampfire.java -@@ -148,6 +148,11 @@ - if (flag1 && !(Boolean) iblockdata.get(BlockCampfire.b) && !(Boolean) iblockdata.get(BlockCampfire.d)) { - BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); +@@ -144,6 +144,11 @@ + if (flag && !(Boolean) iblockdata.get(BlockCampfire.b) && !(Boolean) iblockdata.get(BlockCampfire.d)) { + BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, entity).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11); - } ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, entity).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11); } + } diff --git a/nms-patches/BlockCauldron.patch b/nms-patches/BlockCauldron.patch index e483e549bc..5753283a5b 100644 --- a/nms-patches/BlockCauldron.patch +++ b/nms-patches/BlockCauldron.patch @@ -7,7 +7,7 @@ + public class BlockCauldron extends Block { - public static final BlockStateInteger LEVEL = BlockProperties.al; + public static final BlockStateInteger LEVEL = BlockProperties.ar; @@ -27,8 +29,13 @@ float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F; @@ -42,7 +42,7 @@ world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); } - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.a(world.isClientSide); } else if (item == Items.BUCKET) { if (i == 3 && !world.isClientSide) { + // CraftBukkit start @@ -82,7 +82,7 @@ + // CraftBukkit end } - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.a(world.isClientSide); } else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.WATER) { if (i < 3 && !world.isClientSide) { + // CraftBukkit start @@ -101,7 +101,7 @@ + // CraftBukkit end } - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.a(world.isClientSide); @@ -116,8 +143,13 @@ IDyeable idyeable = (IDyeable) item; diff --git a/nms-patches/BlockChest.patch b/nms-patches/BlockChest.patch index 629cf87f62..cb10e7948b 100644 --- a/nms-patches/BlockChest.patch +++ b/nms-patches/BlockChest.patch @@ -19,7 +19,7 @@ - - @Override - public IChatBaseComponent getScoreboardDisplayName() { -- return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble", new Object[0]))); +- return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble"))); - } - }); + return Optional.of(new DoubleInventory(tileentitychest, tileentitychest1, inventorylargechest)); // CraftBukkit @@ -57,15 +57,15 @@ + + @Override + public IChatBaseComponent getScoreboardDisplayName() { -+ return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble", new Object[0]))); ++ return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble"))); + } + }; + // CraftBukkit end + - protected BlockChest(Block.Info block_info, Supplier> supplier) { - super(block_info, supplier); - this.p((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.blockStateList.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.c, BlockPropertyChestType.SINGLE)).set(BlockChest.d, false)); -@@ -217,7 +232,7 @@ + protected BlockChest(BlockBase.Info blockbase_info, Supplier> supplier) { + super(blockbase_info, supplier); + this.j((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.blockStateList.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.c, BlockPropertyChestType.SINGLE)).set(BlockChest.d, false)); +@@ -218,7 +233,7 @@ } public DoubleBlockFinder.Result a(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) { diff --git a/nms-patches/BlockChorusFlower.patch b/nms-patches/BlockChorusFlower.patch index 75bf329f3f..f66e68b71c 100644 --- a/nms-patches/BlockChorusFlower.patch +++ b/nms-patches/BlockChorusFlower.patch @@ -8,47 +8,39 @@ + public class BlockChorusFlower extends Block { - public static final BlockStateInteger AGE = BlockProperties.ab; -@@ -58,8 +60,12 @@ - } + public static final BlockStateInteger AGE = BlockProperties.ah; +@@ -68,8 +70,12 @@ + } - if (flag && b((IWorldReader) worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmpty(blockposition.up(2))) { -- worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); -- this.b(worldserver, blockposition1, i); -+ // CraftBukkit start - add event -+ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) { -+ worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); -+ this.b(worldserver, blockposition1, i); -+ } -+ // CraftBukkit end - } else if (i < 4) { - j = random.nextInt(4); - if (flag1) { -@@ -73,18 +79,30 @@ - BlockPosition blockposition2 = blockposition.shift(enumdirection); + if (flag && b((IWorldReader) worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmpty(blockposition.up(2))) { +- worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); +- this.b(worldserver, blockposition1, i); ++ // CraftBukkit start - add event ++ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) { ++ worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); ++ this.b(worldserver, blockposition1, i); ++ } ++ // CraftBukkit end + } else if (i < 4) { + j = random.nextInt(4); + if (flag1) { +@@ -83,18 +89,30 @@ + BlockPosition blockposition2 = blockposition.shift(enumdirection); - if (worldserver.isEmpty(blockposition2) && worldserver.isEmpty(blockposition2.down()) && b((IWorldReader) worldserver, blockposition2, enumdirection.opposite())) { -- this.b(worldserver, blockposition2, i + 1); -- flag2 = true; -+ // CraftBukkit start - add event -+ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) { -+ this.b(worldserver, blockposition2, i + 1); -+ flag2 = true; -+ } -+ // CraftBukkit end - } - } - - if (flag2) { - worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); - } else { -- this.a((World) worldserver, blockposition); -+ // CraftBukkit - add event -+ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { -+ this.a((World) worldserver, blockposition); + if (worldserver.isEmpty(blockposition2) && worldserver.isEmpty(blockposition2.down()) && b((IWorldReader) worldserver, blockposition2, enumdirection.opposite())) { +- this.b(worldserver, blockposition2, i + 1); +- flag2 = true; ++ // CraftBukkit start - add event ++ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) { ++ this.b(worldserver, blockposition2, i + 1); ++ flag2 = true; + } + // CraftBukkit end } + } + + if (flag2) { + worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); } else { - this.a((World) worldserver, blockposition); + // CraftBukkit - add event @@ -57,5 +49,13 @@ + } + // CraftBukkit end } - + } else { +- this.a((World) worldserver, blockposition); ++ // CraftBukkit - add event ++ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { ++ this.a((World) worldserver, blockposition); ++ } ++ // CraftBukkit end } + + } diff --git a/nms-patches/BlockCocoa.patch b/nms-patches/BlockCocoa.patch index cc43844182..e6c02c1d32 100644 --- a/nms-patches/BlockCocoa.patch +++ b/nms-patches/BlockCocoa.patch @@ -8,8 +8,8 @@ + public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.Z; -@@ -22,7 +24,7 @@ + public static final BlockStateInteger AGE = BlockProperties.af; +@@ -27,7 +29,7 @@ int i = (Integer) iblockdata.get(BlockCocoa.AGE); if (i < 2) { @@ -18,7 +18,7 @@ } } -@@ -92,7 +94,7 @@ +@@ -97,7 +99,7 @@ @Override public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) { diff --git a/nms-patches/BlockComposter.patch b/nms-patches/BlockComposter.patch index 8659e34465..c46e7761a2 100644 --- a/nms-patches/BlockComposter.patch +++ b/nms-patches/BlockComposter.patch @@ -8,15 +8,15 @@ public class BlockComposter extends Block implements IInventoryHolder { - public static final BlockStateInteger a = BlockProperties.am; + public static final BlockStateInteger a = BlockProperties.as; public static final Object2FloatMap b = new Object2FloatOpenHashMap(); - public static final VoxelShape c = VoxelShapes.b(); + private static final VoxelShape c = VoxelShapes.b(); - private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> { + private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error for (int i = 0; i < 8; ++i) { avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST); } -@@ -220,7 +221,8 @@ +@@ -254,7 +255,8 @@ public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { int i = (Integer) iblockdata.get(BlockComposter.a); @@ -26,7 +26,7 @@ } static class ContainerInput extends InventorySubcontainer implements IWorldInventory { -@@ -232,6 +234,7 @@ +@@ -266,6 +268,7 @@ public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { super(1); @@ -34,7 +34,7 @@ this.a = iblockdata; this.b = generatoraccess; this.c = blockposition; -@@ -282,6 +285,7 @@ +@@ -318,6 +321,7 @@ this.blockData = iblockdata; this.generatorAccess = generatoraccess; this.blockPosition = blockposition; @@ -42,7 +42,7 @@ } @Override -@@ -306,15 +310,23 @@ +@@ -342,15 +346,23 @@ @Override public void update() { diff --git a/nms-patches/BlockConcretePowder.patch b/nms-patches/BlockConcretePowder.patch index 0918e65940..5c40d1d0d2 100644 --- a/nms-patches/BlockConcretePowder.patch +++ b/nms-patches/BlockConcretePowder.patch @@ -13,7 +13,7 @@ private final IBlockData a; @@ -12,7 +17,7 @@ @Override - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) { + public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) { if (canHarden(world, blockposition, iblockdata1)) { - world.setTypeAndData(blockposition, this.a, 3); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit diff --git a/nms-patches/BlockCoral.patch b/nms-patches/BlockCoral.patch index 93d56b09a3..b9e4ae9586 100644 --- a/nms-patches/BlockCoral.patch +++ b/nms-patches/BlockCoral.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/BlockCoral.java @@ -15,6 +15,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!this.a((IBlockAccess) worldserver, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData()).isCancelled()) { diff --git a/nms-patches/BlockCoralFan.patch b/nms-patches/BlockCoralFan.patch index 80e781bbff..882f91fa37 100644 --- a/nms-patches/BlockCoralFan.patch +++ b/nms-patches/BlockCoralFan.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/server/BlockCoralFan.java @@ -19,6 +19,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!b_(iblockdata, worldserver, blockposition)) { + public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData().set(BlockCoralFan.b, false)).isCancelled()) { + return; diff --git a/nms-patches/BlockCoralFanWall.patch b/nms-patches/BlockCoralFanWall.patch index 3463161cba..b751a4e461 100644 --- a/nms-patches/BlockCoralFanWall.patch +++ b/nms-patches/BlockCoralFanWall.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/server/BlockCoralFanWall.java @@ -19,6 +19,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!b_(iblockdata, worldserver, blockposition)) { + public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralFanWall.b, false).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a))).isCancelled()) { + return; diff --git a/nms-patches/BlockCoralPlant.patch b/nms-patches/BlockCoralPlant.patch index 3080c461ab..2845853b5b 100644 --- a/nms-patches/BlockCoralPlant.patch +++ b/nms-patches/BlockCoralPlant.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/server/BlockCoralPlant.java @@ -20,6 +20,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - if (!b_(iblockdata, worldserver, blockposition)) { + public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralPlant.b, false)).isCancelled()) { + return; diff --git a/nms-patches/BlockCrops.patch b/nms-patches/BlockCrops.patch index cb87630f36..5e8e9eb628 100644 --- a/nms-patches/BlockCrops.patch +++ b/nms-patches/BlockCrops.patch @@ -8,8 +8,8 @@ + public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.ac; -@@ -52,7 +54,7 @@ + public static final BlockStateInteger AGE = BlockProperties.ai; +@@ -56,7 +58,7 @@ float f = a((Block) this, (IBlockAccess) worldserver, blockposition); if (random.nextInt((int) (25.0F / f) + 1) == 0) { @@ -18,7 +18,7 @@ } } } -@@ -67,7 +69,7 @@ +@@ -71,7 +73,7 @@ i = j; } @@ -27,7 +27,7 @@ } protected int a(World world) { -@@ -125,7 +127,7 @@ +@@ -129,7 +131,7 @@ @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { diff --git a/nms-patches/BlockDiodeAbstract.patch b/nms-patches/BlockDiodeAbstract.patch index 259791ac06..7be1c166b6 100644 --- a/nms-patches/BlockDiodeAbstract.patch +++ b/nms-patches/BlockDiodeAbstract.patch @@ -27,4 +27,4 @@ + // CraftBukkit end worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, true), 2); if (!flag1) { - worldserver.getBlockTickList().a(blockposition, this, this.h(iblockdata), TickListPriority.VERY_HIGH); + worldserver.getBlockTickList().a(blockposition, this, this.g(iblockdata), TickListPriority.VERY_HIGH); diff --git a/nms-patches/BlockDirtSnowSpreadable.patch b/nms-patches/BlockDirtSnowSpreadable.patch index 6eb4261cfd..38dd7143dd 100644 --- a/nms-patches/BlockDirtSnowSpreadable.patch +++ b/nms-patches/BlockDirtSnowSpreadable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockDirtSnowSpreadable.java +++ b/net/minecraft/server/BlockDirtSnowSpreadable.java -@@ -30,6 +30,11 @@ +@@ -32,6 +32,11 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!b(iblockdata, (IWorldReader) worldserver, blockposition)) { @@ -12,12 +12,12 @@ worldserver.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); } else { if (worldserver.getLightLevel(blockposition.up()) >= 9) { -@@ -39,7 +44,7 @@ +@@ -41,7 +46,7 @@ BlockPosition blockposition1 = blockposition.b(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); - if (worldserver.getType(blockposition1).getBlock() == Blocks.DIRT && c(iblockdata1, (IWorldReader) worldserver, blockposition1)) { -- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).getBlock() == Blocks.SNOW)); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).getBlock() == Blocks.SNOW)); // CraftBukkit + if (worldserver.getType(blockposition1).a(Blocks.DIRT) && c(iblockdata1, (IWorldReader) worldserver, blockposition1)) { +- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); // CraftBukkit } } } diff --git a/nms-patches/BlockDispenser.patch b/nms-patches/BlockDispenser.patch index 1f9fe300f6..196408b0e9 100644 --- a/nms-patches/BlockDispenser.patch +++ b/nms-patches/BlockDispenser.patch @@ -12,7 +12,7 @@ public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) { BlockDispenser.REGISTRY.put(imaterial.getItem(), idispensebehavior); -@@ -58,6 +59,7 @@ +@@ -53,6 +54,7 @@ IDispenseBehavior idispensebehavior = this.a(itemstack); if (idispensebehavior != IDispenseBehavior.NONE) { diff --git a/nms-patches/BlockDoor.patch b/nms-patches/BlockDoor.patch index b7d9728788..a4cd74c32e 100644 --- a/nms-patches/BlockDoor.patch +++ b/nms-patches/BlockDoor.patch @@ -9,7 +9,7 @@ public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -171,9 +173,24 @@ +@@ -155,9 +157,24 @@ @Override public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { diff --git a/nms-patches/BlockEnderPortal.patch b/nms-patches/BlockEnderPortal.patch index 1a94312438..84f9409b3a 100644 --- a/nms-patches/BlockEnderPortal.patch +++ b/nms-patches/BlockEnderPortal.patch @@ -11,21 +11,19 @@ public class BlockEnderPortal extends BlockTileEntity { protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D); -@@ -21,7 +26,16 @@ - @Override - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.canPortal() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { -- entity.a(world.worldProvider.getDimensionManager() == DimensionManager.THE_END ? DimensionManager.OVERWORLD : DimensionManager.THE_END); +@@ -28,6 +33,15 @@ + return; + } + + // 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); + + if (entity instanceof EntityPlayer) { -+ ((EntityPlayer) entity).a(world.worldProvider.getDimensionManager().getType() == DimensionManager.THE_END ? DimensionManager.OVERWORLD : DimensionManager.THE_END, PlayerTeleportEvent.TeleportCause.END_PORTAL); ++ ((EntityPlayer) entity).a(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL); + return; + } -+ entity.a(world.worldProvider.getDimensionManager().getType() == DimensionManager.THE_END ? DimensionManager.OVERWORLD : DimensionManager.THE_END); + // CraftBukkit end + entity.a(worldserver); } - } diff --git a/nms-patches/BlockFire.patch b/nms-patches/BlockFire.patch index 9bb21b4103..cffe266ad7 100644 --- a/nms-patches/BlockFire.patch +++ b/nms-patches/BlockFire.patch @@ -1,28 +1,26 @@ --- a/net/minecraft/server/BlockFire.java +++ b/net/minecraft/server/BlockFire.java -@@ -7,6 +7,15 @@ - import java.util.Map.Entry; - import javax.annotation.Nullable; +@@ -5,6 +5,13 @@ + import java.util.Map; + import java.util.Random; +// CraftBukkit start -+import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; -+import org.bukkit.event.block.BlockSpreadEvent; +// CraftBukkit end + - public class BlockFire extends Block { + public class BlockFire extends BlockFireAbstract { - public static final BlockStateInteger AGE = BlockProperties.ad; -@@ -33,7 +42,20 @@ + public static final BlockStateInteger AGE = BlockProperties.aj; +@@ -26,7 +33,20 @@ @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { -- return this.canPlace(iblockdata, generatoraccess, blockposition) ? (IBlockData) this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData(); +- return this.canPlace(iblockdata, generatoraccess, blockposition) ? this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData(); + // CraftBukkit start -+ if (!iblockdata.canPlace(generatoraccess, blockposition)) { ++ if (!this.canPlace(iblockdata, generatoraccess, blockposition)) { + CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition); + blockState.setData(Blocks.AIR.getBlockData()); + @@ -33,21 +31,21 @@ + return blockState.getHandle(); + } + } -+ return this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)); ++ return this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)); + // CraftBukkit end } - @Nullable -@@ -82,7 +104,7 @@ - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + @Override +@@ -97,7 +117,7 @@ + worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random)); if (worldserver.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) { if (!iblockdata.canPlace(worldserver, blockposition)) { - worldserver.a(blockposition, false); + fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location } - Block block = worldserver.getType(blockposition.down()).getBlock(); -@@ -90,7 +112,7 @@ + IBlockData iblockdata1 = worldserver.getType(blockposition.down()); +@@ -105,7 +125,7 @@ int i = (Integer) iblockdata.get(BlockFire.AGE); if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { @@ -56,7 +54,7 @@ } else { int j = Math.min(15, i + random.nextInt(3) / 2); -@@ -105,14 +127,14 @@ +@@ -119,14 +139,14 @@ BlockPosition blockposition1 = blockposition.down(); if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) { @@ -67,57 +65,57 @@ return; } - if (i == 15 && random.nextInt(4) == 0 && !this.h(worldserver.getType(blockposition.down()))) { + if (i == 15 && random.nextInt(4) == 0 && !this.e(worldserver.getType(blockposition.down()))) { - worldserver.a(blockposition, false); + fireExtinguished(worldserver, blockposition); // CraftBukkit return; } } -@@ -120,12 +142,14 @@ - boolean flag1 = worldserver.s(blockposition); +@@ -134,12 +154,14 @@ + boolean flag1 = worldserver.u(blockposition); int k = flag1 ? -50 : 0; -- this.a(worldserver, blockposition.east(), 300 + k, random, i); -- this.a(worldserver, blockposition.west(), 300 + k, random, i); -- this.a(worldserver, blockposition.down(), 250 + k, random, i); -- this.a(worldserver, blockposition.up(), 250 + k, random, i); -- this.a(worldserver, blockposition.north(), 300 + k, random, i); -- this.a(worldserver, blockposition.south(), 300 + k, random, i); +- this.trySpread(worldserver, blockposition.east(), 300 + k, random, i); +- this.trySpread(worldserver, blockposition.west(), 300 + k, random, i); +- this.trySpread(worldserver, blockposition.down(), 250 + k, random, i); +- this.trySpread(worldserver, blockposition.up(), 250 + k, random, i); +- this.trySpread(worldserver, blockposition.north(), 300 + k, random, i); +- this.trySpread(worldserver, blockposition.south(), 300 + k, random, i); + // CraftBukkit start - add source blockposition to burn calls -+ this.a(worldserver, blockposition.east(), 300 + k, random, i, blockposition); -+ this.a(worldserver, blockposition.west(), 300 + k, random, i, blockposition); -+ this.a(worldserver, blockposition.down(), 250 + k, random, i, blockposition); -+ this.a(worldserver, blockposition.up(), 250 + k, random, i, blockposition); -+ this.a(worldserver, blockposition.north(), 300 + k, random, i, blockposition); -+ this.a(worldserver, blockposition.south(), 300 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.east(), 300 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.west(), 300 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.down(), 250 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.up(), 250 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.north(), 300 + k, random, i, blockposition); ++ this.trySpread(worldserver, blockposition.south(), 300 + k, random, i, blockposition); + // CraftBukkit end BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); for (int l = -1; l <= 1; ++l) { -@@ -151,7 +175,15 @@ +@@ -165,7 +187,15 @@ if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) { int j2 = Math.min(15, i + random.nextInt(5) / 4); -- worldserver.setTypeAndData(blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) worldserver, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, j2), 3); +- worldserver.setTypeAndData(blockposition_mutableblockposition, this.a(worldserver, blockposition_mutableblockposition, j2), 3); + // CraftBukkit start - Call to stop spread of fire + if (worldserver.getType(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) { + if (CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition_mutableblockposition, blockposition).isCancelled()) { + continue; + } + -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) worldserver, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, j2), 3); // CraftBukkit ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition_mutableblockposition, this.a(worldserver, blockposition_mutableblockposition, j2), 3); // CraftBukkit + } + // CraftBukkit end } } } -@@ -175,12 +207,24 @@ - return iblockdata.b((IBlockState) BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock()); +@@ -189,12 +219,24 @@ + return iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock()); } -- 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.i(world.getType(blockposition)); +- private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j) { ++ private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition + int k = this.getBurnChance(world.getType(blockposition)); if (random.nextInt(i) < k) { IBlockData iblockdata = world.getType(blockposition); @@ -137,29 +135,3 @@ if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) { int l = Math.min(j + random.nextInt(5) / 4, 15); -@@ -241,9 +285,10 @@ - @Override - public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { - if (iblockdata1.getBlock() != iblockdata.getBlock()) { -- if (world.worldProvider.getDimensionManager() != DimensionManager.OVERWORLD && world.worldProvider.getDimensionManager() != DimensionManager.NETHER || !((BlockPortal) Blocks.NETHER_PORTAL).a((GeneratorAccess) world, blockposition)) { -+ // CraftBukkit - getType() -+ if (world.worldProvider.getDimensionManager().getType() != DimensionManager.OVERWORLD && world.worldProvider.getDimensionManager().getType() != DimensionManager.NETHER || !((BlockPortal) Blocks.NETHER_PORTAL).a((GeneratorAccess) world, blockposition)) { - if (!iblockdata.canPlace(world, blockposition)) { -- world.a(blockposition, false); -+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke - } else { - world.getBlockTickList().a(blockposition, this, this.a((IWorldReader) world) + world.random.nextInt(10)); - } -@@ -392,4 +437,12 @@ - blockfire.a(Blocks.BEEHIVE, 5, 20); - blockfire.a(Blocks.BEE_NEST, 30, 20); - } -+ -+ // CraftBukkit start -+ private void fireExtinguished(GeneratorAccess world, BlockPosition position) { -+ if (!CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) { -+ world.a(position, false); -+ } -+ } -+ // CraftBukkit end - } diff --git a/nms-patches/BlockFireAbstract.patch b/nms-patches/BlockFireAbstract.patch new file mode 100644 index 0000000000..b11cf53220 --- /dev/null +++ b/nms-patches/BlockFireAbstract.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/server/BlockFireAbstract.java ++++ b/net/minecraft/server/BlockFireAbstract.java +@@ -41,7 +41,14 @@ + if (!entity.isFireProof()) { + entity.setFireTicks(entity.getFireTicks() + 1); + if (entity.getFireTicks() == 0) { +- entity.setOnFire(8); ++ // CraftBukkit start ++ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition), entity.getBukkitEntity(), 8); ++ world.getServer().getPluginManager().callEvent(event); ++ ++ if (!event.isCancelled()) { ++ entity.setOnFire(event.getDuration(), false); ++ } ++ // CraftBukkit end + } + + entity.damageEntity(DamageSource.FIRE, this.g); +@@ -53,9 +60,10 @@ + @Override + public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { + if (!iblockdata1.a(iblockdata.getBlock())) { +- if (world.getDimensionKey() != World.OVERWORLD && world.getDimensionKey() != World.THE_NETHER || !BlockPortal.a((GeneratorAccess) world, blockposition)) { ++ // CraftBukkit - getTypeKey() ++ if (world.getTypeKey()!= DimensionManager.OVERWORLD && world.getTypeKey()!= DimensionManager.THE_NETHER || !BlockPortal.a((GeneratorAccess) world, blockposition)) { + if (!iblockdata.canPlace(world, blockposition)) { +- world.a(blockposition, false); ++ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke + } + + } +@@ -92,4 +100,12 @@ + + return true; + } ++ ++ // CraftBukkit start ++ protected void fireExtinguished(GeneratorAccess world, BlockPosition position) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) { ++ world.a(position, false); ++ } ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/BlockFluids.patch b/nms-patches/BlockFluids.patch index 62d0d908f9..68bbc251e0 100644 --- a/nms-patches/BlockFluids.patch +++ b/nms-patches/BlockFluids.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/server/BlockFluids.java +++ b/net/minecraft/server/BlockFluids.java -@@ -111,14 +111,20 @@ - Fluid fluid = world.getFluid(blockposition); +@@ -113,14 +113,20 @@ + if (world.getFluid(blockposition1).a((Tag) TagsFluid.WATER)) { + Block block = world.getFluid(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; - if (fluid.isSource()) { -- world.setTypeUpdate(blockposition, Blocks.OBSIDIAN.getBlockData()); -- this.fizz(world, blockposition); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData())) { -+ this.fizz(world, blockposition); -+ } -+ // CraftBukkit end - return false; - } +- world.setTypeUpdate(blockposition, block.getBlockData()); +- this.fizz(world, blockposition); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.getBlockData())) { ++ this.fizz(world, blockposition); ++ } ++ // CraftBukkit end + return false; + } - if (fluid.getHeight(world, blockposition) >= 0.44444445F) { -- world.setTypeUpdate(blockposition, Blocks.COBBLESTONE.getBlockData()); -- this.fizz(world, blockposition); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData())) { -+ this.fizz(world, blockposition); -+ } -+ // CraftBukkit end - return false; + if (flag && world.getType(blockposition1).a(Blocks.BLUE_ICE)) { +- world.setTypeUpdate(blockposition, Blocks.BASALT.getBlockData()); +- this.fizz(world, blockposition); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.getBlockData())) { ++ this.fizz(world, blockposition); ++ } ++ // CraftBukkit end + return false; + } } - } diff --git a/nms-patches/BlockGrowingTop.patch b/nms-patches/BlockGrowingTop.patch new file mode 100644 index 0000000000..9549e95255 --- /dev/null +++ b/nms-patches/BlockGrowingTop.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/BlockGrowingTop.java ++++ b/net/minecraft/server/BlockGrowingTop.java +@@ -36,7 +36,7 @@ + BlockPosition blockposition1 = blockposition.shift(this.a); + + if (this.h(worldserver.getType(blockposition1))) { +- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d)); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d)); // CraftBukkit + } + } + diff --git a/nms-patches/BlockIce.patch b/nms-patches/BlockIce.patch index 6d5bc2f8aa..c4dc62bdac 100644 --- a/nms-patches/BlockIce.patch +++ b/nms-patches/BlockIce.patch @@ -5,10 +5,10 @@ protected void melt(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.worldProvider.isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.getDimensionManager().isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - if (world.worldProvider.isNether()) { + if (world.getDimensionManager().isNether()) { world.a(blockposition, false); } else { diff --git a/nms-patches/BlockJukeBox.patch b/nms-patches/BlockJukeBox.patch index 531fbd700d..5cd550ed1e 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 -@@ -25,7 +25,13 @@ +@@ -42,7 +42,13 @@ TileEntity tileentity = generatoraccess.getTileEntity(blockposition); if (tileentity instanceof TileEntityJukeBox) { diff --git a/nms-patches/BlockKelp.patch b/nms-patches/BlockKelp.patch deleted file mode 100644 index 00f48182ea..0000000000 --- a/nms-patches/BlockKelp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/BlockKelp.java -+++ b/net/minecraft/server/BlockKelp.java -@@ -44,7 +44,7 @@ - IBlockData iblockdata1 = worldserver.getType(blockposition1); - - if (iblockdata1.getBlock() == Blocks.WATER && (Integer) iblockdata.get(BlockKelp.a) < 25 && random.nextDouble() < 0.14D) { -- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockKelp.a)); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockKelp.a)); // CraftBukkit - } - - } diff --git a/nms-patches/BlockLeaves.patch b/nms-patches/BlockLeaves.patch index 685fe292fa..34c9f2fa5b 100644 --- a/nms-patches/BlockLeaves.patch +++ b/nms-patches/BlockLeaves.patch @@ -8,10 +8,10 @@ + public class BlockLeaves extends Block { - public static final BlockStateInteger DISTANCE = BlockProperties.ah; -@@ -20,6 +22,14 @@ + public static final BlockStateInteger DISTANCE = BlockProperties.an; +@@ -25,6 +27,14 @@ @Override - public void b(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (!(Boolean) iblockdata.get(BlockLeaves.PERSISTENT) && (Integer) iblockdata.get(BlockLeaves.DISTANCE) == 7) { + // CraftBukkit start + LeavesDecayEvent event = new LeavesDecayEvent(worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); diff --git a/nms-patches/BlockLectern.patch b/nms-patches/BlockLectern.patch index 81c3a26947..5c6e10f316 100644 --- a/nms-patches/BlockLectern.patch +++ b/nms-patches/BlockLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockLectern.java +++ b/net/minecraft/server/BlockLectern.java -@@ -151,12 +151,13 @@ +@@ -165,12 +165,13 @@ } private void d(IBlockData iblockdata, World world, BlockPosition blockposition) { diff --git a/nms-patches/BlockMinecartDetector.patch b/nms-patches/BlockMinecartDetector.patch index d75c736253..b63276b3dc 100644 --- a/nms-patches/BlockMinecartDetector.patch +++ b/nms-patches/BlockMinecartDetector.patch @@ -8,8 +8,8 @@ + public class BlockMinecartDetector extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockProperties.X; -@@ -62,6 +64,16 @@ + public static final BlockStateEnum SHAPE = BlockProperties.ad; +@@ -57,6 +59,16 @@ } IBlockData iblockdata1; diff --git a/nms-patches/BlockMonsterEggs.patch b/nms-patches/BlockMonsterEggs.patch index 21da5e70cf..08a2a82950 100644 --- a/nms-patches/BlockMonsterEggs.patch +++ b/nms-patches/BlockMonsterEggs.patch @@ -9,12 +9,12 @@ public class BlockMonsterEggs extends Block { private final Block a; -@@ -29,7 +31,7 @@ - EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a(world); +@@ -26,7 +28,7 @@ + EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a(world); - entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); -- world.addEntity(entitysilverfish); -+ world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason - entitysilverfish.doSpawnEffect(); - } + entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); +- world.addEntity(entitysilverfish); ++ world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason + entitysilverfish.doSpawnEffect(); + } diff --git a/nms-patches/BlockMushroom.patch b/nms-patches/BlockMushroom.patch index 83b4998ed3..33c0bbf9d8 100644 --- a/nms-patches/BlockMushroom.patch +++ b/nms-patches/BlockMushroom.patch @@ -20,7 +20,7 @@ } } -@@ -70,14 +74,16 @@ +@@ -69,14 +73,16 @@ WorldGenFeatureConfigured worldgenfeatureconfigured; if (this == Blocks.BROWN_MUSHROOM) { @@ -38,4 +38,4 @@ + worldgenfeatureconfigured = WorldGenerator.HUGE_RED_MUSHROOM.b(BiomeDecoratorGroups.HUGE_RED_MUSHROOM); // CraftBukkit - decompile error } - if (worldgenfeatureconfigured.a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition)) { + if (worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), random, blockposition)) { diff --git a/nms-patches/BlockNetherWart.patch b/nms-patches/BlockNetherWart.patch index 698bf8e67d..65cf73689b 100644 --- a/nms-patches/BlockNetherWart.patch +++ b/nms-patches/BlockNetherWart.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockNetherWart.java +++ b/net/minecraft/server/BlockNetherWart.java -@@ -28,7 +28,7 @@ +@@ -33,7 +33,7 @@ if (i < 3 && random.nextInt(10) == 0) { iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1); @@ -8,4 +8,4 @@ + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata, 2); // CraftBukkit } - super.tick(iblockdata, worldserver, blockposition, random); + } diff --git a/nms-patches/BlockNote.patch b/nms-patches/BlockNote.patch index ce30d691d4..9a4a1ebcb5 100644 --- a/nms-patches/BlockNote.patch +++ b/nms-patches/BlockNote.patch @@ -34,7 +34,7 @@ - this.play(world, blockposition); + this.play(world, blockposition, iblockdata); // CraftBukkit entityhuman.a(StatisticList.TUNE_NOTEBLOCK); - return EnumInteractionResult.SUCCESS; + return EnumInteractionResult.CONSUME; } @@ -58,7 +64,7 @@ @Override diff --git a/nms-patches/BlockObserver.patch b/nms-patches/BlockObserver.patch index 1b32ed39e5..187a322b60 100644 --- a/nms-patches/BlockObserver.patch +++ b/nms-patches/BlockObserver.patch @@ -11,7 +11,7 @@ public static final BlockStateBoolean b = BlockProperties.w; @@ -29,8 +31,18 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if ((Boolean) iblockdata.get(BlockObserver.b)) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) { diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch index 1f21e4f100..8eaade117f 100644 --- a/nms-patches/BlockPiston.patch +++ b/nms-patches/BlockPiston.patch @@ -15,7 +15,7 @@ public class BlockPiston extends BlockDirectional { public static final BlockStateBoolean EXTENDED = BlockProperties.g; -@@ -113,6 +121,18 @@ +@@ -103,6 +111,18 @@ } } @@ -31,13 +31,13 @@ + } + // PAIL: checkME - what happened to setTypeAndData? + // CraftBukkit end - world.playBlockAction(blockposition, this, b0, enumdirection.b()); + world.playBlockAction(blockposition, this, b0, enumdirection.c()); } -@@ -284,6 +304,48 @@ - int j = list.size() + list2.size(); - IBlockData[] aiblockdata = new IBlockData[j]; +@@ -277,6 +297,48 @@ + IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); + int j = 0; + // CraftBukkit start + final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + diff --git a/nms-patches/BlockPlant.patch b/nms-patches/BlockPlant.patch index 5c02045770..98cafaef15 100644 --- a/nms-patches/BlockPlant.patch +++ b/nms-patches/BlockPlant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockPlant.java +++ b/net/minecraft/server/BlockPlant.java -@@ -14,7 +14,14 @@ +@@ -12,7 +12,14 @@ @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { diff --git a/nms-patches/BlockPortal.patch b/nms-patches/BlockPortal.patch index bf7df2b703..1e178e37e6 100644 --- a/nms-patches/BlockPortal.patch +++ b/nms-patches/BlockPortal.patch @@ -13,19 +13,19 @@ + public class BlockPortal extends Block { - public static final BlockStateEnum AXIS = BlockProperties.D; + public static final BlockStateEnum AXIS = BlockProperties.E; @@ -34,7 +41,8 @@ } - if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIE_PIGMAN)) { -- Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false); + if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { +- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false); + // CraftBukkit - set spawn reason to NETHER_PORTAL -+ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); ++ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { - entity.portalCooldown = entity.ba(); + entity.portalCooldown = entity.getDefaultPortalCooldown(); @@ -48,8 +56,10 @@ - BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition); + BlockPortal.Shape blockportal_shape = b(generatoraccess, blockposition); if (blockportal_shape != null) { - blockportal_shape.createPortal(); @@ -45,7 +45,7 @@ + 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(blockposition); + entity.d(blockposition); } @@ -172,6 +186,7 @@ @@ -56,7 +56,7 @@ public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { this.a = generatoraccess; -@@ -230,6 +245,9 @@ +@@ -228,6 +243,9 @@ } protected int c() { @@ -66,9 +66,9 @@ int i; label56: -@@ -252,11 +270,21 @@ - block = this.a.getType(blockposition.shift(this.d)).getBlock(); - if (block != Blocks.OBSIDIAN) { +@@ -247,9 +265,19 @@ + if (i == 0) { + if (!this.a.getType(blockposition.shift(this.d)).a(Blocks.OBSIDIAN)) { break label56; + // CraftBukkit start - add the block to our list + } else { @@ -76,20 +76,18 @@ + blocks.add(CraftBlock.at(this.a, pos).getState()); + // CraftBukkit end } - } else if (i == this.width - 1) { - block = this.a.getType(blockposition.shift(this.c)).getBlock(); - if (block != Blocks.OBSIDIAN) { - break label56; -+ // CraftBukkit start - add the block to our list -+ } else { -+ BlockPosition pos = blockposition.shift(this.c); -+ blocks.add(CraftBlock.at(this.a, pos).getState()); -+ // CraftBukkit end - } + } else if (i == this.width - 1 && !this.a.getType(blockposition.shift(this.c)).a(Blocks.OBSIDIAN)) { + break label56; ++ // CraftBukkit start - add the block to our list ++ } else { ++ BlockPosition pos = blockposition.shift(this.c); ++ blocks.add(CraftBlock.at(this.a, pos).getState()); ++ // CraftBukkit end } } -@@ -266,6 +294,11 @@ - if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) { + } +@@ -258,6 +286,11 @@ + if (!this.a.getType(this.position.shift(this.c, i).up(this.height)).a(Blocks.OBSIDIAN)) { this.height = 0; break; + // CraftBukkit start - add the block to our list @@ -100,7 +98,7 @@ } } -@@ -289,7 +322,29 @@ +@@ -279,7 +312,29 @@ return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -131,7 +129,7 @@ for (int i = 0; i < this.width; ++i) { BlockPosition blockposition = this.position.shift(this.c, i); -@@ -298,6 +353,7 @@ +@@ -288,6 +343,7 @@ } } diff --git a/nms-patches/BlockPoweredRail.patch b/nms-patches/BlockPoweredRail.patch index cf868872be..0767f6985f 100644 --- a/nms-patches/BlockPoweredRail.patch +++ b/nms-patches/BlockPoweredRail.patch @@ -7,7 +7,7 @@ + public class BlockPoweredRail extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockProperties.X; + public static final BlockStateEnum SHAPE = BlockProperties.ad; @@ -102,6 +104,13 @@ boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0); @@ -21,4 +21,4 @@ + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, flag1), 3); world.applyPhysics(blockposition.down(), this); - if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).b()) { + if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) { diff --git a/nms-patches/BlockPressurePlateAbstract.patch b/nms-patches/BlockPressurePlateAbstract.patch index 147d7a3169..bc1c7cc895 100644 --- a/nms-patches/BlockPressurePlateAbstract.patch +++ b/nms-patches/BlockPressurePlateAbstract.patch @@ -9,7 +9,7 @@ public abstract class BlockPressurePlateAbstract extends Block { protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); -@@ -66,6 +68,19 @@ +@@ -65,6 +67,19 @@ boolean flag = i > 0; boolean flag1 = j > 0; diff --git a/nms-patches/BlockPressurePlateWeighted.patch b/nms-patches/BlockPressurePlateWeighted.patch index c629a15856..18afba2ebb 100644 --- a/nms-patches/BlockPressurePlateWeighted.patch +++ b/nms-patches/BlockPressurePlateWeighted.patch @@ -7,7 +7,7 @@ + public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { - public static final BlockStateInteger POWER = BlockProperties.at; + public static final BlockStateInteger POWER = BlockProperties.az; @@ -13,7 +15,31 @@ @Override diff --git a/nms-patches/BlockPumpkinCarved.patch b/nms-patches/BlockPumpkinCarved.patch index 43fea9cb43..4b523d17a5 100644 --- a/nms-patches/BlockPumpkinCarved.patch +++ b/nms-patches/BlockPumpkinCarved.patch @@ -10,7 +10,7 @@ +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +// CraftBukkit end + - public class BlockPumpkinCarved extends BlockFacingHorizontal { + public class BlockPumpkinCarved extends BlockFacingHorizontal implements ItemWearable { public static final BlockStateDirection a = BlockFacingHorizontal.FACING; @@ -42,19 +48,28 @@ diff --git a/nms-patches/BlockRedstoneComparator.patch b/nms-patches/BlockRedstoneComparator.patch index 15a04c6489..f4baf5e463 100644 --- a/nms-patches/BlockRedstoneComparator.patch +++ b/nms-patches/BlockRedstoneComparator.patch @@ -8,8 +8,8 @@ + public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity { - public static final BlockStateEnum MODE = BlockProperties.az; -@@ -70,7 +72,8 @@ + public static final BlockStateEnum MODE = BlockProperties.aG; +@@ -67,7 +69,8 @@ @Nullable private EntityItemFrame a(World world, EnumDirection enumdirection, BlockPosition blockposition) { @@ -19,7 +19,7 @@ return entityitemframe != null && entityitemframe.getDirection() == enumdirection; }); -@@ -125,8 +128,18 @@ +@@ -122,8 +125,18 @@ boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.c); if (flag1 && !flag) { diff --git a/nms-patches/BlockRedstoneLamp.patch b/nms-patches/BlockRedstoneLamp.patch index 6748e20358..c11918254a 100644 --- a/nms-patches/BlockRedstoneLamp.patch +++ b/nms-patches/BlockRedstoneLamp.patch @@ -9,7 +9,7 @@ public class BlockRedstoneLamp extends Block { public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; -@@ -37,6 +39,11 @@ +@@ -27,6 +29,11 @@ if (flag1) { world.getBlockTickList().a(blockposition, this, 4); } else { @@ -21,9 +21,9 @@ world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2); } } -@@ -47,6 +54,11 @@ +@@ -37,6 +44,11 @@ @Override - public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { + public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if ((Boolean) iblockdata.get(BlockRedstoneLamp.a) && !worldserver.isBlockIndirectlyPowered(blockposition)) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) { diff --git a/nms-patches/BlockRedstoneOre.patch b/nms-patches/BlockRedstoneOre.patch index d3623afc07..b651f806eb 100644 --- a/nms-patches/BlockRedstoneOre.patch +++ b/nms-patches/BlockRedstoneOre.patch @@ -12,7 +12,7 @@ public class BlockRedstoneOre extends Block { public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; -@@ -18,14 +23,30 @@ +@@ -13,14 +18,30 @@ @Override public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { @@ -46,14 +46,17 @@ } @Override -@@ -34,14 +55,19 @@ +@@ -28,7 +49,7 @@ + if (world.isClientSide) { playEffect(world, blockposition); - return EnumInteractionResult.SUCCESS; } else { - interact(iblockdata, world, blockposition); + interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman - return EnumInteractionResult.PASS; } + + ItemStack itemstack = entityhuman.b(enumhand); +@@ -36,9 +57,14 @@ + return itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).b() ? EnumInteractionResult.PASS : EnumInteractionResult.SUCCESS; } - private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -68,7 +71,7 @@ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3); } -@@ -50,6 +76,11 @@ +@@ -52,6 +78,11 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if ((Boolean) iblockdata.get(BlockRedstoneOre.a)) { @@ -80,7 +83,7 @@ worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3); } -@@ -58,12 +89,25 @@ +@@ -60,12 +91,25 @@ @Override public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { super.dropNaturally(iblockdata, world, blockposition, itemstack); diff --git a/nms-patches/BlockRedstoneTorch.patch b/nms-patches/BlockRedstoneTorch.patch index 1a9942cc07..f594c0f0e3 100644 --- a/nms-patches/BlockRedstoneTorch.patch +++ b/nms-patches/BlockRedstoneTorch.patch @@ -9,13 +9,13 @@ public class BlockRedstoneTorch extends BlockTorch { public static final BlockStateBoolean LIT = BlockProperties.r; -@@ -70,8 +72,24 @@ +@@ -62,8 +64,24 @@ list.remove(0); } + // CraftBukkit start -+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager(); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ org.bukkit.plugin.PluginManager manager = worldserver.getServer().getPluginManager(); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + int oldCurrent = ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0; + + BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent); @@ -31,13 +31,13 @@ + } + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3); - if (a(world, blockposition, true)) { - world.triggerEffect(1502, blockposition, 0); -@@ -79,6 +97,15 @@ + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3); + if (a(worldserver, blockposition, true)) { + worldserver.triggerEffect(1502, blockposition, 0); +@@ -71,6 +89,15 @@ } } - } else if (!flag && !a(world, blockposition, false)) { + } else if (!flag && !a(worldserver, blockposition, false)) { + // CraftBukkit start + if (oldCurrent != 15) { + event.setNewCurrent(15); @@ -47,6 +47,6 @@ + } + } + // CraftBukkit end - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, true), 3); + worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, true), 3); } diff --git a/nms-patches/BlockRedstoneWire.patch b/nms-patches/BlockRedstoneWire.patch index eae998a1a4..294a29fa6b 100644 --- a/nms-patches/BlockRedstoneWire.patch +++ b/nms-patches/BlockRedstoneWire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockRedstoneWire.java +++ b/net/minecraft/server/BlockRedstoneWire.java -@@ -11,6 +11,8 @@ +@@ -9,6 +9,8 @@ import java.util.Set; import javax.annotation.Nullable; @@ -8,20 +8,20 @@ + public class BlockRedstoneWire extends Block { - public static final BlockStateEnum NORTH = BlockProperties.R; -@@ -206,6 +208,15 @@ - l = j; - } + public static final BlockStateEnum NORTH = BlockProperties.X; +@@ -213,7 +215,14 @@ + private void a(World world, BlockPosition blockposition, IBlockData iblockdata) { + int i = this.a(world, blockposition); +- if ((Integer) iblockdata.get(BlockRedstoneWire.POWER) != i) { + // CraftBukkit start -+ if (i != l) { -+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, l); ++ int oldPower = (Integer) iblockdata.get(BlockRedstoneWire.POWER); ++ if (oldPower != i) { ++ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), oldPower, i); + world.getServer().getPluginManager().callEvent(event); + -+ l = event.getNewCurrent(); -+ } -+ // CraftBukkit end -+ - if (i != l) { - iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, l); - if (world.getType(blockposition) == iblockdata1) { ++ i = event.getNewCurrent(); ++ // CraftBukkit end + if (world.getType(blockposition) == iblockdata) { + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, i), 2); + } diff --git a/nms-patches/BlockReed.patch b/nms-patches/BlockReed.patch index 2fe7a05ad8..16d32eed35 100644 --- a/nms-patches/BlockReed.patch +++ b/nms-patches/BlockReed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockReed.java +++ b/net/minecraft/server/BlockReed.java -@@ -33,7 +33,7 @@ +@@ -39,7 +39,7 @@ int j = (Integer) iblockdata.get(BlockReed.AGE); if (j == 15) { diff --git a/nms-patches/BlockSapling.patch b/nms-patches/BlockSapling.patch index 83620a555d..62dd59f544 100644 --- a/nms-patches/BlockSapling.patch +++ b/nms-patches/BlockSapling.patch @@ -13,16 +13,16 @@ + public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger STAGE = BlockProperties.au; + public static final BlockStateInteger STAGE = BlockProperties.aA; protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); private final WorldGenTreeProvider c; + public static TreeType treeType; // CraftBukkit - protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, Block.Info block_info) { - super(block_info); -@@ -23,7 +31,30 @@ + protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) { + super(blockbase_info); +@@ -22,7 +30,30 @@ + @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { - super.tick(iblockdata, worldserver, blockposition, random); if (worldserver.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) { + // CraftBukkit start + worldserver.captureTreeGeneration = true; diff --git a/nms-patches/BlockSnow.patch b/nms-patches/BlockSnow.patch index 03feab20cf..f940552973 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 -@@ -58,6 +58,11 @@ +@@ -67,6 +67,11 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if (worldserver.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { diff --git a/nms-patches/BlockSoil.patch b/nms-patches/BlockSoil.patch index 16c4f42260..5dcd4e558f 100644 --- a/nms-patches/BlockSoil.patch +++ b/nms-patches/BlockSoil.patch @@ -11,23 +11,22 @@ + public class BlockSoil extends Block { - public static final BlockStateInteger MOISTURE = BlockProperties.aq; -@@ -53,12 +58,12 @@ + public static final BlockStateInteger MOISTURE = BlockProperties.aw; +@@ -58,26 +63,49 @@ - if (!a((IWorldReader) worldserver, blockposition) && !worldserver.isRainingAt(blockposition.up())) { - if (i > 0) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit - } else if (!a((IBlockAccess) worldserver, blockposition)) { - fade(iblockdata, worldserver, blockposition); - } - } else if (i < 7) { -- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); // CraftBukkit + if (!a((IWorldReader) worldserver, blockposition) && !worldserver.isRainingAt(blockposition.up())) { + if (i > 0) { +- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit + } else if (!a((IBlockAccess) worldserver, blockposition)) { + fade(iblockdata, worldserver, blockposition); } - + } else if (i < 7) { +- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); // CraftBukkit } -@@ -66,14 +71,37 @@ + + } @Override public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) { diff --git a/nms-patches/BlockSponge.patch b/nms-patches/BlockSponge.patch index d9b9d87abd..2e98c72d4e 100644 --- a/nms-patches/BlockSponge.patch +++ b/nms-patches/BlockSponge.patch @@ -33,7 +33,7 @@ + // CraftBukkit end Material material = iblockdata.getMaterial(); - if (fluid.a(TagsFluid.WATER)) { + if (fluid.a((Tag) TagsFluid.WATER)) { - if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition2, iblockdata) != FluidTypes.EMPTY) { + if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) { // CraftBukkit ++i; diff --git a/nms-patches/BlockStateInteger.patch b/nms-patches/BlockStateInteger.patch index 878d458dc4..6c86828965 100644 --- a/nms-patches/BlockStateInteger.patch +++ b/nms-patches/BlockStateInteger.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/BlockStateInteger.java +++ b/net/minecraft/server/BlockStateInteger.java @@ -9,9 +9,15 @@ - public class BlockStateInteger extends BlockState { + public class BlockStateInteger extends IBlockState { private final ImmutableSet a; + // CraftBukkit start diff --git a/nms-patches/BlockStem.patch b/nms-patches/BlockStem.patch index 16cde53af1..6703296f48 100644 --- a/nms-patches/BlockStem.patch +++ b/nms-patches/BlockStem.patch @@ -8,8 +8,8 @@ + public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.ac; -@@ -35,14 +37,18 @@ + public static final BlockStateInteger AGE = BlockProperties.ai; +@@ -34,14 +36,18 @@ if (i < 7) { iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1); @@ -18,9 +18,9 @@ } else { EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random); BlockPosition blockposition1 = blockposition.shift(enumdirection); - Block block = worldserver.getType(blockposition1.down()).getBlock(); + IBlockData iblockdata1 = worldserver.getType(blockposition1.down()); - if (worldserver.getType(blockposition1).isAir() && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL || block == Blocks.GRASS_BLOCK)) { + if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a(Blocks.DIRT) || iblockdata1.a(Blocks.COARSE_DIRT) || iblockdata1.a(Blocks.PODZOL) || iblockdata1.a(Blocks.GRASS_BLOCK))) { - worldserver.setTypeUpdate(blockposition1, this.blockFruit.getBlockData()); + // CraftBukkit start + if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.blockFruit.getBlockData())) { @@ -30,12 +30,12 @@ worldserver.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection)); } } -@@ -66,7 +72,7 @@ +@@ -65,7 +71,7 @@ int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5)); IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i); - worldserver.setTypeAndData(blockposition, iblockdata1, 2); + CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata1, 2); // CraftBukkit if (i == 7) { - iblockdata1.a(worldserver, blockposition, worldserver.random); + iblockdata1.b(worldserver, blockposition, worldserver.random); } diff --git a/nms-patches/BlockSweetBerryBush.patch b/nms-patches/BlockSweetBerryBush.patch index fe3bc44455..afe6e22ccc 100644 --- a/nms-patches/BlockSweetBerryBush.patch +++ b/nms-patches/BlockSweetBerryBush.patch @@ -11,7 +11,7 @@ public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { -@@ -24,7 +28,7 @@ +@@ -28,7 +32,7 @@ int i = (Integer) iblockdata.get(BlockSweetBerryBush.a); if (i < 3 && random.nextInt(5) == 0 && worldserver.getLightLevel(blockposition.up(), 0) >= 9) { @@ -20,8 +20,8 @@ } } -@@ -38,7 +42,9 @@ - double d1 = Math.abs(entity.locZ() - entity.G); +@@ -42,7 +46,9 @@ + double d1 = Math.abs(entity.locZ() - entity.F); if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { + CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit diff --git a/nms-patches/BlockTNT.patch b/nms-patches/BlockTNT.patch index 8760831d7d..def64b9012 100644 --- a/nms-patches/BlockTNT.patch +++ b/nms-patches/BlockTNT.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockTNT.java +++ b/net/minecraft/server/BlockTNT.java -@@ -95,6 +95,11 @@ +@@ -94,6 +94,11 @@ - if (entityarrow.isBurning()) { + if (iprojectile.isBurning()) { BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - a(world, blockposition, entity1 instanceof EntityLiving ? (EntityLiving) entity1 : null); + a(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null); world.a(blockposition, false); diff --git a/nms-patches/BlockTallPlant.patch b/nms-patches/BlockTallPlant.patch index be83c6b592..dea595b55e 100644 --- a/nms-patches/BlockTallPlant.patch +++ b/nms-patches/BlockTallPlant.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockTallPlant.java +++ b/net/minecraft/server/BlockTallPlant.java -@@ -54,6 +54,11 @@ +@@ -66,6 +66,11 @@ + } - @Override - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { + protected static void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { + return; + } + // CraftBukkit end BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF); - BlockPosition blockposition1 = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER ? blockposition.up() : blockposition.down(); - IBlockData iblockdata1 = world.getType(blockposition1); + + if (blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.UPPER) { diff --git a/nms-patches/BlockTurtleEgg.patch b/nms-patches/BlockTurtleEgg.patch index 728fe6046a..cd2011c60d 100644 --- a/nms-patches/BlockTurtleEgg.patch +++ b/nms-patches/BlockTurtleEgg.patch @@ -13,27 +13,27 @@ public class BlockTurtleEgg extends Block { -@@ -35,6 +41,19 @@ - super.stepOn(world, blockposition, entity); - } else { - if (!world.isClientSide && world.random.nextInt(i) == 0) { -+ // CraftBukkit start - Step on eggs -+ org.bukkit.event.Cancellable cancellable; -+ if (entity instanceof EntityHuman) { -+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); -+ } else { -+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition)); -+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); -+ } -+ -+ if (cancellable.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.a(world, blockposition, world.getType(blockposition)); - } +@@ -36,6 +42,19 @@ + IBlockData iblockdata = world.getType(blockposition); -@@ -60,9 +79,19 @@ + if (iblockdata.a(Blocks.TURTLE_EGG)) { ++ // CraftBukkit start - Step on eggs ++ org.bukkit.event.Cancellable cancellable; ++ if (entity instanceof EntityHuman) { ++ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); ++ } else { ++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition)); ++ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); ++ } ++ ++ if (cancellable.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.a(world, blockposition, iblockdata); + } + } +@@ -62,9 +81,19 @@ int i = (Integer) iblockdata.get(BlockTurtleEgg.a); if (i < 2) { @@ -54,9 +54,9 @@ worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); worldserver.a(blockposition, false); -@@ -73,7 +102,7 @@ +@@ -75,7 +104,7 @@ entityturtle.setAgeRaw(-24000); - entityturtle.g(blockposition); + entityturtle.setHomePos(blockposition); entityturtle.setPositionRotation((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F); - worldserver.addEntity(entityturtle); + worldserver.addEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit diff --git a/nms-patches/BlockVine.patch b/nms-patches/BlockVine.patch index 3505156ed3..c1940952f6 100644 --- a/nms-patches/BlockVine.patch +++ b/nms-patches/BlockVine.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/BlockVine.java +++ b/net/minecraft/server/BlockVine.java -@@ -6,6 +6,8 @@ - import java.util.Map.Entry; +@@ -5,6 +5,8 @@ + import java.util.Random; import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit @@ -9,7 +9,7 @@ public class BlockVine extends Block { public static final BlockStateBoolean UP = BlockSprawling.e; -@@ -177,20 +179,24 @@ +@@ -166,20 +168,24 @@ BlockPosition blockposition3 = blockposition2.shift(enumdirection1); BlockPosition blockposition4 = blockposition2.shift(enumdirection2); @@ -39,21 +39,21 @@ } } else if (a((IBlockAccess) worldserver, blockposition2, enumdirection)) { worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2); -@@ -220,7 +226,7 @@ +@@ -209,7 +215,7 @@ } - if (this.canSpread(iblockdata3)) { -- worldserver.setTypeAndData(blockposition1, iblockdata3, 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata3, 2); // CraftBukkit + if (this.canSpread(iblockdata2)) { +- worldserver.setTypeAndData(blockposition1, iblockdata2, 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2, 2); // CraftBukkit } return; -@@ -235,7 +241,7 @@ - IBlockData iblockdata5 = this.a(iblockdata, iblockdata4, random); +@@ -224,7 +230,7 @@ + IBlockData iblockdata4 = this.a(iblockdata, iblockdata3, random); - if (iblockdata4 != iblockdata5 && this.canSpread(iblockdata5)) { -- worldserver.setTypeAndData(blockposition2, iblockdata5, 2); -+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata5, 2); // CraftBukkit + if (iblockdata3 != iblockdata4 && this.canSpread(iblockdata4)) { +- worldserver.setTypeAndData(blockposition2, iblockdata4, 2); ++ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata4, 2); // CraftBukkit } } } diff --git a/nms-patches/BlockWitherRose.patch b/nms-patches/BlockWitherRose.patch index 1e0256b9b0..ee9660f473 100644 --- a/nms-patches/BlockWitherRose.patch +++ b/nms-patches/BlockWitherRose.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockWitherRose.java +++ b/net/minecraft/server/BlockWitherRose.java -@@ -20,7 +20,7 @@ +@@ -18,7 +18,7 @@ EntityLiving entityliving = (EntityLiving) entity; if (!entityliving.isInvulnerable(DamageSource.WITHER)) { diff --git a/nms-patches/BlockWitherSkull.patch b/nms-patches/BlockWitherSkull.patch index f53ca636ea..777c67a074 100644 --- a/nms-patches/BlockWitherSkull.patch +++ b/nms-patches/BlockWitherSkull.patch @@ -18,8 +18,8 @@ public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { + if (world.captureBlockStates) return; // CraftBukkit if (!world.isClientSide) { - Block block = tileentityskull.getBlock().getBlock(); - boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL; + IBlockData iblockdata = tileentityskull.getBlock(); + boolean flag = iblockdata.a(Blocks.WITHER_SKELETON_SKULL) || iblockdata.a(Blocks.WITHER_SKELETON_WALL_SKULL); @@ -35,12 +41,14 @@ ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition); @@ -38,9 +38,9 @@ } @@ -50,6 +58,15 @@ - entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().m() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); - entitywither.aI = shapedetector_shapedetectorcollection.getFacing().m() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; - entitywither.l(); + entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); + entitywither.aH = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; + entitywither.beginSpawnSequence(); + // CraftBukkit start + if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { + return; diff --git a/nms-patches/ChatHexColor.patch b/nms-patches/ChatHexColor.patch new file mode 100644 index 0000000000..fb88ca6044 --- /dev/null +++ b/nms-patches/ChatHexColor.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/server/ChatHexColor.java ++++ b/net/minecraft/server/ChatHexColor.java +@@ -10,7 +10,7 @@ + public final class ChatHexColor { + + private static final Map a = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::d).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { +- return new ChatHexColor(enumchatformat.e(), enumchatformat.f()); ++ return new ChatHexColor(enumchatformat.e(), enumchatformat.f(), enumchatformat); // CraftBukkit + })); + private static final Map b = (Map) ChatHexColor.a.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { + return chathexcolor.name; +@@ -18,16 +18,22 @@ + private final int rgb; + @Nullable + public final String name; ++ // CraftBukkit start ++ @Nullable ++ public final EnumChatFormat format; + +- private ChatHexColor(int i, String s) { ++ private ChatHexColor(int i, String s, EnumChatFormat format) { + this.rgb = i; + this.name = s; ++ this.format = format; + } + + private ChatHexColor(int i) { + this.rgb = i; + this.name = null; ++ this.format = null; + } ++ // CraftBukkit end + + public String b() { + return this.name != null ? this.name : this.c(); diff --git a/nms-patches/ChatModifier.patch b/nms-patches/ChatModifier.patch new file mode 100644 index 0000000000..ad063eb02d --- /dev/null +++ b/nms-patches/ChatModifier.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/server/ChatModifier.java ++++ b/net/minecraft/server/ChatModifier.java +@@ -114,6 +114,20 @@ + return new ChatModifier(this.color, this.bold, obool, this.underlined, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); + } + ++ // CraftBukkit start ++ public ChatModifier setStrikethrough(@Nullable Boolean obool) { ++ return new ChatModifier(this.color, this.bold, this.italic, this.underlined, obool, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); ++ } ++ ++ public ChatModifier setUnderline(@Nullable Boolean obool) { ++ return new ChatModifier(this.color, this.bold, this.italic, obool, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font); ++ } ++ ++ public ChatModifier setRandom(@Nullable Boolean obool) { ++ return new ChatModifier(this.color, this.bold, this.italic, this.underlined, this.strikethrough, obool, this.clickEvent, this.hoverEvent, this.insertion, this.font); ++ } ++ // CraftBukkit end ++ + public ChatModifier setChatClickable(@Nullable ChatClickable chatclickable) { + return new ChatModifier(this.color, this.bold, this.italic, this.underlined, this.strikethrough, this.obfuscated, chatclickable, this.hoverEvent, this.insertion, this.font); + } diff --git a/nms-patches/Chunk.patch b/nms-patches/Chunk.patch index 19e230aea0..07c86933ee 100644 --- a/nms-patches/Chunk.patch +++ b/nms-patches/Chunk.patch @@ -1,6 +1,24 @@ --- a/net/minecraft/server/Chunk.java +++ b/net/minecraft/server/Chunk.java -@@ -95,8 +95,19 @@ +@@ -31,7 +31,7 @@ + private BiomeStorage d; + private final Map e; + public boolean loaded; +- public final World world; ++ public final WorldServer world; // CraftBukkit - type + public final Map heightMap; + private final ChunkConverter i; + public final Map tileEntities; +@@ -65,7 +65,7 @@ + this.m = Maps.newHashMap(); + this.n = new ShortList[16]; + this.entitySlices = (EntitySlice[]) (new EntitySlice[16]); +- this.world = world; ++ this.world = (WorldServer) world; // CraftBukkit - type + this.loc = chunkcoordintpair; + this.i = chunkconverter; + HeightMap.Type[] aheightmap_type = HeightMap.Type.values(); +@@ -96,8 +96,19 @@ } } @@ -20,7 +38,7 @@ public Chunk(World world, ProtoChunk protochunk) { this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.getInhabitedTime(), protochunk.getSections(), (Consumer) null); Iterator iterator = protochunk.y().iterator(); -@@ -138,6 +149,7 @@ +@@ -139,6 +150,7 @@ this.b(protochunk.r()); this.s = true; @@ -28,7 +46,7 @@ } @Override -@@ -228,9 +240,16 @@ +@@ -229,9 +241,16 @@ } } @@ -45,7 +63,7 @@ int i = blockposition.getX() & 15; int j = blockposition.getY(); int k = blockposition.getZ() & 15; -@@ -282,7 +301,8 @@ +@@ -283,7 +302,8 @@ } } @@ -55,7 +73,7 @@ iblockdata.onPlace(this.world, blockposition, iblockdata1, flag); } -@@ -377,7 +397,12 @@ +@@ -378,7 +398,12 @@ @Nullable public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { @@ -69,8 +87,8 @@ if (tileentity == null) { NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition); -@@ -423,6 +448,13 @@ - tileentity1.ab_(); +@@ -424,6 +449,13 @@ + tileentity1.an_(); } + // CraftBukkit start @@ -83,7 +101,7 @@ } } -@@ -472,6 +504,50 @@ +@@ -473,6 +505,50 @@ } @@ -134,7 +152,7 @@ public void markDirty() { this.s = true; } -@@ -525,7 +601,7 @@ +@@ -526,7 +602,7 @@ Iterator iterator = this.entitySlices[k].a(Entity.class).iterator(); while (iterator.hasNext()) { @@ -143,7 +161,7 @@ if ((entitytypes == null || entity.getEntityType() == entitytypes) && entity.getBoundingBox().c(axisalignedbb) && predicate.test(entity)) { list.add(entity); -@@ -546,7 +622,7 @@ +@@ -547,7 +623,7 @@ Iterator iterator = this.entitySlices[k].a(oclass).iterator(); while (iterator.hasNext()) { @@ -152,7 +170,7 @@ if (t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { list.add(t0); -@@ -620,7 +696,7 @@ +@@ -621,7 +697,7 @@ @Override public boolean isNeedsSaving() { @@ -161,7 +179,7 @@ } public void d(boolean flag) { -@@ -761,7 +837,7 @@ +@@ -763,7 +839,7 @@ public void B() { if (this.o instanceof ProtoChunkTickList) { @@ -170,7 +188,7 @@ return this.getType(blockposition).getBlock(); }); this.o = TickListEmpty.b(); -@@ -771,7 +847,7 @@ +@@ -773,7 +849,7 @@ } if (this.p instanceof ProtoChunkTickList) { @@ -179,18 +197,18 @@ return this.getFluid(blockposition).getType(); }); this.p = TickListEmpty.b(); -@@ -783,12 +859,12 @@ +@@ -785,12 +861,12 @@ } public void a(WorldServer worldserver) { - if (this.o == TickListEmpty.b()) { + if (this.o == TickListEmpty.b()) { // CraftBukkit - decompile error - this.o = new TickListChunk<>(IRegistry.BLOCK::getKey, worldserver.getBlockTickList().a(this.loc, true, false)); + this.o = new TickListChunk<>(IRegistry.BLOCK::getKey, worldserver.getBlockTickList().a(this.loc, true, false), worldserver.getTime()); this.setNeedsSaving(true); } - if (this.p == TickListEmpty.b()) { + if (this.p == TickListEmpty.b()) { // CraftBukkit - decompile error - this.p = new TickListChunk<>(IRegistry.FLUID::getKey, worldserver.getFluidTickList().a(this.loc, true, false)); + this.p = new TickListChunk<>(IRegistry.FLUID::getKey, worldserver.getFluidTickList().a(this.loc, true, false), worldserver.getTime()); this.setNeedsSaving(true); } diff --git a/nms-patches/ChunkGenerator.patch b/nms-patches/ChunkGenerator.patch index 70378d5c3e..03b8ee7077 100644 --- a/nms-patches/ChunkGenerator.patch +++ b/nms-patches/ChunkGenerator.patch @@ -1,21 +1,31 @@ --- a/net/minecraft/server/ChunkGenerator.java +++ b/net/minecraft/server/ChunkGenerator.java -@@ -147,6 +147,18 @@ - StructureStart structurestart1 = StructureStart.a; - BiomeBase biomebase = biomemanager.a(new BlockPosition(chunkcoordintpair.d() + 9, 0, chunkcoordintpair.e() + 9)); +@@ -214,6 +214,13 @@ + while (iterator.hasNext()) { + StructureFeature structurefeature = (StructureFeature) iterator.next(); -+ // CraftBukkit start -+ if (structuregenerator == WorldGenerator.STRONGHOLD) { -+ synchronized (structuregenerator) { -+ if (structuregenerator.a(biomemanager, chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z, biomebase)) { -+ StructureStart structurestart2 = structuregenerator.a().create(structuregenerator, chunkcoordintpair.x, chunkcoordintpair.z, StructureBoundingBox.a(), i, chunkgenerator.getSeed()); -+ -+ structurestart2.a(this, definedstructuremanager, chunkcoordintpair.x, chunkcoordintpair.z, biomebase); -+ structurestart1 = structurestart2.e() ? structurestart2 : StructureStart.a; -+ } -+ } -+ } else -+ // CraftBukkit end - if (structuregenerator.a(biomemanager, chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z, biomebase)) { - StructureStart structurestart2 = structuregenerator.a().create(structuregenerator, chunkcoordintpair.x, chunkcoordintpair.z, StructureBoundingBox.a(), i, chunkgenerator.getSeed()); ++ // CraftBukkit start ++ if (structurefeature.b == StructureGenerator.STRONGHOLD) { ++ synchronized (structurefeature) { ++ this.a(structurefeature, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); ++ } ++ } else ++ // CraftBukkit end + this.a(structurefeature, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); + } +@@ -293,9 +300,11 @@ + } + + static { +- IRegistry.a(IRegistry.CHUNK_GENERATOR, "noise", (Object) ChunkGeneratorAbstract.d); +- IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", (Object) ChunkProviderFlat.d); +- IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", (Object) ChunkProviderDebug.e); ++ // CraftBukkit start - decompile errors ++ IRegistry.a(IRegistry.CHUNK_GENERATOR, "noise", ChunkGeneratorAbstract.d); ++ IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", ChunkProviderFlat.d); ++ IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", ChunkProviderDebug.e); ++ // CraftBukkit end + a = IRegistry.CHUNK_GENERATOR.dispatchStable(ChunkGenerator::a, Function.identity()); + } + } diff --git a/nms-patches/ChunkGeneratorAbstract.patch b/nms-patches/ChunkGeneratorAbstract.patch new file mode 100644 index 0000000000..b4220bc8c3 --- /dev/null +++ b/nms-patches/ChunkGeneratorAbstract.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/server/ChunkGeneratorAbstract.java ++++ b/net/minecraft/server/ChunkGeneratorAbstract.java +@@ -23,7 +23,7 @@ + return chunkgeneratorabstract.h; + })).apply(instance, instance.stable(ChunkGeneratorAbstract::new)); + }); +- private static final float[] i = (float[]) SystemUtils.a((Object) (new float[13824]), (afloat) -> { ++ private static final float[] i = (float[]) SystemUtils.a((new float[13824]), (afloat) -> { // CraftBukkit - decompile error + for (int i = 0; i < 24; ++i) { + for (int j = 0; j < 24; ++j) { + for (int k = 0; k < 24; ++k) { +@@ -33,7 +33,7 @@ + } + + }); +- private static final float[] j = (float[]) SystemUtils.a((Object) (new float[25]), (afloat) -> { ++ private static final float[] j = (float[]) SystemUtils.a((new float[25]), (afloat) -> { // CraftBukkit - decompile error + for (int i = -2; i <= 2; ++i) { + for (int j = -2; j <= 2; ++j) { + float f = 10.0F / MathHelper.c((float) (i * i + j * j) + 0.2F); +@@ -190,6 +190,11 @@ + f6 = f4; + f7 = f5; + } ++ // CraftBukkit start - fix MC-54738 ++ if (f6 < -1.8F) { ++ f6 = -1.8F; ++ } ++ // CraftBukkit end + + float f8 = f4 > f3 ? 0.5F : 1.0F; + float f9 = f8 * ChunkGeneratorAbstract.j[l + 2 + (i1 + 2) * 5] / (f6 + 2.0F); diff --git a/nms-patches/ChunkMapDistance.patch b/nms-patches/ChunkMapDistance.patch index 19f20b0c91..5a7f15d082 100644 --- a/nms-patches/ChunkMapDistance.patch +++ b/nms-patches/ChunkMapDistance.patch @@ -8,7 +8,7 @@ + if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error return ticket.b(this.currentTick); })) { - this.e.b(entry.getLongKey(), a((ArraySetSorted) entry.getValue()), false); + this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false); @@ -95,10 +95,25 @@ } @@ -38,15 +38,6 @@ return true; } else { if (!this.l.isEmpty()) { -@@ -120,7 +135,7 @@ - - completablefuture.thenAccept((either) -> { - this.m.execute(() -> { -- this.k.a((Object) ChunkTaskQueueSorter.a(() -> { -+ this.k.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error - }, j, false)); - }); - }); @@ -134,23 +149,25 @@ } } @@ -54,13 +45,13 @@ - private void addTicket(long i, Ticket ticket) { + private boolean addTicket(long i, Ticket ticket) { // CraftBukkit - void -> boolean ArraySetSorted> arraysetsorted = this.e(i); - int j = a(arraysetsorted); + int j = getLowestTicketLevel(arraysetsorted); - Ticket ticket1 = (Ticket) arraysetsorted.a((Object) ticket); + Ticket ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error ticket1.a(this.currentTick); if (ticket.b() < j) { - this.e.b(i, ticket.b(), true); + this.ticketLevelTracker.update(i, ticket.b(), true); } + return ticket == ticket1; // CraftBukkit @@ -80,7 +71,7 @@ @@ -158,16 +175,29 @@ } - this.e.b(i, a(arraysetsorted), false); + this.ticketLevelTracker.update(i, getLowestTicketLevel(arraysetsorted), false); + return removed; // CraftBukkit } @@ -123,7 +114,7 @@ + ArraySetSorted> tickets = entry.getValue(); + if (tickets.remove(target)) { + // copied from removeTicket -+ this.e.b(entry.getLongKey(), a(tickets), false); // PAIL ticketLevelTracker // PAIL update // PAIL getLowestTicketLevel ++ this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false); + + // can't use entry after it's removed + if (tickets.isEmpty()) { @@ -137,28 +128,3 @@ class a extends ChunkMap { public a() { -@@ -331,13 +381,13 @@ - Ticket ticket = new Ticket<>(TicketType.PLAYER, ChunkMapDistance.b, new ChunkCoordIntPair(i)); - - if (flag1) { -- ChunkMapDistance.this.j.a((Object) ChunkTaskQueueSorter.a(() -> { -+ ChunkMapDistance.this.j.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error - ChunkMapDistance.this.m.execute(() -> { - if (this.c(this.c(i))) { - ChunkMapDistance.this.addTicket(i, ticket); - ChunkMapDistance.this.l.add(i); - } else { -- ChunkMapDistance.this.k.a((Object) ChunkTaskQueueSorter.a(() -> { -+ ChunkMapDistance.this.k.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error - }, i, false)); - } - -@@ -346,7 +396,7 @@ - return j; - })); - } else { -- ChunkMapDistance.this.k.a((Object) ChunkTaskQueueSorter.a(() -> { -+ ChunkMapDistance.this.k.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error - ChunkMapDistance.this.m.execute(() -> { - ChunkMapDistance.this.removeTicket(i, ticket); - }); diff --git a/nms-patches/ChunkProviderGenerate.patch b/nms-patches/ChunkProviderGenerate.patch deleted file mode 100644 index 790ede79d8..0000000000 --- a/nms-patches/ChunkProviderGenerate.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/server/ChunkProviderGenerate.java -+++ b/net/minecraft/server/ChunkProviderGenerate.java -@@ -4,7 +4,7 @@ - - public class ChunkProviderGenerate extends ChunkGeneratorAbstract { - -- private static final float[] h = (float[]) SystemUtils.a((Object) (new float[25]), (afloat) -> { -+ private static final float[] h = (float[]) SystemUtils.a((new float[25]), (afloat) -> { // CraftBukkit - decompile error - for (int i = -2; i <= 2; ++i) { - for (int j = -2; j <= 2; ++j) { - float f = 10.0F / MathHelper.c((float) (i * i + j * j) + 0.2F); -@@ -83,6 +83,11 @@ - f4 = 1.0F + f4 * 2.0F; - f5 = 1.0F + f5 * 4.0F; - } -+ // CraftBukkit start - fix MC-54738 -+ if (f4 < -1.8F) { -+ f4 = -1.8F; -+ } -+ // CraftBukkit end - - float f6 = ChunkProviderGenerate.h[l + 2 + (i1 + 2) * 5] / (f4 + 2.0F); - diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch index 5111274053..d945a3d4d7 100644 --- a/nms-patches/ChunkProviderServer.patch +++ b/nms-patches/ChunkProviderServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkProviderServer.java +++ b/net/minecraft/server/ChunkProviderServer.java -@@ -51,6 +51,16 @@ +@@ -54,6 +54,16 @@ this.clearCache(); } @@ -17,7 +17,7 @@ @Override public LightEngineThreaded getLightEngine() { return this.lightEngine; -@@ -95,7 +105,7 @@ +@@ -98,7 +108,7 @@ for (int l = 0; l < 4; ++l) { if (k == this.cachePos[l] && chunkstatus == this.cacheStatus[l]) { ichunkaccess = this.cacheChunk[l]; @@ -26,7 +26,7 @@ return ichunkaccess; } } -@@ -141,12 +151,12 @@ +@@ -144,12 +154,12 @@ if (playerchunk == null) { return null; } else { @@ -41,7 +41,7 @@ if (ichunkaccess1 != null) { this.a(k, ichunkaccess1, ChunkStatus.FULL); -@@ -173,7 +183,15 @@ +@@ -176,7 +186,15 @@ int l = 33 + ChunkStatus.a(chunkstatus); PlayerChunk playerchunk = this.getChunk(k); @@ -58,7 +58,7 @@ this.chunkMapDistance.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); if (this.a(playerchunk, l)) { GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); -@@ -192,7 +210,7 @@ +@@ -195,7 +213,7 @@ } private boolean a(@Nullable PlayerChunk playerchunk, int i) { @@ -67,7 +67,30 @@ } public boolean isLoaded(int i, int j) { -@@ -294,11 +312,31 @@ +@@ -257,19 +275,19 @@ + public boolean a(Entity entity) { + long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4); + +- return this.a(i, PlayerChunk::b); ++ return this.a(i, (Function>>) PlayerChunk::b); // CraftBukkit - decompile error + } + + @Override + public boolean a(ChunkCoordIntPair chunkcoordintpair) { +- return this.a(chunkcoordintpair.pair(), PlayerChunk::b); ++ return this.a(chunkcoordintpair.pair(), (Function>>) PlayerChunk::b); // CraftBukkit - decompile error + } + + @Override + public boolean a(BlockPosition blockposition) { + long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4); + +- return this.a(i, PlayerChunk::a); ++ return this.a(i, (Function>>) PlayerChunk::a); // CraftBukkit - decompile error + } + + private boolean a(long i, Function>> function) { +@@ -291,11 +309,31 @@ @Override public void close() throws IOException { @@ -100,66 +123,22 @@ public void tick(BooleanSupplier booleansupplier) { this.world.getMethodProfiler().enter("purge"); this.chunkMapDistance.purgeTickets(); -@@ -318,13 +356,19 @@ +@@ -315,12 +353,12 @@ this.lastTickTime = i; WorldData worlddata = this.world.getWorldData(); - boolean flag = worlddata.getType() == WorldType.DEBUG_ALL_BLOCK_STATES; + boolean flag = this.world.isDebugWorld(); - boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING); + boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !world.getPlayers().isEmpty(); // CraftBukkit if (!flag) { this.world.getMethodProfiler().enter("pollingChunks"); int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED); - BlockPosition blockposition = this.world.getSpawn(); - boolean flag2 = worlddata.getTime() % 400L == 0L; -+ // CraftBukkit start - Other mob type spawn tick rate -+ boolean spawnAnimalThisTick = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; -+ boolean spawnMonsterThisTick = world.ticksPerMonsterSpawns != 0L && worlddata.getTime() % world.ticksPerMonsterSpawns == 0L; -+ boolean spawnWaterThisTick = world.ticksPerWaterSpawns != 0L && worlddata.getTime() % world.ticksPerWaterSpawns == 0L; -+ boolean spawnAmbientThisTick = world.ticksPerAmbientSpawns != 0L && worlddata.getTime() % world.ticksPerAmbientSpawns == 0L; -+ boolean flag2 = spawnAnimalThisTick; -+ // CraftBukkit end ++ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit this.world.getMethodProfiler().enter("naturalSpawnCount"); int l = this.chunkMapDistance.b(); -@@ -353,8 +397,35 @@ - for (int j1 = 0; j1 < i1; ++j1) { - EnumCreatureType enumcreaturetype = aenumcreaturetype1[j1]; - -+ // CraftBukkit start - Use per-world spawn limits -+ boolean spawnThisTick = true; -+ int limit = enumcreaturetype.b(); -+ switch (enumcreaturetype) { -+ case MONSTER: -+ spawnThisTick = spawnMonsterThisTick; -+ limit = world.getWorld().getMonsterSpawnLimit(); -+ break; -+ case CREATURE: -+ spawnThisTick = spawnAnimalThisTick; -+ limit = world.getWorld().getAnimalSpawnLimit(); -+ break; -+ case WATER_CREATURE: -+ spawnThisTick = spawnWaterThisTick; -+ limit = world.getWorld().getWaterAnimalSpawnLimit(); -+ break; -+ case AMBIENT: -+ spawnThisTick = spawnAmbientThisTick; -+ limit = world.getWorld().getAmbientSpawnLimit(); -+ break; -+ } -+ -+ if (!spawnThisTick || limit == 0) { -+ continue; -+ } -+ // CraftBukkit end -+ - if (enumcreaturetype != EnumCreatureType.MISC && (!enumcreaturetype.c() || this.allowAnimals) && (enumcreaturetype.c() || this.allowMonsters) && (!enumcreaturetype.d() || flag2)) { -- int k1 = enumcreaturetype.b() * l / ChunkProviderServer.b; -+ int k1 = limit * l / ChunkProviderServer.b; // CraftBukkit - use per-world limits - - if (object2intmap.getInt(enumcreaturetype) <= k1) { - SpawnerCreature.a(enumcreaturetype, this.world, chunk, blockposition); -@@ -507,12 +578,18 @@ +@@ -507,12 +545,18 @@ @Override protected boolean executeNext() { diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch index b04ba4f70a..ff4b686b65 100644 --- a/nms-patches/CommandBlockListenerAbstract.patch +++ b/nms-patches/CommandBlockListenerAbstract.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/CommandBlockListenerAbstract.java +++ b/net/minecraft/server/CommandBlockListenerAbstract.java @@ -4,6 +4,7 @@ - import java.text.SimpleDateFormat; import java.util.Date; + import java.util.UUID; import javax.annotation.Nullable; +import org.bukkit.command.CommandSender; public abstract class CommandBlockListenerAbstract implements ICommandListener { -@@ -16,6 +17,10 @@ +@@ -17,6 +18,10 @@ private IChatBaseComponent lastOutput; private String command = ""; private IChatBaseComponent customName; @@ -19,7 +19,7 @@ public CommandBlockListenerAbstract() { this.customName = CommandBlockListenerAbstract.c; -@@ -112,7 +117,7 @@ +@@ -113,7 +118,7 @@ }); diff --git a/nms-patches/CommandDispatcher.patch b/nms-patches/CommandDispatcher.patch index f199c5b4fb..11f9aaac45 100644 --- a/nms-patches/CommandDispatcher.patch +++ b/nms-patches/CommandDispatcher.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/server/CommandDispatcher.java +++ b/net/minecraft/server/CommandDispatcher.java -@@ -19,12 +19,21 @@ +@@ -17,12 +17,21 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import com.google.common.base.Joiner; ++import java.util.Collection; +import java.util.LinkedHashSet; -+import org.bukkit.craftbukkit.command.VanillaCommandWrapper; +import org.bukkit.event.player.PlayerCommandSendEvent; +import org.bukkit.event.server.ServerCommandEvent; +// CraftBukkit end @@ -17,30 +17,29 @@ private static final Logger LOGGER = LogManager.getLogger(); private final com.mojang.brigadier.CommandDispatcher b = new com.mojang.brigadier.CommandDispatcher(); -- public CommandDispatcher(boolean flag) { -+ // CraftBukkit start -+ public final CommandDispatcher init(boolean flag) { + public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) { ++ this(); // CraftBukkit CommandAdvancement.a(this.b); + CommandAttribute.a(this.b); CommandExecute.a(this.b); - CommandBossBar.a(this.b); -@@ -100,14 +109,59 @@ +@@ -103,14 +112,57 @@ } this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { - CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); + // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); // CraftBukkit }); -+ return this; +- this.b.setConsumer((commandcontext, flag, i) -> { +- ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i); + } + ++ // CraftBukkit start + public CommandDispatcher() { -+ // CraftBukkit end - this.b.setConsumer((commandcontext, flag1, i) -> { - ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i); ++ this.b.setConsumer((commandcontext, flag1, i) -> { ++ ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i); }); } -+ // CraftBukkit start + public int dispatchServerCommand(CommandListenerWrapper sender, String command) { + Joiner joiner = Joiner.on(" "); + if (command.startsWith("/")) { @@ -84,16 +83,16 @@ StringReader stringreader = new StringReader(s); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -134,7 +188,7 @@ +@@ -137,7 +189,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); - IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).a((chatmodifier) -> { -- chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s)); -+ chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit + IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> { +- return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s)); ++ return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit }); if (j > 10) { -@@ -184,11 +238,36 @@ +@@ -187,11 +239,36 @@ } public void a(EntityPlayer entityplayer) { @@ -131,7 +130,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); } -@@ -199,7 +278,7 @@ +@@ -202,7 +279,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -140,7 +139,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -222,7 +301,7 @@ +@@ -225,7 +302,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/nms-patches/CommandEffect.patch b/nms-patches/CommandEffect.patch index 1b97133194..42f5524389 100644 --- a/nms-patches/CommandEffect.patch +++ b/nms-patches/CommandEffect.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CommandEffect.java +++ b/net/minecraft/server/CommandEffect.java -@@ -63,7 +63,7 @@ +@@ -62,7 +62,7 @@ if (entity instanceof EntityLiving) { MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag); @@ -9,7 +9,7 @@ ++j; } } -@@ -89,7 +89,7 @@ +@@ -88,7 +88,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -18,7 +18,7 @@ ++i; } } -@@ -114,7 +114,7 @@ +@@ -113,7 +113,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/CommandListenerWrapper.patch b/nms-patches/CommandListenerWrapper.patch index 0a344c8502..070458cc12 100644 --- a/nms-patches/CommandListenerWrapper.patch +++ b/nms-patches/CommandListenerWrapper.patch @@ -7,8 +7,8 @@ +import com.mojang.brigadier.tree.CommandNode; import java.util.Collection; import java.util.Iterator; - import java.util.concurrent.CompletableFuture; -@@ -31,6 +32,7 @@ + import java.util.Set; +@@ -32,6 +33,7 @@ private final ResultConsumer l; private final ArgumentAnchor.Anchor m; private final Vec2F n; @@ -16,7 +16,7 @@ public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) { this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> { -@@ -120,9 +122,22 @@ +@@ -121,9 +123,22 @@ @Override public boolean hasPermission(int i) { @@ -39,18 +39,18 @@ public Vec3D getPosition() { return this.d; } -@@ -184,7 +199,7 @@ +@@ -185,7 +200,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - if (entityplayer != this.base && this.i.getPlayerList().isOp(entityplayer.getProfile())) { + if (entityplayer != this.base && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit - entityplayer.sendMessage(ichatbasecomponent1); + entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.b); } } -@@ -234,4 +249,10 @@ - public CompletableFuture a(CommandContext commandcontext, SuggestionsBuilder suggestionsbuilder) { - return null; +@@ -240,4 +255,10 @@ + public Set> p() { + return this.i.E(); } + + // CraftBukkit start diff --git a/nms-patches/CommandReload.patch b/nms-patches/CommandReload.patch new file mode 100644 index 0000000000..c1d0f19612 --- /dev/null +++ b/nms-patches/CommandReload.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/server/CommandReload.java ++++ b/net/minecraft/server/CommandReload.java +@@ -36,6 +36,16 @@ + return collection1; + } + ++ // CraftBukkit start ++ public static void reload(MinecraftServer minecraftserver) { ++ ResourcePackRepository resourcepackrepository = minecraftserver.getResourcePackRepository(); ++ SaveData savedata = minecraftserver.getSaveData(); ++ Collection collection = resourcepackrepository.d(); ++ Collection collection1 = a(resourcepackrepository, savedata, collection); ++ minecraftserver.a(collection1); ++ } ++ // CraftBukkit end ++ + public static void a(com.mojang.brigadier.CommandDispatcher com_mojang_brigadier_commanddispatcher) { + com_mojang_brigadier_commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) CommandDispatcher.a("reload").requires((commandlistenerwrapper) -> { + return commandlistenerwrapper.hasPermission(2); diff --git a/nms-patches/CommandSpreadPlayers.patch b/nms-patches/CommandSpreadPlayers.patch index 1a75511121..928dadb884 100644 --- a/nms-patches/CommandSpreadPlayers.patch +++ b/nms-patches/CommandSpreadPlayers.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CommandSpreadPlayers.java +++ b/net/minecraft/server/CommandSpreadPlayers.java -@@ -58,7 +58,7 @@ +@@ -61,7 +61,7 @@ if (entity instanceof EntityHuman) { set.add(entity.getScoreboardTeam()); } else { @@ -9,32 +9,32 @@ } } -@@ -266,7 +266,7 @@ +@@ -270,7 +270,7 @@ + + for (boolean flag2 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > 0; flag2 = flag1) { + blockposition_mutableblockposition.c(EnumDirection.DOWN); +- flag1 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); ++ flag1 = getType(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit + if (!flag1 && flag2 && flag) { + return blockposition_mutableblockposition.getY() + 1; } +@@ -283,7 +283,7 @@ - blockposition = blockposition.down(); -- } while (iblockaccess.getType(blockposition).isAir()); -+ } while (getType(iblockaccess, blockposition).isAir()); // CraftBukkit - - return blockposition.getY() + 1; - } -@@ -282,7 +282,7 @@ - } - - blockposition = blockposition.down(); -- iblockdata = iblockaccess.getType(blockposition); -+ iblockdata = getType(iblockaccess, blockposition); // CraftBukkit - } while (iblockdata.isAir()); - + public boolean b(IBlockAccess iblockaccess, int i) { + BlockPosition blockposition = new BlockPosition(this.a, (double) (this.a(iblockaccess, i) - 1), this.b); +- IBlockData iblockdata = iblockaccess.getType(blockposition); ++ IBlockData iblockdata = getType(iblockaccess, blockposition); // CraftBukkit Material material = iblockdata.getMaterial(); -@@ -294,5 +294,12 @@ + + return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE; +@@ -293,5 +293,12 @@ this.a = MathHelper.a(random, d0, d2); this.b = MathHelper.a(random, d1, d3); } + + // CraftBukkit start - add a version of getType which force loads chunks + private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) { -+ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4, true); ++ ((WorldServer) iblockaccess).getChunkProvider().getChunkAt(position.getX() >> 4, position.getZ() >> 4, true); + return iblockaccess.getType(position); + } + // CraftBukkit end diff --git a/nms-patches/CommandSummon.patch b/nms-patches/CommandSummon.patch deleted file mode 100644 index 8ebf13f2f8..0000000000 --- a/nms-patches/CommandSummon.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/CommandSummon.java -+++ b/net/minecraft/server/CommandSummon.java -@@ -30,7 +30,7 @@ - if (EntityTypes.getName(EntityTypes.LIGHTNING_BOLT).equals(minecraftkey)) { - EntityLightning entitylightning = new EntityLightning(commandlistenerwrapper.getWorld(), vec3d.x, vec3d.y, vec3d.z, false); - -- commandlistenerwrapper.getWorld().strikeLightning(entitylightning); -+ commandlistenerwrapper.getWorld().strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.COMMAND); // CraftBukkit - commandlistenerwrapper.sendMessage(new ChatMessage("commands.summon.success", new Object[]{entitylightning.getScoreboardDisplayName()}), true); - return 1; - } else { diff --git a/nms-patches/CommandTeleport.patch b/nms-patches/CommandTeleport.patch index 43b66a562e..feeb8e0a48 100644 --- a/nms-patches/CommandTeleport.patch +++ b/nms-patches/CommandTeleport.patch @@ -12,37 +12,37 @@ public class CommandTeleport { -@@ -121,9 +126,9 @@ - } +@@ -128,9 +133,9 @@ + } - if (worldserver == entity.world) { -- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set); -+ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - } else { -- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1); -+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - } + if (worldserver == entity.world) { +- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set); ++ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit + } else { +- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1); ++ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit + } - entity.setHeadRotation(f); -@@ -132,6 +137,21 @@ - float f3 = MathHelper.g(f1); + entity.setHeadRotation(f); +@@ -139,6 +144,21 @@ + float f3 = MathHelper.g(f1); - f3 = MathHelper.a(f3, -90.0F, 90.0F); -+ // CraftBukkit start - Teleport event -+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3); -+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to); -+ worldserver.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } + f3 = MathHelper.a(f3, -90.0F, 90.0F); ++ // CraftBukkit start - Teleport event ++ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3); ++ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to); ++ worldserver.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } + -+ d0 = to.getX(); -+ d1 = to.getY(); -+ d2 = to.getZ(); -+ f2 = to.getYaw(); -+ f3 = to.getPitch(); -+ worldserver = ((CraftWorld) to.getWorld()).getHandle(); -+ // CraftBukkit end - if (worldserver == entity.world) { - entity.setPositionRotation(d0, d1, d2, f2, f3); - entity.setHeadRotation(f2); ++ d0 = to.getX(); ++ d1 = to.getY(); ++ d2 = to.getZ(); ++ f2 = to.getYaw(); ++ f3 = to.getPitch(); ++ worldserver = ((CraftWorld) to.getWorld()).getHandle(); ++ // CraftBukkit end + if (worldserver == entity.world) { + entity.setPositionRotation(d0, d1, d2, f2, f3); + entity.setHeadRotation(f2); diff --git a/nms-patches/CommandTime.patch b/nms-patches/CommandTime.patch index 7b15b6daef..bf79dcb139 100644 --- a/nms-patches/CommandTime.patch +++ b/nms-patches/CommandTime.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/server/CommandTime.java +++ b/net/minecraft/server/CommandTime.java -@@ -4,6 +4,11 @@ +@@ -4,6 +4,10 @@ import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; - import com.mojang.brigadier.context.CommandContext; + import java.util.Iterator; +// CraftBukkit start +import org.bukkit.Bukkit; +import org.bukkit.event.world.TimeSkipEvent; +// CrafBukkit end -+ - import java.util.Iterator; public class CommandTime { -@@ -47,7 +52,13 @@ + +@@ -46,7 +50,13 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); @@ -27,7 +26,7 @@ } commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true); -@@ -60,7 +71,13 @@ +@@ -59,7 +69,13 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); diff --git a/nms-patches/Container.patch b/nms-patches/Container.patch index 1870b5ab67..e422011b52 100644 --- a/nms-patches/Container.patch +++ b/nms-patches/Container.patch @@ -47,7 +47,7 @@ protected Container(@Nullable Containers containers, int i) { this.e = containers; this.windowId = i; -@@ -180,6 +213,7 @@ +@@ -202,6 +235,7 @@ k = playerinventory.getCarried().getCount(); Iterator iterator = this.i.iterator(); @@ -55,7 +55,7 @@ while (iterator.hasNext()) { Slot slot1 = (Slot) iterator.next(); ItemStack itemstack3 = playerinventory.getCarried(); -@@ -195,12 +229,48 @@ +@@ -217,12 +251,48 @@ } k -= itemstack4.getCount() - j1; @@ -107,20 +107,20 @@ } this.d(); -@@ -217,8 +287,11 @@ +@@ -239,8 +309,11 @@ if (i == -999) { if (!playerinventory.getCarried().isEmpty()) { if (j == 0) { - entityhuman.drop(playerinventory.getCarried(), true); + // CraftBukkit start + ItemStack carried = playerinventory.getCarried(); - playerinventory.setCarried(ItemStack.a); + playerinventory.setCarried(ItemStack.b); + entityhuman.drop(carried, true); + // CraftBukkit start } if (j == 1) { -@@ -306,6 +379,15 @@ +@@ -328,6 +401,15 @@ } slot2.d(); @@ -135,15 +135,15 @@ + // CraftBukkit end } } - } else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) { -@@ -408,8 +490,11 @@ + } else if (inventoryclicktype == InventoryClickType.SWAP) { +@@ -430,8 +512,11 @@ PlayerInventory playerinventory = entityhuman.inventory; if (!playerinventory.getCarried().isEmpty()) { - entityhuman.drop(playerinventory.getCarried(), false); + // CraftBukkit start - SPIGOT-4556 + ItemStack carried = playerinventory.getCarried(); - playerinventory.setCarried(ItemStack.a); + playerinventory.setCarried(ItemStack.b); + entityhuman.drop(carried, false); + // CraftBukkit end } diff --git a/nms-patches/ContainerAnvil.patch b/nms-patches/ContainerAnvil.patch index 2a3ca1df19..e6dea04372 100644 --- a/nms-patches/ContainerAnvil.patch +++ b/nms-patches/ContainerAnvil.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerAnvil.java +++ b/net/minecraft/server/ContainerAnvil.java -@@ -6,6 +6,10 @@ +@@ -6,12 +6,20 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,68 +8,57 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerAnvil extends Container { + public class ContainerAnvil extends ContainerAnvilAbstract { private static final Logger LOGGER = LogManager.getLogger(); -@@ -16,6 +20,12 @@ private int h; public String renameText; - private final EntityHuman player; + public final ContainerProperty levelCost; + // CraftBukkit start + public int maximumRepairCost = 40; -+ private int lastLevelCost; + private CraftInventoryView bukkitEntity; -+ private PlayerInventory playerInventory; + // CraftBukkit end public ContainerAnvil(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.a); -@@ -23,6 +33,7 @@ - - public ContainerAnvil(int i, PlayerInventory playerinventory, final ContainerAccess containeraccess) { - super(Containers.ANVIL, i); -+ this.playerInventory = playerinventory; // CraftBukkit - this.resultInventory = new InventoryCraftResult(); - this.repairInventory = new InventorySubcontainer(2) { - @Override -@@ -123,7 +134,7 @@ +@@ -85,7 +93,7 @@ byte b1 = 0; if (itemstack.isEmpty()) { -- this.resultInventory.setItem(0, ItemStack.a); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit +- this.resultInventory.setItem(0, ItemStack.b); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit this.levelCost.set(0); } else { ItemStack itemstack1 = itemstack.cloneItemStack(); -@@ -141,7 +152,7 @@ +@@ -103,7 +111,7 @@ if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) { k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4); if (k <= 0) { -- this.resultInventory.setItem(0, ItemStack.a); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit +- this.resultInventory.setItem(0, ItemStack.b); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit this.levelCost.set(0); return; } -@@ -156,7 +167,7 @@ +@@ -118,7 +126,7 @@ this.h = i1; } else { if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) { -- this.resultInventory.setItem(0, ItemStack.a); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit +- this.resultInventory.setItem(0, ItemStack.b); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit this.levelCost.set(0); return; } -@@ -246,7 +257,7 @@ +@@ -208,7 +216,7 @@ } if (flag2 && !flag1) { -- this.resultInventory.setItem(0, ItemStack.a); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit +- this.resultInventory.setItem(0, ItemStack.b); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.b); // CraftBukkit this.levelCost.set(0); return; } -@@ -270,11 +281,11 @@ - itemstack1 = ItemStack.a; +@@ -232,11 +240,11 @@ + itemstack1 = ItemStack.b; } - if (b1 == i && b1 > 0 && this.levelCost.get() >= 40) { @@ -80,10 +69,10 @@ - if (this.levelCost.get() >= 40 && !this.player.abilities.canInstantlyBuild) { + if (this.levelCost.get() >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit - itemstack1 = ItemStack.a; + itemstack1 = ItemStack.b; } -@@ -293,7 +304,7 @@ +@@ -255,7 +263,7 @@ EnchantmentManager.a(map, itemstack1); } @@ -92,15 +81,7 @@ this.c(); } } -@@ -312,6 +323,7 @@ - - @Override - public boolean canUse(EntityHuman entityhuman) { -+ if (!this.checkReachable) return true; // CraftBukkit - return (Boolean) this.containerAccess.a((world, blockposition) -> { - return !world.getType(blockposition).a(TagsBlock.ANVIL) ? false : entityhuman.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; - }, true); -@@ -370,4 +382,18 @@ +@@ -278,4 +286,18 @@ this.e(); } diff --git a/nms-patches/ContainerAnvilAbstract.patch b/nms-patches/ContainerAnvilAbstract.patch new file mode 100644 index 0000000000..6129102138 --- /dev/null +++ b/nms-patches/ContainerAnvilAbstract.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/ContainerAnvilAbstract.java ++++ b/net/minecraft/server/ContainerAnvilAbstract.java +@@ -79,6 +79,7 @@ + + @Override + public boolean canUse(EntityHuman entityhuman) { ++ if (!this.checkReachable) return true; // CraftBukkit + return (Boolean) this.containerAccess.a((world, blockposition) -> { + return !this.a(world.getType(blockposition)) ? false : entityhuman.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; + }, true); diff --git a/nms-patches/ContainerBeacon.patch b/nms-patches/ContainerBeacon.patch index fe376ff026..2e0b86f2b5 100644 --- a/nms-patches/ContainerBeacon.patch +++ b/nms-patches/ContainerBeacon.patch @@ -34,7 +34,7 @@ return a(this.containerAccess, entityhuman, Blocks.BEACON); } -@@ -145,4 +153,17 @@ +@@ -143,4 +151,17 @@ return 1; } } diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch index 619e6638de..c0c3bbb163 100644 --- a/nms-patches/ContainerEnchantTable.patch +++ b/nms-patches/ContainerEnchantTable.patch @@ -115,7 +115,7 @@ this.c(); }); } else { -@@ -167,25 +231,53 @@ +@@ -167,9 +231,24 @@ ItemStack itemstack2 = itemstack; List list = this.a(itemstack, i, this.costs[i]); @@ -142,6 +142,7 @@ if (flag) { itemstack2 = new ItemStack(Items.ENCHANTED_BOOK); +@@ -182,16 +261,29 @@ this.enchantSlots.setItem(0, itemstack2); } @@ -177,7 +178,7 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack1.subtract(j); if (itemstack1.isEmpty()) { -@@ -232,6 +324,7 @@ +@@ -238,6 +330,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { @@ -185,7 +186,7 @@ return a(this.containerAccess, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -285,4 +378,17 @@ +@@ -289,4 +382,17 @@ return itemstack; } diff --git a/nms-patches/ContainerPlayer.patch b/nms-patches/ContainerPlayer.patch index 72b3e02e8c..e24a97afc7 100644 --- a/nms-patches/ContainerPlayer.patch +++ b/nms-patches/ContainerPlayer.patch @@ -51,9 +51,9 @@ } @Override -@@ -188,4 +206,17 @@ - public int h() { - return this.craftInventory.f(); +@@ -192,4 +210,17 @@ + public InventoryCrafting j() { + return this.craftInventory; } + + // CraftBukkit start diff --git a/nms-patches/ContainerSmithing.patch b/nms-patches/ContainerSmithing.patch new file mode 100644 index 0000000000..37bc0bd782 --- /dev/null +++ b/nms-patches/ContainerSmithing.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/server/ContainerSmithing.java ++++ b/net/minecraft/server/ContainerSmithing.java +@@ -3,12 +3,17 @@ + import java.util.List; + import javax.annotation.Nullable; + ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit ++ + public class ContainerSmithing extends ContainerAnvilAbstract { + + private final World g; + @Nullable + private RecipeSmithing h; + private final List i; ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity; ++ // CraftBukkit end + + public ContainerSmithing(int i, PlayerInventory playerinventory) { + this(i, playerinventory, ContainerAccess.a); +@@ -68,4 +73,18 @@ + return recipesmithing.a(itemstack); + }); + } ++ ++ // CraftBukkit start ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventorySmithing( ++ this.repairInventory, this.resultInventory); ++ bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/ContainerWorkbench.patch b/nms-patches/ContainerWorkbench.patch index fd067c4653..3a6d2a54bd 100644 --- a/nms-patches/ContainerWorkbench.patch +++ b/nms-patches/ContainerWorkbench.patch @@ -44,7 +44,7 @@ + protected static void a(int i, World world, EntityHuman entityhuman, InventoryCrafting inventorycrafting, InventoryCraftResult inventorycraftresult, Container container) { // CraftBukkit if (!world.isClientSide) { EntityPlayer entityplayer = (EntityPlayer) entityhuman; - ItemStack itemstack = ItemStack.a; + ItemStack itemstack = ItemStack.b; @@ -55,6 +67,7 @@ itemstack = recipecrafting.a(inventorycrafting); } diff --git a/nms-patches/Containers.patch b/nms-patches/Containers.patch index 8e6a97fbe6..60a5b5b4b5 100644 --- a/nms-patches/Containers.patch +++ b/nms-patches/Containers.patch @@ -9,8 +9,8 @@ }); public static final Containers LOOM = a("loom", ContainerLoom::new); public static final Containers MERCHANT = a("merchant", ContainerMerchant::new); -@@ -30,12 +30,17 @@ - private final Containers.Supplier x; +@@ -31,12 +31,17 @@ + private final Containers.Supplier y; private static Containers a(String s, Containers.Supplier containers_supplier) { - return (Containers) IRegistry.a(IRegistry.MENU, s, (Object) (new Containers<>(containers_supplier))); @@ -18,7 +18,7 @@ } private Containers(Containers.Supplier containers_supplier) { - this.x = containers_supplier; + this.y = containers_supplier; } - interface Supplier {} diff --git a/nms-patches/Convertable.patch b/nms-patches/Convertable.patch new file mode 100644 index 0000000000..00a4d8269c --- /dev/null +++ b/nms-patches/Convertable.patch @@ -0,0 +1,54 @@ +--- a/net/minecraft/server/Convertable.java ++++ b/net/minecraft/server/Convertable.java +@@ -175,8 +175,10 @@ + }; + } + +- public Convertable.ConversionSession c(String s) throws IOException { +- return new Convertable.ConversionSession(s); ++ // CraftBukkit start ++ public Convertable.ConversionSession c(String s, ResourceKey dimensionType) throws IOException { ++ return new Convertable.ConversionSession(s, dimensionType); ++ // CraftBukkit end + } + + public class ConversionSession implements AutoCloseable { +@@ -185,8 +187,12 @@ + public final java.nio.file.Path folder; + private final String levelName; + private final Map e = Maps.newHashMap(); ++ // CraftBukkit start ++ private final ResourceKey dimensionType; + +- public ConversionSession(String s) throws IOException { ++ public ConversionSession(String s, ResourceKey dimensionType) throws IOException { ++ this.dimensionType = dimensionType; ++ // CraftBukkit end + this.levelName = s; + this.folder = Convertable.this.universe.resolve(s); + this.lock = SessionLock.a(this.folder); +@@ -203,9 +209,23 @@ + } + + public File a(ResourceKey resourcekey) { +- return DimensionManager.a(resourcekey, this.folder.toFile()); ++ // CraftBukkit start ++ return this.getFolder(this.folder.toFile()); + } + ++ private File getFolder(File file) { ++ if (dimensionType == WorldDimension.OVERWORLD) { ++ return file; ++ } else if (dimensionType == WorldDimension.THE_NETHER) { ++ return new File(file, "DIM-1"); ++ } else if (dimensionType == WorldDimension.THE_END) { ++ return new File(file, "DIM1"); ++ } else { ++ throw new IllegalArgumentException("Unknwon dimension " + this.dimensionType); ++ } ++ } ++ // CraftBukkit end ++ + private void checkSession() { + if (!this.lock.a()) { + throw new IllegalStateException("Lock is no longer valid"); diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch index bb53a16843..1b4fc9a20c 100644 --- a/nms-patches/CraftingManager.patch +++ b/nms-patches/CraftingManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CraftingManager.java +++ b/net/minecraft/server/CraftingManager.java -@@ -22,11 +22,13 @@ +@@ -23,11 +23,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,9 +15,9 @@ private boolean d; public CraftingManager() { -@@ -35,7 +37,12 @@ +@@ -36,7 +38,12 @@ - protected void a(Map map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) { + protected void a(Map map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) { this.d = false; - Map, Builder>> map1 = Maps.newHashMap(); + // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable @@ -29,9 +29,9 @@ Iterator iterator = map.entrySet().iterator(); while (iterator.hasNext()) { -@@ -45,24 +52,42 @@ +@@ -46,24 +53,42 @@ try { - IRecipe irecipe = a(minecraftkey, (JsonObject) entry.getValue()); + IRecipe irecipe = a(minecraftkey, ChatDeserializer.m((JsonElement) entry.getValue(), "top element")); - ((Builder) map1.computeIfAbsent(irecipe.g(), (recipes) -> { - return ImmutableMap.builder(); @@ -66,9 +66,9 @@ + // CraftBukkit end + public > Optional craft(Recipes recipes, C c0, World world) { -- return this.a(recipes).values().stream().flatMap((irecipe) -> { +- return this.b(recipes).values().stream().flatMap((irecipe) -> { + // CraftBukkit start -+ Optional recipe = this.a(recipes).values().stream().flatMap((irecipe) -> { ++ Optional recipe = this.b(recipes).values().stream().flatMap((irecipe) -> { return SystemUtils.a(recipes.a(irecipe, world, c0)); }).findFirst(); + c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found @@ -76,17 +76,17 @@ + return recipe; } - public > List b(Recipes recipes, C c0, World world) { -@@ -74,7 +99,7 @@ + public > List a(Recipes recipes) { +@@ -81,7 +106,7 @@ } - private > Map> a(Recipes recipes) { + private > Map> b(Recipes recipes) { - return (Map) this.recipes.getOrDefault(recipes, Collections.emptyMap()); + return (Map) this.recipes.getOrDefault(recipes, new Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit } public > NonNullList c(Recipes recipes, C c0, World world) { -@@ -95,7 +120,7 @@ +@@ -102,7 +127,7 @@ public Optional> a(MinecraftKey minecraftkey) { return this.recipes.values().stream().map((map) -> { @@ -95,7 +95,7 @@ }).filter(Objects::nonNull).findFirst(); } -@@ -118,4 +143,14 @@ +@@ -125,4 +150,14 @@ return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'"); })).a(minecraftkey, jsonobject); } diff --git a/nms-patches/CustomFunction.patch b/nms-patches/CustomFunction.patch deleted file mode 100644 index 3f5c3a103b..0000000000 --- a/nms-patches/CustomFunction.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/CustomFunction.java -+++ b/net/minecraft/server/CustomFunction.java -@@ -48,7 +48,7 @@ - } - - try { -- ParseResults parseresults = customfunctiondata.getServer().getCommandDispatcher().a().parse(stringreader, customfunctiondata.g()); -+ ParseResults parseresults = customfunctiondata.getCommandDispatcher().parse(stringreader, customfunctiondata.g()); // CraftBukkit - - if (parseresults.getReader().canRead()) { - throw CommandDispatcher.a(parseresults); diff --git a/nms-patches/CustomFunctionData.patch b/nms-patches/CustomFunctionData.patch index 4badabd4e1..113934fe10 100644 --- a/nms-patches/CustomFunctionData.patch +++ b/nms-patches/CustomFunctionData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java -@@ -54,7 +54,7 @@ +@@ -30,7 +30,7 @@ } public com.mojang.brigadier.CommandDispatcher getCommandDispatcher() { diff --git a/nms-patches/DamageSource.patch b/nms-patches/DamageSource.patch index 265ff64bb7..aff8bdec0b 100644 --- a/nms-patches/DamageSource.patch +++ b/nms-patches/DamageSource.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/DamageSource.java +++ b/net/minecraft/server/DamageSource.java -@@ -36,6 +36,18 @@ +@@ -35,6 +35,18 @@ + private boolean D; private boolean E; - private boolean F; public final String translationIndex; + // CraftBukkit start + private boolean sweep; @@ -17,5 +17,5 @@ + } + // CraftBukkit end - public static DamageSource a(EntityLiving entityliving) { + public static DamageSource b(EntityLiving entityliving) { return new EntityDamageSource("sting", entityliving); diff --git a/nms-patches/DataConverterFlatten.patch b/nms-patches/DataConverterFlatten.patch index d6351b4f3e..44d8f67efe 100644 --- a/nms-patches/DataConverterFlatten.patch +++ b/nms-patches/DataConverterFlatten.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DataConverterFlatten.java +++ b/net/minecraft/server/DataConverterFlatten.java -@@ -376,7 +376,7 @@ +@@ -375,7 +375,7 @@ Typed typed2 = typed.getOrCreateTyped(opticfinder1); Dynamic dynamic1 = (Dynamic) typed2.get(DSL.remainderFinder()); diff --git a/nms-patches/DataConverterMap.patch b/nms-patches/DataConverterMap.patch index a97e488994..8b09d75408 100644 --- a/nms-patches/DataConverterMap.patch +++ b/nms-patches/DataConverterMap.patch @@ -5,7 +5,7 @@ Dynamic dynamic1 = (Dynamic) typed1.get(DSL.remainderFinder()); - dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.get("Damage").asInt(0))); -+ if (!dynamic1.getElement("map").isPresent()) dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.get("Damage").asInt(0))); // CraftBukkit ++ if (!dynamic1.getElement("map").result().isPresent()) dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.get("Damage").asInt(0))); // CraftBukkit return typed.set(opticfinder1, typed1.set(DSL.remainderFinder(), dynamic1)); } else { return typed; diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch index 68646a4317..4e210d2d8f 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 -@@ -26,6 +26,17 @@ +@@ -22,6 +22,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -18,20 +18,20 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer { private static final Logger LOGGER = LogManager.getLogger(); -@@ -39,8 +50,10 @@ +@@ -34,8 +45,10 @@ @Nullable - private ServerGUI p; + private ServerGUI q; -- public DedicatedServer(File file, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { -- super(file, Proxy.NO_PROXY, datafixer, new CommandDispatcher(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory, s); +- public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { +- super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + // CraftBukkit start - Signature changed -+ public DedicatedServer(joptsimple.OptionSet options, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { -+ super(options, Proxy.NO_PROXY, datafixer, new CommandDispatcher().init(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory, s); ++ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { ++ super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + // CraftBukkit end this.propertyManager = dedicatedserversettings; this.remoteControlCommandListener = new RemoteControlCommandListener(this); - Thread thread = new Thread("Server Infinisleeper") { -@@ -66,13 +79,44 @@ + } +@@ -44,13 +57,44 @@ public boolean init() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { @@ -79,7 +79,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -81,6 +125,27 @@ +@@ -59,6 +103,27 @@ } }; @@ -107,12 +107,21 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -134,6 +199,12 @@ +@@ -85,7 +150,7 @@ + this.setForceGamemode(dedicatedserverproperties.forceGamemode); + super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); + this.i(dedicatedserverproperties.enforceWhitelist); +- this.saveData.setGameType(dedicatedserverproperties.gamemode); ++ // this.saveData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading + DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); + InetAddress inetaddress = null; + +@@ -110,6 +175,12 @@ return false; } + // CraftBukkit start -+ this.a((PlayerList) (new DedicatedPlayerList(this))); ++ this.a((PlayerList) (new DedicatedPlayerList(this, this.f, this.worldNBTStorage))); + server.loadPlugins(); + server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); + // CraftBukkit end @@ -120,31 +129,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."); -@@ -148,7 +219,7 @@ +@@ -124,7 +195,7 @@ if (!NameReferencingFileConverter.e(this)) { return false; } else { -- this.a((PlayerList) (new DedicatedPlayerList(this))); -+ this.convertable = new Convertable(server.getWorldContainer().toPath(), server.getWorldContainer().toPath().resolve("../backups"), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor +- this.a((PlayerList) (new DedicatedPlayerList(this, this.f, this.worldNBTStorage))); ++ // this.a((PlayerList) (new DedicatedPlayerList(this, this.f, this.worldNBTStorage))); // CraftBukkit - moved up long i = SystemUtils.getMonotonicNanos(); - String s = dedicatedserverproperties.levelSeed; - String s1 = dedicatedserverproperties.generatorSettings; -@@ -178,7 +249,13 @@ - if (worldtype == WorldType.FLAT) { - jsonobject.addProperty("flat_world_options", s1); - } else if (!s1.isEmpty()) { -- jsonobject = ChatDeserializer.a(s1); -+ // CraftBukkit start -+ try { -+ jsonobject = ChatDeserializer.a(s1); -+ } catch (Exception ex) { -+ DedicatedServer.LOGGER.warn("Invalid generator-settings, ignoring", ex); -+ } -+ // CraftBukkit end - } - this.a(this.getWorld(), this.getWorld(), j, worldtype, jsonobject); -@@ -200,6 +277,7 @@ + this.c(dedicatedserverproperties.maxBuildHeight); +@@ -132,7 +203,7 @@ + TileEntitySkull.a(this.getMinecraftSessionService()); + UserCache.a(this.getOnlineMode()); + DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld()); +- this.loadWorld(); ++ this.loadWorld(convertable.getLevelName()); // CraftBukkit + long j = SystemUtils.getMonotonicNanos() - i; + String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D); + +@@ -151,6 +222,7 @@ DedicatedServer.LOGGER.info("Starting remote control listener"); this.remoteControlListener = new RemoteControlListener(this); this.remoteControlListener.a(); @@ -152,7 +155,7 @@ } if (this.getMaxTickTime() > 0L) { -@@ -307,6 +385,7 @@ +@@ -261,6 +333,7 @@ this.remoteStatusListener.b(); } @@ -160,7 +163,7 @@ } @Override -@@ -340,7 +419,15 @@ +@@ -289,7 +362,15 @@ while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); @@ -177,7 +180,7 @@ } } -@@ -540,14 +627,45 @@ +@@ -494,14 +575,45 @@ @Override public String getPlugins() { @@ -225,13 +228,12 @@ }); return this.remoteControlCommandListener.getMessages(); } -@@ -568,4 +686,16 @@ - public boolean a(GameProfile gameprofile) { - return false; +@@ -537,4 +649,15 @@ + public boolean isSyncChunkWrites() { + return this.propertyManager.getProperties().syncChunkWrites; } + + // CraftBukkit start -+ @Override + public boolean isDebugging() { + return this.getDedicatedServerProperties().debug; + } diff --git a/nms-patches/DedicatedServerProperties.patch b/nms-patches/DedicatedServerProperties.patch index 70de039a76..d4d2bd2b07 100644 --- a/nms-patches/DedicatedServerProperties.patch +++ b/nms-patches/DedicatedServerProperties.patch @@ -12,9 +12,9 @@ public final boolean onlineMode = this.getBoolean("online-mode", true); public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false); public final String serverIp = this.getString("server-ip", ""); -@@ -52,8 +54,10 @@ - public final PropertyManager.EditableProperty playerIdleTimeout; +@@ -53,8 +55,10 @@ public final PropertyManager.EditableProperty whiteList; + public final GeneratorSettings generatorSettings; - public DedicatedServerProperties(Properties properties) { - super(properties); @@ -25,8 +25,8 @@ this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY); this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL); this.levelName = this.getString("level-name", "world"); -@@ -98,12 +102,14 @@ - this.whiteList = this.b("white-list", false); +@@ -103,12 +107,14 @@ + this.generatorSettings = GeneratorSettings.a(properties); } - public static DedicatedServerProperties load(java.nio.file.Path java_nio_file_path) { diff --git a/nms-patches/DefinedStructure.patch b/nms-patches/DefinedStructure.patch index 203f463d2f..8b54713ac7 100644 --- a/nms-patches/DefinedStructure.patch +++ b/nms-patches/DefinedStructure.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/server/DefinedStructure.java +++ b/net/minecraft/server/DefinedStructure.java -@@ -84,7 +84,7 @@ +@@ -98,7 +98,7 @@ + } + + private static List a(List list, List list1, List list2) { +- Comparator comparator = Comparator.comparingInt((definedstructure_blockinfo) -> { ++ Comparator comparator = Comparator.comparingInt((definedstructure_blockinfo) -> { // CraftBukkit - decompile error + return definedstructure_blockinfo.a.getY(); + }).thenComparingInt((definedstructure_blockinfo) -> { + return definedstructure_blockinfo.a.getX(); +@@ -118,7 +118,7 @@ } private void a(World world, BlockPosition blockposition, BlockPosition blockposition1) { @@ -9,7 +18,7 @@ return !(entity instanceof EntityHuman); }); -@@ -388,11 +388,13 @@ +@@ -430,11 +430,13 @@ } private static Optional a(GeneratorAccess generatoraccess, NBTTagCompound nbttagcompound) { @@ -27,11 +36,11 @@ } public BlockPosition a(EnumBlockRotation enumblockrotation) { -@@ -801,7 +803,7 @@ +@@ -869,7 +871,7 @@ public IBlockData a(int i) { IBlockData iblockdata = (IBlockData) this.b.fromId(i); -- return iblockdata == null ? DefinedStructure.a.a : iblockdata; +- return iblockdata == null ? DefinedStructure.b.a : iblockdata; + return iblockdata == null ? a : iblockdata; // CraftBukkit - decompile error } diff --git a/nms-patches/DefinedStructureManager.patch b/nms-patches/DefinedStructureManager.patch index d1bdcca564..c3d85ad0d4 100644 --- a/nms-patches/DefinedStructureManager.patch +++ b/nms-patches/DefinedStructureManager.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/DefinedStructureManager.java +++ b/net/minecraft/server/DefinedStructureManager.java -@@ -20,7 +20,7 @@ - public class DefinedStructureManager implements IResourcePackListener { +@@ -19,7 +19,7 @@ + public class DefinedStructureManager { private static final Logger LOGGER = LogManager.getLogger(); - private final Map b = Maps.newHashMap(); + private final Map b = Maps.newConcurrentMap(); // SPIGOT-5287 private final DataFixer c; - private final MinecraftServer d; + private IResourceManager d; private final java.nio.file.Path e; diff --git a/nms-patches/DimensionManager.patch b/nms-patches/DimensionManager.patch deleted file mode 100644 index 93d35d1ab9..0000000000 --- a/nms-patches/DimensionManager.patch +++ /dev/null @@ -1,47 +0,0 @@ ---- a/net/minecraft/server/DimensionManager.java -+++ b/net/minecraft/server/DimensionManager.java -@@ -8,9 +8,11 @@ - - public class DimensionManager implements MinecraftSerializable { - -- public static final DimensionManager OVERWORLD = register("overworld", new DimensionManager(1, "", "", WorldProviderNormal::new, true, GenLayerZoomVoronoiFixed.INSTANCE)); -- public static final DimensionManager NETHER = register("the_nether", new DimensionManager(0, "_nether", "DIM-1", WorldProviderHell::new, false, GenLayerZoomVoronoi.INSTANCE)); -- public static final DimensionManager THE_END = register("the_end", new DimensionManager(2, "_end", "DIM1", WorldProviderTheEnd::new, false, GenLayerZoomVoronoi.INSTANCE)); -+ // CraftBukkit start -+ public static final DimensionManager OVERWORLD = register("overworld", new DimensionManager(1, "", "", WorldProviderNormal::new, true, GenLayerZoomVoronoiFixed.INSTANCE, null)); -+ public static final DimensionManager NETHER = register("the_nether", new DimensionManager(0, "_nether", "DIM-1", WorldProviderHell::new, false, GenLayerZoomVoronoiFixed.INSTANCE, null)); -+ public static final DimensionManager THE_END = register("the_end", new DimensionManager(2, "_end", "DIM1", WorldProviderTheEnd::new, false, GenLayerZoomVoronoiFixed.INSTANCE, null)); -+ // CraftBukkit end - private final int id; - private final String suffix; - public final String folder; -@@ -22,13 +24,15 @@ - return (DimensionManager) IRegistry.a(IRegistry.DIMENSION_TYPE, dimensionmanager.id, s, dimensionmanager); - } - -- public DimensionManager(int i, String s, String s1, BiFunction bifunction, boolean flag, GenLayerZoomer genlayerzoomer) { -+ // CraftBukkit - add type -+ public DimensionManager(int i, String s, String s1, BiFunction bifunction, boolean flag, GenLayerZoomer genlayerzoomer, DimensionManager type) { - this.id = i; - this.suffix = s; - this.folder = s1; - this.providerFactory = bifunction; - this.hasSkyLight = flag; - this.genLayerZoomer = genlayerzoomer; -+ this.type = type; // CraftBukkit - } - - public static DimensionManager a(Dynamic dynamic) { -@@ -86,4 +90,12 @@ - public T a(DynamicOps dynamicops) { - return dynamicops.createString(IRegistry.DIMENSION_TYPE.getKey(this).toString()); - } -+ -+ // CraftBukkit start -+ private final DimensionManager type; -+ -+ public DimensionManager getType() { -+ return (type == null) ? this : type; -+ } -+ // CraftBukkit end - } diff --git a/nms-patches/DispenseBehaviorBoat.patch b/nms-patches/DispenseBehaviorBoat.patch index 35eee4d832..fe370d8df4 100644 --- a/nms-patches/DispenseBehaviorBoat.patch +++ b/nms-patches/DispenseBehaviorBoat.patch @@ -47,7 +47,7 @@ + // CraftBukkit end entityboat.setType(this.c); - entityboat.yaw = enumdirection.n(); + entityboat.yaw = enumdirection.o(); - world.addEntity(entityboat); - itemstack.subtract(1); + if (!world.addEntity(entityboat)) itemstack.add(1); // CraftBukkit diff --git a/nms-patches/DispenseBehaviorProjectile.patch b/nms-patches/DispenseBehaviorProjectile.patch index d8b541210c..3d58d9fa24 100644 --- a/nms-patches/DispenseBehaviorProjectile.patch +++ b/nms-patches/DispenseBehaviorProjectile.patch @@ -46,7 +46,7 @@ + iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.a()); + ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); + // CraftBukkit end - world.addEntity((Entity) iprojectile); + world.addEntity(iprojectile); - itemstack.subtract(1); + // itemstack.subtract(1); // CraftBukkit - Handled during event processing return itemstack; diff --git a/nms-patches/DispenseBehaviorShears.patch b/nms-patches/DispenseBehaviorShears.patch new file mode 100644 index 0000000000..cad396786c --- /dev/null +++ b/nms-patches/DispenseBehaviorShears.patch @@ -0,0 +1,71 @@ +--- a/net/minecraft/server/DispenseBehaviorShears.java ++++ b/net/minecraft/server/DispenseBehaviorShears.java +@@ -2,6 +2,11 @@ + + import java.util.Iterator; + import java.util.List; ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.block.BlockDispenseEvent; ++// CraftBukkit end + + public class DispenseBehaviorShears extends DispenseBehaviorMaybe { + +@@ -10,11 +15,34 @@ + @Override + protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { + World world = isourceblock.getWorld(); ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ // CraftBukkit end + + if (!world.s_()) { + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); + +- this.a(a((WorldServer) world, blockposition) || b((WorldServer) world, blockposition)); ++ this.a(a((WorldServer) world, blockposition) || b((WorldServer) world, blockposition, bukkitBlock, craftItem)); // CraftBukkit + if (this.a() && itemstack.isDamaged(1, world.getRandom(), (EntityPlayer) null)) { + itemstack.setCount(0); + } +@@ -40,7 +68,7 @@ + return false; + } + +- private static boolean b(WorldServer worldserver, BlockPosition blockposition) { ++ private static boolean b(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args + List list = worldserver.a(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.g); + Iterator iterator = list.iterator(); + +@@ -51,6 +79,11 @@ + IShearable ishearable = (IShearable) entityliving; + + if (ishearable.canShear()) { ++ // CraftBukkit start ++ if (CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem).isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + ishearable.shear(SoundCategory.BLOCKS); + return true; + } diff --git a/nms-patches/DispenseBehaviorShulkerBox.patch b/nms-patches/DispenseBehaviorShulkerBox.patch index 7f76d69cbe..ea7d1be967 100644 --- a/nms-patches/DispenseBehaviorShulkerBox.patch +++ b/nms-patches/DispenseBehaviorShulkerBox.patch @@ -39,6 +39,6 @@ + } + // CraftBukkit end + - this.dispensed = ((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))) == EnumInteractionResult.SUCCESS; + this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a()); } diff --git a/nms-patches/Enchantments.patch b/nms-patches/Enchantments.patch index 98d97bc9f0..db3493ea08 100644 --- a/nms-patches/Enchantments.patch +++ b/nms-patches/Enchantments.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Enchantments.java +++ b/net/minecraft/server/Enchantments.java -@@ -41,7 +41,15 @@ +@@ -42,7 +42,15 @@ public static final Enchantment MENDING = a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); public static final Enchantment VANISHING_CURSE = a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); diff --git a/nms-patches/EnderDragonBattle.patch b/nms-patches/EnderDragonBattle.patch deleted file mode 100644 index 0290ce9830..0000000000 --- a/nms-patches/EnderDragonBattle.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- a/net/minecraft/server/EnderDragonBattle.java -+++ b/net/minecraft/server/EnderDragonBattle.java -@@ -21,7 +21,7 @@ - private static final Logger LOGGER = LogManager.getLogger(); - private static final Predicate b = IEntitySelector.a.and(IEntitySelector.a(0.0D, 128.0D, 0.0D, 192.0D)); - public final BossBattleServer bossBattle; -- private final WorldServer d; -+ public final WorldServer d; // CraftBukkit PAIL private -> public, rename world - private final List e; - private final ShapeDetector f; - private int g; -@@ -30,10 +30,10 @@ - private int j; - private boolean k; - private boolean l; -- private UUID m; -+ public UUID m; // CraftBukkit PAIL private -> public, rename dragonUUID - private boolean n; -- private BlockPosition o; -- private EnumDragonRespawn p; -+ public BlockPosition o; // CraftBukkit PAIL private -> public, rename portalLocation -+ public EnumDragonRespawn p; // CraftBukkit PAIL private -> public, rename respawnPhase - private int q; - private List r; - -@@ -194,7 +194,7 @@ - - } - -- protected void a(EnumDragonRespawn enumdragonrespawn) { -+ public void a(EnumDragonRespawn enumdragonrespawn) { // CraftBukkit PAIL protected -> public, rename setRespawnPhase - if (this.p == null) { - throw new IllegalStateException("Dragon respawn isn't in progress, can't skip ahead in the animation."); - } else { -@@ -376,7 +376,7 @@ - - private void a(BlockPosition blockposition) { - this.d.triggerEffect(3000, blockposition, 0); -- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a()).a(this.d, this.d.getChunkProvider().getChunkGenerator(), new Random(), blockposition); -+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a()).a(this.d, this.d.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error - } - - private void a(boolean flag) { -@@ -388,7 +388,7 @@ - } - } - -- worldgenendtrophy.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.e).a(this.d, this.d.getChunkProvider().getChunkGenerator(), new Random(), this.o); -+ worldgenendtrophy.b(WorldGenFeatureConfiguration.e).a(this.d, this.d.getChunkProvider().getChunkGenerator(), new Random(), this.o); // CraftBukkit - decompile error - } - - private EntityEnderDragon o() { diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 8b655fd9a1..919c90558d 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Entity.java +++ b/net/minecraft/server/Entity.java -@@ -20,8 +20,57 @@ +@@ -21,8 +21,57 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,8 +58,8 @@ protected static final Logger LOGGER = LogManager.getLogger(); private static final AtomicInteger entityCount = new AtomicInteger(); private static final List c = Collections.emptyList(); -@@ -110,6 +159,20 @@ - private long aH; +@@ -111,6 +160,20 @@ + private long aG; private EntitySize size; private float headHeight; + // CraftBukkit start @@ -73,7 +73,7 @@ + } + + public boolean isChunkLoaded() { -+ return world.isChunkLoaded((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4); ++ return world.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); + } + // CraftBukkit end @@ -82,7 +82,7 @@ @@ -214,6 +277,12 @@ } - protected void setPose(EntityPose entitypose) { + public void setPose(EntityPose entitypose) { + // CraftBukkit start + if (entitypose == this.getPose()) { + return; @@ -92,7 +92,7 @@ this.datawatcher.set(Entity.POSE, entitypose); } -@@ -222,6 +291,33 @@ +@@ -230,6 +299,33 @@ } protected void setYawPitch(float f, float f1) { @@ -126,15 +126,15 @@ this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; } -@@ -232,6 +328,7 @@ +@@ -240,6 +336,7 @@ float f1 = this.size.height; this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f)); + if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit } - protected void Z() { -@@ -246,6 +343,15 @@ + protected void ac() { +@@ -254,6 +351,15 @@ this.entityBaseTick(); } @@ -150,16 +150,16 @@ public void entityBaseTick() { this.world.getMethodProfiler().enter("entityBaseTick"); if (this.isPassenger() && this.getVehicle().dead) { -@@ -259,7 +365,7 @@ - this.A = this.B; +@@ -267,7 +373,7 @@ + this.z = this.A; this.lastPitch = this.pitch; this.lastYaw = this.yaw; - this.doPortalTick(); + if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick - this.aE(); - this.m(); - if (this.world.isClientSide) { -@@ -309,12 +415,44 @@ + if (this.aK()) { + this.aL(); + } +@@ -322,12 +428,44 @@ protected void burnFromLava() { if (!this.isFireProof()) { @@ -205,14 +205,14 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -404,6 +542,28 @@ +@@ -424,6 +562,28 @@ block.a((IBlockAccess) this.world, this); } + // CraftBukkit start + if (positionChanged && getBukkitEntity() instanceof Vehicle) { + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); -+ org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); ++ org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX()), MathHelper.floor(this.locY()), MathHelper.floor(this.locZ())); + + if (vec3d.x > vec3d1.x) { + bl = bl.getRelative(BlockFace.EAST); @@ -231,26 +231,10 @@ + } + // CraftBukkit end + - if (this.onGround && !this.bk()) { + if (this.onGround && !this.br()) { block.stepOn(this.world, blockposition, this); } -@@ -458,7 +618,14 @@ - if (!flag) { - ++this.fireTicks; - if (this.fireTicks == 0) { -- this.setOnFire(8); -+ // CraftBukkit start -+ EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(null, getBukkitEntity(), 8); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ this.setOnFire(event.getDuration(), false); -+ } -+ // CraftBukkit end - } - } - -@@ -683,6 +850,7 @@ +@@ -698,6 +858,7 @@ AxisAlignedBB axisalignedbb = this.getBoundingBox(); this.setPositionRaw((axisalignedbb.minX + axisalignedbb.maxX) / 2.0D, axisalignedbb.minY, (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D); @@ -258,16 +242,7 @@ } protected SoundEffect getSoundSwim() { -@@ -854,7 +1022,7 @@ - return null; - } - -- protected void burn(int i) { -+ protected void burn(float i) { // CraftBukkit - int -> float - if (!this.isFireProof()) { - this.damageEntity(DamageSource.FIRE, (float) i); - } -@@ -1088,6 +1256,13 @@ +@@ -1036,6 +1197,13 @@ } public void spawnIn(World world) { @@ -281,16 +256,16 @@ this.world = world; } -@@ -1103,6 +1278,7 @@ +@@ -1051,6 +1219,7 @@ this.pitch = MathHelper.a(f1, -90.0F, 90.0F) % 360.0F; this.lastYaw = this.yaw; this.lastPitch = this.pitch; -+ world.getChunkAt((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4); // CraftBukkit ++ world.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit } - public void setPositionRotation(BlockPosition blockposition, float f, float f1) { -@@ -1279,7 +1455,7 @@ - public boolean c(NBTTagCompound nbttagcompound) { + public void c(Vec3D vec3d) { +@@ -1235,7 +1404,7 @@ + public boolean a_(NBTTagCompound nbttagcompound) { String s = this.getSaveID(); - if (!this.dead && s != null) { @@ -298,7 +273,7 @@ nbttagcompound.setString("id", s); this.save(nbttagcompound); return true; -@@ -1298,15 +1474,33 @@ +@@ -1259,6 +1428,18 @@ Vec3D vec3d = this.getMot(); nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z)); @@ -317,23 +292,20 @@ nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch)); nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setShort("Fire", (short) this.fireTicks); - nbttagcompound.setShort("Air", (short) this.getAirTicks()); - nbttagcompound.setBoolean("OnGround", this.onGround); -- nbttagcompound.setInt("Dimension", this.dimension.getDimensionID()); -+ nbttagcompound.setInt("Dimension", this.dimension.getType().getDimensionID()); // CraftBukkit - preserve Vanilla compat +@@ -1267,6 +1448,12 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.a("UUID", this.getUniqueID()); + // CraftBukkit start + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast -+ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.world).getDataManager().getUUID().getLeastSignificantBits()); -+ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.world).getDataManager().getUUID().getMostSignificantBits()); ++ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.world).getWorld().getUID().getLeastSignificantBits()); ++ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.world).getWorld().getUID().getMostSignificantBits()); + nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); + // CraftBukkit end IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1364,6 +1558,11 @@ +@@ -1324,6 +1511,11 @@ } } @@ -345,16 +317,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); -@@ -1396,7 +1595,7 @@ - this.setAirTicks(nbttagcompound.getShort("Air")); - this.onGround = nbttagcompound.getBoolean("OnGround"); - if (nbttagcompound.hasKey("Dimension")) { -- this.dimension = DimensionManager.a(nbttagcompound.getInt("Dimension")); -+ // this.dimension = DimensionManager.a(nbttagcompound.getInt("Dimension")); // CraftBukkit - redundant - } - - this.invulnerable = nbttagcompound.getBoolean("Invulnerable"); -@@ -1439,6 +1638,43 @@ +@@ -1401,6 +1593,43 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -387,7 +350,7 @@ + } + + if (bworld == null) { -+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(DimensionManager.OVERWORLD).getWorld(); ++ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld(); + } + + spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle()); @@ -398,7 +361,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1514,9 +1750,22 @@ +@@ -1476,9 +1705,22 @@ } else if (this.world.isClientSide) { return null; } else { @@ -421,16 +384,16 @@ this.world.addEntity(entityitem); return entityitem; } -@@ -1624,7 +1873,7 @@ - } +@@ -1559,7 +1801,7 @@ + this.setPose(EntityPose.STANDING); this.vehicle = entity; - this.vehicle.addPassenger(this); + if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit return true; } } -@@ -1649,15 +1898,36 @@ +@@ -1584,7 +1826,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -439,6 +402,9 @@ } } +@@ -1593,10 +1835,31 @@ + this.bb(); + } - protected void addPassenger(Entity entity) { + protected boolean addPassenger(Entity entity) { // CraftBukkit @@ -469,7 +435,7 @@ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1665,15 +1935,33 @@ +@@ -1604,15 +1867,33 @@ } } @@ -504,27 +470,22 @@ } protected boolean q(Entity entity) { -@@ -1717,11 +2005,17 @@ - int i = this.ab(); - - if (this.af) { -- if (this.world.getMinecraftServer().getAllowNether() && !this.isPassenger() && this.ag++ >= i) { -+ if ((true || this.world.getMinecraftServer().getAllowNether()) && !this.isPassenger() && this.ag++ >= i) { // CraftBukkit +@@ -1665,7 +1946,13 @@ this.world.getMethodProfiler().enter("portal"); - this.ag = i; - this.portalCooldown = this.ba(); -- this.a(this.world.worldProvider.getDimensionManager() == DimensionManager.NETHER ? DimensionManager.OVERWORLD : DimensionManager.NETHER); + this.portalTicks = i; + this.portalCooldown = this.getDefaultPortalCooldown(); +- this.a(worldserver1); + // CraftBukkit start + if (this instanceof EntityPlayer) { -+ ((EntityPlayer) this).a(this.world.worldProvider.getDimensionManager().getType() == DimensionManager.NETHER ? DimensionManager.OVERWORLD : DimensionManager.NETHER, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); ++ ((EntityPlayer) this).a(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); + } else { -+ this.a(this.world.worldProvider.getDimensionManager().getType() == DimensionManager.NETHER ? DimensionManager.OVERWORLD : DimensionManager.NETHER); ++ this.a(worldserver1); + } + // CraftBukkit end this.world.getMethodProfiler().exit(); } -@@ -1821,6 +2115,13 @@ +@@ -1765,6 +2052,13 @@ } public void setSwimming(boolean flag) { @@ -538,7 +499,7 @@ this.setFlag(4, flag); } -@@ -1881,16 +2182,56 @@ +@@ -1825,16 +2119,56 @@ } public void setAirTicks(int i) { @@ -557,7 +518,7 @@ } public void onLightningStrike(EntityLightning entitylightning) { - ++this.fireTicks; + this.setFireTicks(this.fireTicks + 1); + // CraftBukkit start + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); + final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); @@ -597,33 +558,26 @@ + // CraftBukkit end } - public void j(boolean flag) { -@@ -2042,33 +2383,60 @@ + public void k(boolean flag) { +@@ -1986,18 +2320,45 @@ @Nullable - public Entity a(DimensionManager dimensionmanager) { + public Entity a(WorldServer worldserver) { + // CraftBukkit start -+ return teleportTo(dimensionmanager, null); ++ return teleportTo(worldserver, null); + } + + @Nullable -+ public Entity teleportTo(DimensionManager dimensionmanager, BlockPosition location) { ++ public Entity teleportTo(WorldServer worldserver, BlockPosition location) { + // CraftBukkit end - if (!this.world.isClientSide && !this.dead) { + if (this.world instanceof WorldServer && !this.dead) { this.world.getMethodProfiler().enter("changeDimension"); - MinecraftServer minecraftserver = this.getMinecraftServer(); - DimensionManager dimensionmanager1 = this.dimension; - WorldServer worldserver = minecraftserver.getWorldServer(dimensionmanager1); - WorldServer worldserver1 = minecraftserver.getWorldServer(dimensionmanager); +- this.decouple(); + // CraftBukkit start -+ if (worldserver1 == null){ ++ // this.decouple(); ++ if (worldserver == null){ + return null; + } - -- this.dimension = dimensionmanager; -- this.decouple(); -+ // this.dimension = dimensionmanager; -+ // this.decouple(); + // CraftBukkit end this.world.getMethodProfiler().enter("reposition"); Vec3D vec3d = this.getMot(); @@ -631,91 +585,79 @@ - BlockPosition blockposition; + BlockPosition blockposition = location; // CraftBukkit -- if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) { -- blockposition = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()); -- } else if (dimensionmanager == DimensionManager.THE_END) { -- blockposition = worldserver1.getDimensionSpawn(); + if (blockposition == null) { // CraftBukkit -+ if (dimensionmanager1.getType() == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) { // CraftBukkit + if (this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) { +- blockposition = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()); + // CraftBukkit start -+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver1, worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()), 0); ++ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()), 0); + if (event == null) { + return null; + } -+ worldserver1 = ((CraftWorld) event.getTo().getWorld()).getHandle(); ++ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + // CraftBukkit end -+ } else if (dimensionmanager.getType() == DimensionManager.THE_END) { // CraftBukkit + } else if (worldserver.getDimensionKey() == World.THE_END) { +- blockposition = WorldServer.a; + // CraftBukkit start -+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver1, worldserver1.getDimensionSpawn() != null ? worldserver1.getDimensionSpawn() : worldserver1.getSpawn(), 0); ++ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, WorldServer.a, 0); + if (event == null) { + return null; + } -+ worldserver1 = ((CraftWorld) event.getTo().getWorld()).getHandle(); ++ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + // CraftBukkit end } else { double d0 = this.locX(); double d1 = this.locZ(); - double d2 = 8.0D; - -- if (dimensionmanager1 == DimensionManager.OVERWORLD && dimensionmanager == DimensionManager.NETHER) { -+ if (dimensionmanager1.getType() == DimensionManager.OVERWORLD && dimensionmanager.getType() == DimensionManager.NETHER) { // CraftBukkit - d0 /= 8.0D; - d1 /= 8.0D; -- } else if (dimensionmanager1 == DimensionManager.NETHER && dimensionmanager == DimensionManager.OVERWORLD) { -+ } else if (dimensionmanager1.getType() == DimensionManager.NETHER && dimensionmanager.getType() == DimensionManager.OVERWORLD) { // CraftBukkit - d0 *= 8.0D; - d1 *= 8.0D; - } -@@ -2083,7 +2451,16 @@ +@@ -2023,7 +2384,16 @@ Vec3D vec3d1 = this.getPortalOffset(); blockposition = new BlockPosition(d0, this.locY(), d1); -- ShapeDetector.Shape shapedetector_shape = worldserver1.getTravelAgent().a(blockposition, vec3d, this.getPortalDirection(), vec3d1.x, vec3d1.y, this instanceof EntityHuman); +- ShapeDetector.Shape shapedetector_shape = worldserver.getTravelAgent().a(blockposition, vec3d, this.getPortalDirection(), vec3d1.x, vec3d1.y, this instanceof EntityHuman); + // CraftBukkit start -+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver1, blockposition, 128); ++ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, blockposition, 128); + if (event == null) { + return null; + } -+ worldserver1 = ((CraftWorld) event.getTo().getWorld()).getHandle(); ++ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + int searchRadius = event.getSearchRadius(); + // CraftBukkit end -+ ShapeDetector.Shape shapedetector_shape = worldserver1.getTravelAgent().findPortal(blockposition, vec3d, this.getPortalDirection(), vec3d1.x, vec3d1.y, this instanceof EntityHuman, searchRadius); // CraftBukkit - search radius ++ ShapeDetector.Shape shapedetector_shape = worldserver.getTravelAgent().findPortal(blockposition, vec3d, this.getPortalDirection(), vec3d1.x, vec3d1.y, this instanceof EntityHuman, searchRadius); // CraftBukkit - search radius if (shapedetector_shape == null) { return null; -@@ -2093,6 +2470,13 @@ +@@ -2033,6 +2403,11 @@ vec3d = shapedetector_shape.velocity; f = (float) shapedetector_shape.yaw; } + } // CraftBukkit + + // CraftBukkit start -+ -+ this.dimension = dimensionmanager; + this.decouple(); + // CraftBukkit end this.world.getMethodProfiler().exitEnter("reloading"); - Entity entity = this.getEntityType().a((World) worldserver1); -@@ -2102,6 +2486,14 @@ - entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch); + Entity entity = this.getEntityType().a((World) worldserver); +@@ -2043,8 +2418,16 @@ entity.setMot(vec3d); - worldserver1.addEntityTeleport(entity); + worldserver.addEntityTeleport(entity); + if (worldserver.getDimensionKey() == World.THE_END) { +- WorldServer.a(worldserver); ++ WorldServer.a(worldserver, this); // CraftBukkit ++ } + // CraftBukkit start - Forward the CraftEntity to the new entity + this.getBukkitEntity().setHandle(entity); + entity.bukkitEntity = this.getBukkitEntity(); + + if (this instanceof EntityInsentient) { + ((EntityInsentient)this).unleash(true, false); // Unleash to prevent duping of leads. -+ } + } + // CraftBukkit end } - this.dead = true; -@@ -2308,7 +2700,26 @@ + this.bJ(); +@@ -2253,7 +2636,26 @@ } public void a(AxisAlignedBB axisalignedbb) { diff --git a/nms-patches/EntityAgeable.patch b/nms-patches/EntityAgeable.patch index b72e4e042a..f914201b2d 100644 --- a/nms-patches/EntityAgeable.patch +++ b/nms-patches/EntityAgeable.patch @@ -8,32 +8,23 @@ protected EntityAgeable(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -46,7 +47,7 @@ - if (entityageable != null) { - entityageable.setAgeRaw(-24000); - entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F); -- this.world.addEntity(entityageable); -+ this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - if (itemstack.hasName()) { - entityageable.setCustomName(itemstack.getName()); - } -@@ -119,6 +120,7 @@ - super.b(nbttagcompound); +@@ -91,6 +92,7 @@ + super.saveData(nbttagcompound); nbttagcompound.setInt("Age", this.getAge()); nbttagcompound.setInt("ForcedAge", this.c); + nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit } @Override -@@ -126,6 +128,7 @@ - super.a(nbttagcompound); +@@ -98,6 +100,7 @@ + super.loadData(nbttagcompound); this.setAgeRaw(nbttagcompound.getInt("Age")); this.c = nbttagcompound.getInt("ForcedAge"); + this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit } @Override -@@ -140,7 +143,7 @@ +@@ -112,7 +115,7 @@ @Override public void movementTick() { super.movementTick(); @@ -41,4 +32,4 @@ + if (this.world.isClientSide || ageLocked) { // CraftBukkit if (this.d > 0) { if (this.d % 4 == 0) { - this.world.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.cv() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D); + this.world.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.cE() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D); diff --git a/nms-patches/EntityAnimal.patch b/nms-patches/EntityAnimal.patch index 723735f8d5..fbf81b386f 100644 --- a/nms-patches/EntityAnimal.patch +++ b/nms-patches/EntityAnimal.patch @@ -8,7 +8,7 @@ protected EntityAnimal(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -42,6 +43,9 @@ +@@ -44,6 +45,9 @@ } @@ -18,7 +18,7 @@ @Override public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable(damagesource)) { -@@ -51,6 +55,7 @@ +@@ -53,6 +57,7 @@ return super.damageEntity(damagesource, f); } } @@ -26,7 +26,7 @@ @Override public float a(BlockPosition blockposition, IWorldReader iworldreader) { -@@ -140,6 +145,7 @@ +@@ -147,6 +152,7 @@ if (entityhuman != null) { this.breedCause = entityhuman.getUniqueID(); } @@ -34,3 +34,45 @@ this.world.broadcastEntityEffect(this, (byte) 18); } +@@ -186,11 +192,24 @@ + EntityAgeable entityageable = this.createChild(entityanimal); + + if (entityageable != null) { ++ // CraftBukkit start - set persistence for tame animals ++ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) { ++ entityageable.persistent = true; ++ } ++ // CraftBukkit end + EntityPlayer entityplayer = this.getBreedCause(); + + if (entityplayer == null && entityanimal.getBreedCause() != null) { + entityplayer = entityanimal.getBreedCause(); + } ++ // CraftBukkit start - call EntityBreedEvent ++ int experience = this.getRandom().nextInt(7) + 1; ++ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, entityplayer, this.breedItem, experience); ++ if (entityBreedEvent.isCancelled()) { ++ return; ++ } ++ experience = entityBreedEvent.getExperience(); ++ // CraftBukkit end + + if (entityplayer != null) { + entityplayer.a(StatisticList.ANIMALS_BRED); +@@ -203,10 +222,14 @@ + entityanimal.resetLove(); + entityageable.a(true); + entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F); +- world.addEntity(entityageable); ++ world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + world.broadcastEntityEffect(this, (byte) 18); + if (world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { +- world.addEntity(new EntityExperienceOrb(world, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1)); ++ // CraftBukkit start - use event experience ++ if (experience > 0) { ++ world.addEntity(new EntityExperienceOrb(world, this.locX(), this.locY(), this.locZ(), experience)); ++ } ++ // CraftBukkit end + } + + } diff --git a/nms-patches/EntityArmorStand.patch b/nms-patches/EntityArmorStand.patch index 9c57d1c5c9..c30970cb08 100644 --- a/nms-patches/EntityArmorStand.patch +++ b/nms-patches/EntityArmorStand.patch @@ -15,7 +15,7 @@ + public class EntityArmorStand extends EntityLiving { - private static final Vector3f br = new Vector3f(0.0F, 0.0F, 0.0F); + private static final Vector3f bq = new Vector3f(0.0F, 0.0F, 0.0F); @@ -53,6 +62,13 @@ this.setPosition(d0, d1, d2); } @@ -109,7 +109,7 @@ } private void f(DamageSource damagesource) { -- Block.a(this.world, new BlockPosition(this), new ItemStack(Items.ARMOR_STAND)); +- Block.a(this.world, this.getChunkCoordinates(), new ItemStack(Items.ARMOR_STAND)); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops this.g(damagesource); } @@ -125,18 +125,18 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { -- Block.a(this.world, (new BlockPosition(this)).up(), itemstack); +- Block.a(this.world, this.getChunkCoordinates().up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.handItems.set(i, ItemStack.a); + this.handItems.set(i, ItemStack.b); } } @@ -507,10 +548,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { -- Block.a(this.world, (new BlockPosition(this)).up(), itemstack); +- Block.a(this.world, this.getChunkCoordinates().up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.armorItems.set(i, ItemStack.a); + this.armorItems.set(i, ItemStack.b); } } + this.d(damagesource); // CraftBukkit - moved from above diff --git a/nms-patches/EntityArrow.patch b/nms-patches/EntityArrow.patch index 07878deac1..5e6950c4f0 100644 --- a/nms-patches/EntityArrow.patch +++ b/nms-patches/EntityArrow.patch @@ -1,28 +1,19 @@ --- a/net/minecraft/server/EntityArrow.java +++ b/net/minecraft/server/EntityArrow.java -@@ -9,6 +9,12 @@ - import java.util.UUID; +@@ -8,6 +8,11 @@ + import java.util.List; import javax.annotation.Nullable; +// CraftBukkit start -+import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.player.PlayerPickupArrowEvent; +// CraftBukkit end + - public abstract class EntityArrow extends Entity implements IProjectile { + public abstract class EntityArrow extends IProjectile { - private static final DataWatcherObject ao = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a); -@@ -255,6 +261,7 @@ - } - - protected void a(MovingObjectPosition movingobjectposition) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event - MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); - - if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) { -@@ -336,7 +343,13 @@ - int j = entity.ad(); + private static final DataWatcherObject f = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a); +@@ -291,7 +296,13 @@ + int k = entity.getFireTicks(); if (this.isBurning() && !flag) { - entity.setOnFire(5); @@ -36,18 +27,10 @@ } if (entity.damageEntity(damagesource, (float) i)) { -@@ -477,6 +490,7 @@ - - public void setShooter(@Nullable Entity entity) { - this.shooter = entity == null ? null : entity.getUniqueID(); -+ this.projectileSource = entity == null ? null : (LivingEntity) entity.getBukkitEntity(); // CraftBukkit - if (entity instanceof EntityHuman) { - this.fromPlayer = ((EntityHuman) entity).abilities.canInstantlyBuild ? EntityArrow.PickupStatus.CREATIVE_ONLY : EntityArrow.PickupStatus.ALLOWED; - } -@@ -491,9 +505,23 @@ +@@ -458,9 +469,23 @@ @Override public void pickup(EntityHuman entityhuman) { - if (!this.world.isClientSide && (this.inGround || this.v()) && this.shake <= 0) { + if (!this.world.isClientSide && (this.inGround || this.t()) && this.shake <= 0) { + // CraftBukkit start + ItemStack itemstack = this.getItemStack(); + if (this.fromPlayer == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.inventory.canHold(itemstack) > 0) { @@ -61,7 +44,7 @@ + } + itemstack = item.getItemStack(); + } - boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.v() && this.getShooter().getUniqueID() == entityhuman.getUniqueID(); + boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.t() && this.getShooter().getUniqueID() == entityhuman.getUniqueID(); - if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) { + if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(itemstack)) { diff --git a/nms-patches/EntityBat.patch b/nms-patches/EntityBat.patch index f5fa6c2dba..dcd4e24e7c 100644 --- a/nms-patches/EntityBat.patch +++ b/nms-patches/EntityBat.patch @@ -8,14 +8,16 @@ public class EntityBat extends EntityAmbient { -@@ -105,12 +106,20 @@ +@@ -105,16 +106,24 @@ } if (this.world.a(EntityBat.c, (EntityLiving) this) != null) { + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { + this.setAsleep(false); -+ this.world.a((EntityHuman) null, 1025, blockposition, 0); ++ if (!flag) { ++ this.world.a((EntityHuman) null, 1025, blockposition, 0); ++ } + } + // CraftBukkit End + } @@ -23,17 +25,21 @@ + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { this.setAsleep(false); - this.world.a((EntityHuman) null, 1025, blockposition, 0); + if (!flag) { + this.world.a((EntityHuman) null, 1025, blockposition, 0); + } } - } else { - this.setAsleep(false); -- this.world.a((EntityHuman) null, 1025, blockposition, 0); +- if (!flag) { +- this.world.a((EntityHuman) null, 1025, blockposition, 0); +- } + // CraftBukkit End - Call BatToggleSleepEvent } } else { if (this.d != null && (!this.world.isEmpty(this.d) || this.d.getY() < 1)) { -@@ -134,7 +143,11 @@ - this.bb = 0.5F; +@@ -138,7 +147,11 @@ + this.ba = 0.5F; this.yaw += f1; if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding(this.world, blockposition1)) { - this.setAsleep(true); @@ -45,7 +51,7 @@ } } -@@ -164,7 +177,11 @@ +@@ -168,7 +181,11 @@ return false; } else { if (!this.world.isClientSide && this.isAsleep()) { diff --git a/nms-patches/EntityBee.patch b/nms-patches/EntityBee.patch index 9ede031bb7..193aaf8d65 100644 --- a/nms-patches/EntityBee.patch +++ b/nms-patches/EntityBee.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/server/EntityBee.java +++ b/net/minecraft/server/EntityBee.java -@@ -21,7 +21,7 @@ - private float bA; - private int bB; - private int ticksSincePollination; -- private int cannotEnterHiveTicks; -+ public int cannotEnterHiveTicks; // PAIL private -> public - private int numCropsGrownSincePollination; - private int bF = 0; - private int bG = 0; -@@ -152,12 +152,12 @@ +@@ -137,7 +137,7 @@ } if (b0 > 0) { @@ -18,23 +9,16 @@ } } - this.setHasStung(true); -- this.setGoalTarget((EntityLiving) null); -+ this.setGoalTarget((EntityLiving) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - this.a(SoundEffects.ENTITY_BEE_STING, 1.0F, 1.0F); - } - -@@ -546,12 +546,16 @@ +@@ -512,11 +512,15 @@ } else { Entity entity = damagesource.getEntity(); -- if (!this.world.isClientSide && entity instanceof EntityHuman && !((EntityHuman) entity).isCreative() && this.hasLineOfSight(entity) && !this.isNoAI()) { +- if (!this.world.isClientSide) { + // CraftBukkit start + boolean result = super.damageEntity(damagesource, f); + -+ if (result && !this.world.isClientSide && entity instanceof EntityHuman && !((EntityHuman) entity).isCreative() && this.hasLineOfSight(entity) && !this.isNoAI()) { ++ if (result && !this.world.isClientSide) { this.bJ.l(); - this.a(entity); } - return super.damageEntity(damagesource, f); @@ -43,7 +27,7 @@ } } -@@ -572,7 +576,7 @@ +@@ -537,7 +541,7 @@ class d extends EntityBee.a { private d() { @@ -52,7 +36,7 @@ } @Override -@@ -632,7 +636,7 @@ +@@ -597,7 +601,7 @@ class g extends EntityBee.a { private g() { @@ -61,7 +45,7 @@ } @Override -@@ -681,7 +685,7 @@ +@@ -646,7 +650,7 @@ } } @@ -69,8 +53,8 @@ + if (flag && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)).isCancelled()) { // Spigot EntityBee.this.world.triggerEffect(2005, blockposition, 0); EntityBee.this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)); - EntityBee.this.eO(); -@@ -696,7 +700,7 @@ + EntityBee.this.fj(); +@@ -661,7 +665,7 @@ class i extends EntityBee.a { private i() { @@ -79,7 +63,7 @@ } @Override -@@ -760,7 +764,7 @@ +@@ -725,7 +729,7 @@ private int h = 0; k() { @@ -88,7 +72,7 @@ this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -944,7 +948,7 @@ +@@ -909,7 +913,7 @@ private int c; f() { @@ -97,8 +81,8 @@ this.c = EntityBee.this.world.random.nextInt(10); this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); } -@@ -1001,7 +1005,7 @@ - private PathEntity e; +@@ -967,7 +971,7 @@ + private int f; e() { - super(null); @@ -106,10 +90,10 @@ this.c = EntityBee.this.world.random.nextInt(10); this.d = Lists.newArrayList(); this.e = null; -@@ -1210,7 +1214,7 @@ +@@ -1187,7 +1191,7 @@ @Override protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { - if (entityinsentient instanceof EntityBee && this.e.hasLineOfSight(entityliving) && ((EntityBee) entityinsentient).a((Entity) entityliving)) { + if (entityinsentient instanceof EntityBee && this.e.hasLineOfSight(entityliving)) { - entityinsentient.setGoalTarget(entityliving); + entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason } diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch index 994ecab0ba..f3a1b50fea 100644 --- a/nms-patches/EntityBoat.patch +++ b/nms-patches/EntityBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityBoat.java +++ b/net/minecraft/server/EntityBoat.java -@@ -3,6 +3,15 @@ +@@ -4,6 +4,15 @@ import java.util.List; import javax.annotation.Nullable; @@ -16,9 +16,9 @@ public class EntityBoat extends Entity { private static final DataWatcherObject b = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b); -@@ -37,6 +46,14 @@ +@@ -38,6 +47,14 @@ + private float aK; private float aL; - private float aM; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -30,44 +30,44 @@ + public EntityBoat(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.ap = new float[2]; -@@ -98,6 +115,19 @@ - if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) { - return false; - } else { -+ // CraftBukkit start -+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); -+ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); + this.ao = new float[2]; +@@ -101,6 +118,19 @@ + if (this.isInvulnerable(damagesource)) { + return false; + } else if (!this.world.isClientSide && !this.dead) { ++ // CraftBukkit start ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity(); + -+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); -+ this.world.getServer().getPluginManager().callEvent(event); ++ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f); ++ this.world.getServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ return false; -+ } -+ // f = event.getDamage(); // TODO Why don't we do this? -+ // CraftBukkit end ++ if (event.isCancelled()) { ++ return false; ++ } ++ // f = event.getDamage(); // TODO Why don't we do this? ++ // CraftBukkit end + - this.c(-this.o()); - this.b(10); - this.setDamage(this.getDamage() + f * 10.0F); -@@ -105,6 +135,15 @@ - boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; + this.c(-this.o()); + this.b(10); + this.setDamage(this.getDamage() + f * 10.0F); +@@ -108,6 +138,15 @@ + boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; - if (flag || this.getDamage() > 40.0F) { -+ // CraftBukkit start -+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); -+ this.world.getServer().getPluginManager().callEvent(destroyEvent); + if (flag || this.getDamage() > 40.0F) { ++ // CraftBukkit start ++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); ++ this.world.getServer().getPluginManager().callEvent(destroyEvent); + -+ if (destroyEvent.isCancelled()) { -+ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away -+ return true; -+ } -+ // CraftBukkit end - if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { - this.a((IMaterial) this.f()); - } -@@ -140,9 +179,29 @@ ++ if (destroyEvent.isCancelled()) { ++ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away ++ return true; ++ } ++ // CraftBukkit end + if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { + this.a((IMaterial) this.g()); + } +@@ -142,9 +181,29 @@ public void collide(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { @@ -97,15 +97,15 @@ super.collide(entity); } -@@ -176,6 +235,7 @@ - return this.getDirection().f(); +@@ -178,6 +237,7 @@ + return this.getDirection().g(); } + private Location lastLocation; // CraftBukkit @Override public void tick() { - this.aG = this.aF; -@@ -216,6 +276,22 @@ + this.aF = this.aE; +@@ -218,6 +278,22 @@ this.setMot(Vec3D.a); } @@ -128,7 +128,7 @@ this.q(); for (int i = 0; i <= 1; ++i) { -@@ -734,6 +810,11 @@ +@@ -709,6 +785,11 @@ this.b(this.fallDistance, 1.0F); if (!this.world.isClientSide && !this.dead) { @@ -140,7 +140,7 @@ this.die(); if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { int i; -@@ -747,6 +828,7 @@ +@@ -722,6 +803,7 @@ } } } diff --git a/nms-patches/EntityCat.patch b/nms-patches/EntityCat.patch index 8b2a5cf813..6039ba9399 100644 --- a/nms-patches/EntityCat.patch +++ b/nms-patches/EntityCat.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/server/EntityCat.java +++ b/net/minecraft/server/EntityCat.java -@@ -16,7 +16,7 @@ - private static final DataWatcherObject bC = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); - private static final DataWatcherObject bD = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); - private static final DataWatcherObject bE = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b); -- public static final Map bz = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ public static final Map bz = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error +@@ -15,7 +15,7 @@ + private static final DataWatcherObject bA = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); + private static final DataWatcherObject bB = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); + private static final DataWatcherObject bC = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b); +- public static final Map bx = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ public static final Map bx = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error hashmap.put(0, new MinecraftKey("textures/entity/cat/tabby.png")); hashmap.put(1, new MinecraftKey("textures/entity/cat/black.png")); hashmap.put(2, new MinecraftKey("textures/entity/cat/red.png")); -@@ -347,7 +347,7 @@ +@@ -341,7 +341,7 @@ } - } else if (this.i(itemstack)) { + } else if (this.k(itemstack)) { this.a(entityhuman, itemstack); - if (this.random.nextInt(3) == 0) { + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit this.tame(entityhuman); - this.goalSit.setSitting(true); + this.setWillSit(true); this.world.broadcastEntityEffect(this, (byte) 7); -@@ -533,7 +533,7 @@ +@@ -529,7 +529,7 @@ static class PathfinderGoalTemptChance extends PathfinderGoalTempt { @Nullable @@ -27,7 +27,7 @@ private final EntityCat d; public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) { -@@ -568,9 +568,9 @@ +@@ -564,9 +564,9 @@ private final EntityCat i; public a(EntityCat entitycat, Class oclass, float f, double d0, double d1) { diff --git a/nms-patches/EntityCaveSpider.patch b/nms-patches/EntityCaveSpider.patch index 27832f51c9..5bffc53bb4 100644 --- a/nms-patches/EntityCaveSpider.patch +++ b/nms-patches/EntityCaveSpider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityCaveSpider.java +++ b/net/minecraft/server/EntityCaveSpider.java -@@ -27,7 +27,7 @@ +@@ -25,7 +25,7 @@ } if (b0 > 0) { diff --git a/nms-patches/EntityChicken.patch b/nms-patches/EntityChicken.patch index bc73e72667..8f0dbc3900 100644 --- a/nms-patches/EntityChicken.patch +++ b/nms-patches/EntityChicken.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityChicken.java +++ b/net/minecraft/server/EntityChicken.java -@@ -43,6 +43,11 @@ +@@ -40,6 +40,11 @@ @Override public void movementTick() { @@ -10,12 +10,12 @@ + } + // CraftBukkit end super.movementTick(); - this.bz = this.bw; - this.by = this.bx; -@@ -62,7 +67,9 @@ - this.bw += this.bA * 2.0F; + this.by = this.bv; + this.bx = this.bw; +@@ -59,7 +64,9 @@ + this.bv += this.bz * 2.0F; if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 0) { - this.a(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.playSound(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.EGG); + this.forceDrops = false; // CraftBukkit diff --git a/nms-patches/EntityCow.patch b/nms-patches/EntityCow.patch index db3cf8729b..131985bc20 100644 --- a/nms-patches/EntityCow.patch +++ b/nms-patches/EntityCow.patch @@ -11,29 +11,21 @@ public class EntityCow extends EntityAnimal { public EntityCow(EntityTypes entitytypes, World world) { -@@ -55,13 +60,22 @@ +@@ -52,8 +57,16 @@ ItemStack itemstack = entityhuman.b(enumhand); - if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) { + if (itemstack.getItem() == Items.BUCKET && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman.world, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET); ++ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.world, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET); + + if (event.isCancelled()) { -+ return false; ++ return EnumInteractionResult.PASS; + } -+ -+ ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack()); - entityhuman.a(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F); - itemstack.subtract(1); - if (itemstack.isEmpty()) { -- entityhuman.a(enumhand, new ItemStack(Items.MILK_BUCKET)); -- } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) { -- entityhuman.drop(new ItemStack(Items.MILK_BUCKET), false); -+ entityhuman.a(enumhand, result); -+ } else if (!entityhuman.inventory.pickup(result)) { -+ entityhuman.drop(result, false); - } + // CraftBukkit end ++ + entityhuman.playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F); +- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, Items.MILK_BUCKET.r()); ++ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit - return true; - } else { + entityhuman.a(enumhand, itemstack1); + return EnumInteractionResult.a(this.world.isClientSide); diff --git a/nms-patches/EntityCreature.patch b/nms-patches/EntityCreature.patch index 969f6a2708..4d4f2fd450 100644 --- a/nms-patches/EntityCreature.patch +++ b/nms-patches/EntityCreature.patch @@ -20,7 +20,7 @@ @@ -42,6 +47,7 @@ - this.u(f); + this.t(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 13322d4a0c..2f1d6dacc2 100644 --- a/nms-patches/EntityCreeper.patch +++ b/nms-patches/EntityCreeper.patch @@ -12,7 +12,7 @@ public class EntityCreeper extends EntityMonster { -@@ -167,9 +172,19 @@ +@@ -165,9 +170,19 @@ @Override public void onLightningStrike(EntityLightning entitylightning) { super.onLightningStrike(entitylightning); @@ -31,9 +31,9 @@ + // CraftBukkit end + @Override - protected boolean a(EntityHuman entityhuman, EnumHand enumhand) { + protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -@@ -194,10 +209,18 @@ +@@ -192,10 +207,18 @@ Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; float f = this.isPowered() ? 2.0F : 1.0F; @@ -56,7 +56,7 @@ } } -@@ -208,6 +231,7 @@ +@@ -206,6 +229,7 @@ if (!collection.isEmpty()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX(), this.locY(), this.locZ()); @@ -64,7 +64,7 @@ entityareaeffectcloud.setRadius(2.5F); entityareaeffectcloud.setRadiusOnUse(-0.5F); entityareaeffectcloud.setWaitTime(10); -@@ -221,7 +245,7 @@ +@@ -219,7 +243,7 @@ entityareaeffectcloud.addEffect(new MobEffect(mobeffect)); } diff --git a/nms-patches/EntityDamageSourceIndirect.patch b/nms-patches/EntityDamageSourceIndirect.patch index c6ef0607ef..7fd01bf44e 100644 --- a/nms-patches/EntityDamageSourceIndirect.patch +++ b/nms-patches/EntityDamageSourceIndirect.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityDamageSourceIndirect.java @@ -32,4 +32,10 @@ - return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.B()}) : new ChatMessage(s, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent}); + return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.C()}) : new ChatMessage(s, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent}); } + + // CraftBukkit start diff --git a/nms-patches/EntityDolphin.patch b/nms-patches/EntityDolphin.patch index da1c477545..3daecc2064 100644 --- a/nms-patches/EntityDolphin.patch +++ b/nms-patches/EntityDolphin.patch @@ -8,29 +8,29 @@ + this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a(new Class[0])); // CraftBukkit - decompile error } - @Override -@@ -179,6 +179,11 @@ + public static AttributeProvider.Builder eN() { +@@ -174,6 +174,11 @@ ItemStack itemstack = entityitem.getItemStack(); - if (this.g(itemstack)) { + if (this.canPickup(itemstack)) { + // CraftBukkit start - call EntityPickupItemEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) { + return; + } + // CraftBukkit end + this.a(entityitem); this.setSlot(EnumItemSlot.MAINHAND, itemstack); this.dropChanceHand[EnumItemSlot.MAINHAND.b()] = 2.0F; - this.receive(entityitem, itemstack.getCount()); -@@ -317,7 +322,7 @@ +@@ -315,7 +320,7 @@ @Override public boolean a() { -- return this.a.eq() && this.a.getAirTicks() >= 100; -+ return this.a.eq() && this.a.getAirTicks() >= 100 && this.a.world.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false +- return this.a.gotFish() && this.a.getAirTicks() >= 100; ++ return this.a.gotFish() && this.a.getAirTicks() >= 100 && this.a.world.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false } @Override -@@ -425,7 +430,7 @@ +@@ -424,7 +429,7 @@ @Override public void c() { @@ -39,7 +39,7 @@ } @Override -@@ -444,7 +449,7 @@ +@@ -443,7 +448,7 @@ } if (this.c.isSwimming() && this.c.world.random.nextInt(6) == 0) { diff --git a/nms-patches/EntityEgg.patch b/nms-patches/EntityEgg.patch index f4e07d39bc..c7cf9cf767 100644 --- a/nms-patches/EntityEgg.patch +++ b/nms-patches/EntityEgg.patch @@ -13,9 +13,9 @@ public class EntityEgg extends EntityProjectileThrowable { public EntityEgg(EntityTypes entitytypes, World world) { -@@ -21,20 +28,40 @@ - } - +@@ -24,20 +31,40 @@ + protected void a(MovingObjectPosition movingobjectposition) { + super.a(movingobjectposition); if (!this.world.isClientSide) { - if (this.random.nextInt(8) == 0) { + boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit diff --git a/nms-patches/EntityEnderCrystal.patch b/nms-patches/EntityEnderCrystal.patch index fb6204868f..099a8042fe 100644 --- a/nms-patches/EntityEnderCrystal.patch +++ b/nms-patches/EntityEnderCrystal.patch @@ -13,13 +13,13 @@ private static final DataWatcherObject> c = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m); @@ -38,7 +43,11 @@ - BlockPosition blockposition = new BlockPosition(this); + BlockPosition blockposition = this.getChunkCoordinates(); - if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).isAir()) { -- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + if (((WorldServer) this.world).getDragonBattle() != null && this.world.getType(blockposition).isAir()) { +- this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition)); + // CraftBukkit start + if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition, this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); ++ this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition)); + } + // CraftBukkit end } diff --git a/nms-patches/EntityEnderDragon.patch b/nms-patches/EntityEnderDragon.patch index 92932b6655..95ec8f9cbc 100644 --- a/nms-patches/EntityEnderDragon.patch +++ b/nms-patches/EntityEnderDragon.patch @@ -15,14 +15,14 @@ private static final Logger LOGGER = LogManager.getLogger(); @@ -38,6 +44,7 @@ - private final PathPoint[] bR = new PathPoint[24]; - private final int[] bS = new int[24]; - private final Path bT = new Path(); -+ private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() + private final PathPoint[] bQ = new PathPoint[24]; + private final int[] bR = new int[24]; + private final Path bS = new Path(); ++ private Explosion explosionSource = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() public EntityEnderDragon(EntityTypes entitytypes, World world) { super(EntityTypes.ENDER_DRAGON, world); -@@ -177,7 +184,7 @@ +@@ -175,7 +182,7 @@ Vec3D vec3d1 = idragoncontroller.g(); @@ -31,7 +31,7 @@ d0 = vec3d1.x - this.locX(); d1 = vec3d1.y - this.locY(); d2 = vec3d1.z - this.locZ(); -@@ -315,7 +322,14 @@ +@@ -313,7 +320,14 @@ if (this.currentEnderCrystal.dead) { this.currentEnderCrystal = null; } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -47,7 +47,7 @@ } } -@@ -390,6 +404,9 @@ +@@ -388,6 +402,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; @@ -57,7 +57,7 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -400,7 +417,11 @@ +@@ -398,7 +415,11 @@ if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) { if (this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) && !TagsBlock.DRAGON_IMMUNE.isTagged(block)) { @@ -70,7 +70,7 @@ } else { flag = true; } -@@ -409,6 +430,51 @@ +@@ -407,6 +428,51 @@ } } @@ -105,12 +105,12 @@ + Block nmsBlock = craftBlock.getNMS().getBlock(); + if (nmsBlock.a(explosionSource)) { + TileEntity tileentity = nmsBlock.isTileEntity() ? this.world.getTileEntity(blockposition) : null; -+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.a).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); ++ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.b).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); + + craftBlock.getNMS().a(loottableinfo_builder).forEach((itemstack) -> { + Block.a(world, blockposition, itemstack); + }); -+ craftBlock.getNMS().dropNaturally(world, blockposition, ItemStack.a); ++ craftBlock.getNMS().dropNaturally(world, blockposition, ItemStack.b); + } + nmsBlock.wasExploded(world, blockposition, explosionSource); + diff --git a/nms-patches/EntityEnderPearl.patch b/nms-patches/EntityEnderPearl.patch index 4098d2b4b3..fff8bbe05c 100644 --- a/nms-patches/EntityEnderPearl.patch +++ b/nms-patches/EntityEnderPearl.patch @@ -13,8 +13,8 @@ public class EntityEnderPearl extends EntityProjectileThrowable { -@@ -65,21 +71,35 @@ - EntityPlayer entityplayer = (EntityPlayer) entityliving; +@@ -37,21 +43,35 @@ + EntityPlayer entityplayer = (EntityPlayer) entity; if (entityplayer.playerConnection.a().isConnected() && entityplayer.world == this.world && !entityplayer.isSleeping()) { - if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING)) { @@ -34,29 +34,29 @@ - entityendermite.setPlayerSpawned(true); + entityendermite.setPlayerSpawned(true); - entityendermite.setPositionRotation(entityliving.locX(), entityliving.locY(), entityliving.locZ(), entityliving.yaw, entityliving.pitch); + entityendermite.setPositionRotation(entity.locX(), entity.locY(), entity.locZ(), entity.yaw, entity.pitch); - this.world.addEntity(entityendermite); - } + this.world.addEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL); + } -- if (entityliving.isPassenger()) { -- entityliving.stopRiding(); -+ if (entityliving.isPassenger()) { -+ entityliving.stopRiding(); +- if (entity.isPassenger()) { +- entity.stopRiding(); ++ if (entity.isPassenger()) { ++ entity.stopRiding(); + } + + entityplayer.playerConnection.teleport(teleEvent.getTo()); -+ entityliving.fallDistance = 0.0F; ++ entity.fallDistance = 0.0F; + CraftEventFactory.entityDamage = this; -+ entityliving.damageEntity(DamageSource.FALL, 5.0F); ++ entity.damageEntity(DamageSource.FALL, 5.0F); + CraftEventFactory.entityDamage = null; } - -- entityliving.enderTeleportTo(this.locX(), this.locY(), this.locZ()); -- entityliving.fallDistance = 0.0F; -- entityliving.damageEntity(DamageSource.FALL, 5.0F); +- entity.enderTeleportTo(this.locX(), this.locY(), this.locZ()); +- entity.fallDistance = 0.0F; +- entity.damageEntity(DamageSource.FALL, 5.0F); + // CraftBukkit end } - } else if (entityliving != null) { - entityliving.enderTeleportTo(this.locX(), this.locY(), this.locZ()); + } else if (entity != null) { + entity.enderTeleportTo(this.locX(), this.locY(), this.locZ()); diff --git a/nms-patches/EntityEnderman.patch b/nms-patches/EntityEnderman.patch index 7530c3ea19..d47af191e7 100644 --- a/nms-patches/EntityEnderman.patch +++ b/nms-patches/EntityEnderman.patch @@ -16,21 +16,21 @@ + } + entityliving = getGoalTarget(); + // CraftBukkit end - AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); + AttributeModifiable attributemodifiable = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { @@ -67,6 +77,7 @@ - attributeinstance.addModifier(EntityEnderman.c); + attributemodifiable.b(EntityEnderman.c); } } + return true; } -@@ -323,8 +334,12 @@ +@@ -360,8 +371,12 @@ boolean flag = movingobjectpositionblock.getBlockPosition().equals(blockposition); - if (block.a(TagsBlock.ENDERMAN_HOLDABLE) && flag) { + if (block.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) { - this.enderman.setCarried(iblockdata); - world.a(blockposition, false); + // CraftBukkit start - Pickup event @@ -42,7 +42,7 @@ } } -@@ -357,8 +372,12 @@ +@@ -394,8 +409,12 @@ IBlockData iblockdata2 = this.a.getCarried(); if (iblockdata2 != null && this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { diff --git a/nms-patches/EntityExperienceOrb.patch b/nms-patches/EntityExperienceOrb.patch index 316e744b1f..da8f63ef56 100644 --- a/nms-patches/EntityExperienceOrb.patch +++ b/nms-patches/EntityExperienceOrb.patch @@ -44,16 +44,7 @@ Vec3D vec3d = new Vec3D(this.targetPlayer.locX() - this.locX(), this.targetPlayer.locY() + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY(), this.targetPlayer.locZ() - this.locZ()); double d1 = vec3d.g(); -@@ -113,7 +134,7 @@ - protected void aD() {} - - @Override -- protected void burn(int i) { -+ protected void burn(float i) { // CraftBukkit - int -> float - this.damageEntity(DamageSource.FIRE, (float) i); - } - -@@ -160,13 +181,19 @@ +@@ -155,13 +176,19 @@ if (!itemstack.isEmpty() && itemstack.f()) { int i = Math.min(this.c(this.value), itemstack.getDamage()); @@ -76,7 +67,7 @@ } this.die(); -@@ -188,6 +215,24 @@ +@@ -183,6 +210,24 @@ } public static int getOrbValue(int i) { diff --git a/nms-patches/EntityFallingBlock.patch b/nms-patches/EntityFallingBlock.patch index 568aeb0d67..3de850e79d 100644 --- a/nms-patches/EntityFallingBlock.patch +++ b/nms-patches/EntityFallingBlock.patch @@ -12,9 +12,9 @@ @@ -70,7 +72,7 @@ if (this.ticksLived++ == 0) { - blockposition = new BlockPosition(this); -- if (this.world.getType(blockposition).getBlock() == block) { -+ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + blockposition = this.getChunkCoordinates(); +- if (this.world.getType(blockposition).a(block)) { ++ if (this.world.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { this.world.a(blockposition, false); } else if (!this.world.isClientSide) { this.die(); @@ -29,7 +29,7 @@ + // CraftBukkit end if (this.world.setTypeAndData(blockposition, this.block, 3)) { if (block instanceof BlockFalling) { - ((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata); + ((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata, this); @@ -178,7 +185,9 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/EntityFireball.patch b/nms-patches/EntityFireball.patch index dfbef19757..10955553f6 100644 --- a/nms-patches/EntityFireball.patch +++ b/nms-patches/EntityFireball.patch @@ -1,14 +1,12 @@ --- a/net/minecraft/server/EntityFireball.java +++ b/net/minecraft/server/EntityFireball.java -@@ -1,5 +1,7 @@ +@@ -1,10 +1,14 @@ package net.minecraft.server; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + - public abstract class EntityFireball extends Entity { + public abstract class EntityFireball extends IProjectile { - public EntityLiving shooter; -@@ -8,6 +10,8 @@ public double dirX; public double dirY; public double dirZ; @@ -17,24 +15,20 @@ protected EntityFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -27,9 +31,16 @@ - public EntityFireball(EntityTypes entitytypes, EntityLiving entityliving, double d0, double d1, double d2, World world) { +@@ -14,6 +18,12 @@ this(entitytypes, world); - this.shooter = entityliving; -+ this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit - this.setPositionRotation(entityliving.locX(), entityliving.locY(), entityliving.locZ(), entityliving.yaw, entityliving.pitch); - this.Z(); - this.setMot(Vec3D.a); + this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch); + this.ac(); + // CraftBukkit start - Added setDirection method -+ this.setDirection(d0, d1, d2); ++ this.setDirection(d3, d4, d5); + } + -+ public void setDirection(double d0, double d1, double d2) { ++ public void setDirection(double d3, double d4, double d5) { + // CraftBukkit end - d0 += this.random.nextGaussian() * 0.4D; - d1 += this.random.nextGaussian() * 0.4D; - d2 += this.random.nextGaussian() * 0.4D; -@@ -58,6 +69,12 @@ + double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); + + if (d6 != 0.0D) { +@@ -49,6 +59,12 @@ if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { this.a(movingobjectposition); @@ -47,23 +41,15 @@ } Vec3D vec3d = this.getMot(); -@@ -157,6 +174,11 @@ - } else { - this.velocityChanged(); - if (damagesource.getEntity() != null) { +@@ -132,6 +148,11 @@ + Entity entity = damagesource.getEntity(); + + if (entity != null) { + // CraftBukkit start + if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { + return false; + } + // CraftBukkit end - Vec3D vec3d = damagesource.getEntity().getLookDirection(); + Vec3D vec3d = entity.getLookDirection(); this.setMot(vec3d); -@@ -165,6 +187,7 @@ - this.dirZ = vec3d.z * 0.1D; - if (damagesource.getEntity() instanceof EntityLiving) { - this.shooter = (EntityLiving) damagesource.getEntity(); -+ this.projectileSource = (org.bukkit.projectiles.ProjectileSource) this.shooter.getBukkitEntity(); - } - - return true; diff --git a/nms-patches/EntityFireballFireball.patch b/nms-patches/EntityFireballFireball.patch index 8a253b5663..69a2fc05af 100644 --- a/nms-patches/EntityFireballFireball.patch +++ b/nms-patches/EntityFireballFireball.patch @@ -1,27 +1,19 @@ --- a/net/minecraft/server/EntityFireballFireball.java +++ b/net/minecraft/server/EntityFireballFireball.java -@@ -18,14 +18,14 @@ +@@ -18,7 +18,7 @@ - public void b(ItemStack itemstack) { + public void setItem(ItemStack itemstack) { if (itemstack.getItem() != Items.FIRE_CHARGE || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityFireballFireball.f, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { -+ this.getDataWatcher().set(EntityFireballFireball.f, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error +- this.getDataWatcher().set(EntityFireballFireball.e, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { ++ this.getDataWatcher().set(EntityFireballFireball.e, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error itemstack1.setCount(1); })); } - - } - -- protected ItemStack l() { -+ public ItemStack l() { // PAIL protected -> public - return (ItemStack) this.getDataWatcher().get(EntityFireballFireball.f); - } - @@ -50,6 +50,6 @@ - super.a(nbttagcompound); + super.loadData(nbttagcompound); ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("Item")); -- this.b(itemstack); -+ if (!itemstack.isEmpty()) this.b(itemstack); // CraftBukkit - SPIGOT-5474 probably came from bugged earlier versions +- this.setItem(itemstack); ++ if (!itemstack.isEmpty()) this.setItem(itemstack); // CraftBukkit - SPIGOT-5474 probably came from bugged earlier versions } } diff --git a/nms-patches/EntityFireworks.patch b/nms-patches/EntityFireworks.patch index 534e63aa0d..b45e1d1158 100644 --- a/nms-patches/EntityFireworks.patch +++ b/nms-patches/EntityFireworks.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/EntityFireworks.java +++ b/net/minecraft/server/EntityFireworks.java -@@ -3,6 +3,7 @@ - import java.util.Iterator; +@@ -4,6 +4,7 @@ import java.util.List; import java.util.OptionalInt; + import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - public class EntityFireworks extends Entity implements IProjectile { + public class EntityFireworks extends IProjectile { -@@ -130,7 +131,11 @@ +@@ -119,7 +120,11 @@ } if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) { @@ -21,48 +21,48 @@ } } -@@ -143,7 +148,11 @@ - - protected void a(MovingObjectPosition movingobjectposition) { - if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY && !this.world.isClientSide) { +@@ -134,7 +139,11 @@ + protected void a(MovingObjectPositionEntity movingobjectpositionentity) { + super.a(movingobjectpositionentity); + if (!this.world.isClientSide) { - this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { + this.explode(); + } + // CraftBukkit end - } else if (this.w) { - BlockPosition blockposition; + } + } -@@ -155,7 +164,11 @@ +@@ -144,7 +153,11 @@ - this.world.getType(blockposition).a(this.world, blockposition, (Entity) this); - if (this.hasExplosions()) { -- this.explode(); -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.explode(); -+ } -+ // CraftBukkit end - } + this.world.getType(blockposition).a(this.world, blockposition, (Entity) this); + if (!this.world.s_() && this.hasExplosions()) { +- this.explode(); ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { ++ this.explode(); ++ } ++ // CraftBukkit end } -@@ -181,7 +194,9 @@ + super.a(movingobjectpositionblock); +@@ -170,7 +183,9 @@ if (f > 0.0F) { if (this.ridingEntity != null) { + CraftEventFactory.entityDamage = this; // CraftBukkit - this.ridingEntity.damageEntity(DamageSource.FIREWORKS, 5.0F + (float) (nbttaglist.size() * 2)); + this.ridingEntity.damageEntity(DamageSource.a(this, this.getShooter()), 5.0F + (float) (nbttaglist.size() * 2)); + CraftEventFactory.entityDamage = null; // CraftBukkit } double d0 = 5.0D; -@@ -208,7 +223,9 @@ +@@ -197,7 +212,9 @@ if (flag) { float f1 = f * (float) Math.sqrt((5.0D - (double) this.g(entityliving)) / 5.0D); + CraftEventFactory.entityDamage = this; // CraftBukkit - entityliving.damageEntity(DamageSource.FIREWORKS, f1); + entityliving.damageEntity(DamageSource.a(this, this.getShooter()), f1); + CraftEventFactory.entityDamage = null; // CraftBukkit } } diff --git a/nms-patches/EntityFish.patch b/nms-patches/EntityFish.patch index b8574e46ba..bd9ca48502 100644 --- a/nms-patches/EntityFish.patch +++ b/nms-patches/EntityFish.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityFish.java +++ b/net/minecraft/server/EntityFish.java -@@ -34,7 +34,7 @@ +@@ -32,7 +32,7 @@ @Override public boolean isTypeNotPersistent(double d0) { @@ -9,7 +9,7 @@ } @Override -@@ -54,6 +54,7 @@ +@@ -52,6 +52,7 @@ public void setFromBucket(boolean flag) { this.datawatcher.set(EntityFish.FROM_BUCKET, flag); diff --git a/nms-patches/EntityFishingHook.patch b/nms-patches/EntityFishingHook.patch index a4581609ea..e6d79e8162 100644 --- a/nms-patches/EntityFishingHook.patch +++ b/nms-patches/EntityFishingHook.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityFishingHook.java +++ b/net/minecraft/server/EntityFishingHook.java -@@ -4,6 +4,11 @@ - import java.util.Iterator; +@@ -6,6 +6,11 @@ import java.util.List; + import java.util.Random; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.entity.Player; @@ -10,47 +10,39 @@ +import org.bukkit.event.player.PlayerFishEvent; +// CraftBukkit end - public class EntityFishingHook extends Entity { + public class EntityFishingHook extends IProjectile { -@@ -204,6 +209,7 @@ - }, RayTrace.BlockCollisionOption.COLLIDER, true); - - if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event - if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { - this.hooked = ((MovingObjectPositionEntity) movingobjectposition).getEntity(); - this.n(); -@@ -236,6 +242,10 @@ - if (this.ao <= 0) { +@@ -253,6 +258,10 @@ + this.ao = 0; this.ap = 0; - this.aq = 0; + this.getDataWatcher().set(EntityFishingHook.f, false); + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + // CraftBukkit end - } else { - this.setMot(this.getMot().add(0.0D, -0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat(), 0.0D)); } -@@ -271,6 +281,13 @@ + } else { + float f; +@@ -286,6 +295,13 @@ worldserver.a(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return; + } + // CraftBukkit end - Vec3D vec3d = this.getMot(); + this.playSound(SoundEffects.ENTITY_FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + double d3 = this.locY() + 0.5D; - this.setMot(vec3d.x, (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F)), vec3d.z); -@@ -327,6 +344,14 @@ +@@ -390,6 +406,14 @@ int i = 0; if (this.hooked != null) { + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hooked.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { @@ -58,14 +50,14 @@ + } + // CraftBukkit end this.reel(); - CriterionTriggers.D.a((EntityPlayer) this.owner, itemstack, this, Collections.emptyList()); + CriterionTriggers.D.a((EntityPlayer) entityhuman, itemstack, this, (Collection) Collections.emptyList()); this.world.broadcastEntityEffect(this, (byte) 31); -@@ -342,6 +367,15 @@ +@@ -405,6 +429,15 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY(), this.locZ(), itemstack1); + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); + playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + @@ -73,28 +65,28 @@ + return 0; + } + // CraftBukkit end - double d0 = this.owner.locX() - this.locX(); - double d1 = this.owner.locY() - this.locY(); - double d2 = this.owner.locZ() - this.locZ(); -@@ -349,7 +383,11 @@ + double d0 = entityhuman.locX() - this.locX(); + double d1 = entityhuman.locY() - this.locY(); + double d2 = entityhuman.locZ() - this.locZ(); +@@ -412,7 +445,11 @@ entityitem.setMot(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); this.world.addEntity(entityitem); -- this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX(), this.owner.locY() + 0.5D, this.owner.locZ() + 0.5D, this.random.nextInt(6) + 1)); +- entityhuman.world.addEntity(new EntityExperienceOrb(entityhuman.world, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, this.random.nextInt(6) + 1)); + // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop() + if (playerFishEvent.getExpToDrop() > 0) { -+ this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX(), this.owner.locY() + 0.5D, this.owner.locZ() + 0.5D, playerFishEvent.getExpToDrop())); ++ entityhuman.world.addEntity(new EntityExperienceOrb(entityhuman.world, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, playerFishEvent.getExpToDrop())); + } + // CraftBukkit end - if (itemstack1.getItem().a(TagsItem.FISHES)) { - this.owner.a(StatisticList.FISH_CAUGHT, 1); + if (itemstack1.getItem().a((Tag) TagsItem.FISHES)) { + entityhuman.a(StatisticList.FISH_CAUGHT, 1); } -@@ -359,8 +397,25 @@ +@@ -422,8 +459,25 @@ } - if (this.isInGround) { + if (this.onGround) { + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { @@ -105,7 +97,7 @@ } + // CraftBukkit start + if (i == 0) { -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return 0; diff --git a/nms-patches/EntityFox.patch b/nms-patches/EntityFox.patch index a3fc90cbf0..f7e581b908 100644 --- a/nms-patches/EntityFox.patch +++ b/nms-patches/EntityFox.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityFox.java +++ b/net/minecraft/server/EntityFox.java -@@ -263,8 +263,8 @@ - private List eE() { +@@ -264,8 +264,8 @@ + private List fb() { List list = Lists.newArrayList(); - list.add(((Optional) this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse((Object) null)); @@ -11,16 +11,16 @@ return list; } -@@ -397,7 +397,7 @@ - protected void a(EntityItem entityitem) { +@@ -401,7 +401,7 @@ + protected void b(EntityItem entityitem) { ItemStack itemstack = entityitem.getItemStack(); -- if (this.g(itemstack)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack.getCount() - 1, !this.g(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent +- if (this.canPickup(itemstack)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack.getCount() - 1, !this.canPickup(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent int i = itemstack.getCount(); if (i > 1) { -@@ -918,6 +918,11 @@ +@@ -923,6 +923,11 @@ int i = (Integer) iblockdata.get(BlockSweetBerryBush.a); iblockdata.set(BlockSweetBerryBush.a, 1); @@ -32,7 +32,7 @@ int j = 1 + EntityFox.this.world.random.nextInt(2) + (i == 3 ? 1 : 0); ItemStack itemstack = EntityFox.this.getEquipment(EnumItemSlot.MAINHAND); -@@ -957,7 +962,7 @@ +@@ -962,7 +967,7 @@ private int f; public r() { @@ -41,7 +41,7 @@ this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK)); } -@@ -1009,7 +1014,7 @@ +@@ -1014,7 +1019,7 @@ private int c; public t() { @@ -50,7 +50,7 @@ this.c = EntityFox.this.random.nextInt(140); this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK, PathfinderGoal.Type.JUMP)); } -@@ -1120,7 +1125,7 @@ +@@ -1125,7 +1130,7 @@ private EntityLiving k; private int l; @@ -59,16 +59,7 @@ super(EntityFox.this, oclass, 10, flag, flag1, predicate); } -@@ -1155,7 +1160,7 @@ - - @Override - public void c() { -- EntityFox.this.setGoalTarget(this.j); -+ EntityFox.this.setGoalTarget(this.j, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - this.c = this.j; - if (this.k != null) { - this.l = this.k.cI(); -@@ -1199,6 +1204,14 @@ +@@ -1204,6 +1209,14 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { entityfox.b(entityplayer1.getUniqueID()); } @@ -83,7 +74,7 @@ if (entityplayer2 != null) { entityplayer2.a(StatisticList.ANIMALS_BRED); -@@ -1213,10 +1226,14 @@ +@@ -1216,10 +1229,14 @@ this.partner.resetLove(); entityfox.setAgeRaw(-24000); entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F); diff --git a/nms-patches/EntityGhast.patch b/nms-patches/EntityGhast.patch index 612e4cbe21..07b2616fb3 100644 --- a/nms-patches/EntityGhast.patch +++ b/nms-patches/EntityGhast.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityGhast.java +++ b/net/minecraft/server/EntityGhast.java @@ -163,7 +163,8 @@ - world.a((EntityHuman) null, 1016, new BlockPosition(this.ghast), 0); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4); - entitylargefireball.yield = this.ghast.getPower(); diff --git a/nms-patches/EntityGuardianElder.patch b/nms-patches/EntityGuardianElder.patch index f5f5291cac..9dcb957bda 100644 --- a/nms-patches/EntityGuardianElder.patch +++ b/nms-patches/EntityGuardianElder.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityGuardianElder.java +++ b/net/minecraft/server/EntityGuardianElder.java -@@ -69,7 +69,7 @@ +@@ -65,7 +65,7 @@ if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(10, 0.0F)); + entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.k, this.isSilent() ? 0.0F : 1.0F)); - entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2)); + entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch index 8c33c4b107..59a47ca02e 100644 --- a/nms-patches/EntityHanging.patch +++ b/nms-patches/EntityHanging.patch @@ -43,8 +43,8 @@ + d0 -= (double) direction.getAdjacentX() * 0.46875D; + d2 -= (double) direction.getAdjacentZ() * 0.46875D; d1 += d5; -- EnumDirection enumdirection = this.direction.g(); -+ EnumDirection enumdirection = direction.g(); +- EnumDirection enumdirection = this.direction.h(); ++ EnumDirection enumdirection = direction.h(); d0 += d4 * (double) enumdirection.getAdjacentX(); d2 += d4 * (double) enumdirection.getAdjacentZ(); @@ -59,8 +59,8 @@ + double d7 = (double) height; + double d8 = (double) width; -- if (this.direction.m() == EnumDirection.EnumAxis.Z) { -+ if (direction.m() == EnumDirection.EnumAxis.Z) { +- if (this.direction.n() == EnumDirection.EnumAxis.Z) { ++ if (direction.n() == EnumDirection.EnumAxis.Z) { d8 = 1.0D; } else { d6 = 1.0D; @@ -79,32 +79,32 @@ return i % 32 == 0 ? 0.5D : 0.0D; } -@@ -78,6 +96,24 @@ - if (this.e++ == 100 && !this.world.isClientSide) { - this.e = 0; - if (!this.dead && !this.survives()) { -+ // CraftBukkit start - fire break events -+ Material material = this.world.getType(new BlockPosition(this)).getMaterial(); -+ HangingBreakEvent.RemoveCause cause; +@@ -83,6 +101,24 @@ + if (this.e++ == 100) { + this.e = 0; + if (!this.dead && !this.survives()) { ++ // CraftBukkit start - fire break events ++ Material material = this.world.getType(this.getChunkCoordinates()).getMaterial(); ++ HangingBreakEvent.RemoveCause cause; + -+ if (!material.equals(Material.AIR)) { -+ // TODO: This feels insufficient to catch 100% of suffocation cases -+ cause = HangingBreakEvent.RemoveCause.OBSTRUCTION; -+ } else { -+ cause = HangingBreakEvent.RemoveCause.PHYSICS; -+ } ++ if (!material.equals(Material.AIR)) { ++ // TODO: This feels insufficient to catch 100% of suffocation cases ++ cause = HangingBreakEvent.RemoveCause.OBSTRUCTION; ++ } else { ++ cause = HangingBreakEvent.RemoveCause.PHYSICS; ++ } + -+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause); -+ this.world.getServer().getPluginManager().callEvent(event); ++ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause); ++ this.world.getServer().getPluginManager().callEvent(event); + -+ if (dead || event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.die(); - this.a((Entity) null); - } -@@ -140,6 +176,22 @@ ++ if (dead || event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.die(); + this.a((Entity) null); + } +@@ -146,6 +182,22 @@ return false; } else { if (!this.dead && !this.world.isClientSide) { @@ -127,7 +127,7 @@ this.die(); this.velocityChanged(); this.a(damagesource.getEntity()); -@@ -152,6 +204,18 @@ +@@ -158,6 +210,18 @@ @Override public void move(EnumMoveType enummovetype, Vec3D vec3d) { if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) { @@ -146,7 +146,7 @@ this.die(); this.a((Entity) null); } -@@ -160,7 +224,7 @@ +@@ -166,7 +230,7 @@ @Override public void h(double d0, double d1, double d2) { diff --git a/nms-patches/EntityHorseAbstract.patch b/nms-patches/EntityHorseAbstract.patch index a8b13321f9..649c9b98ca 100644 --- a/nms-patches/EntityHorseAbstract.patch +++ b/nms-patches/EntityHorseAbstract.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/server/EntityHorseAbstract.java +++ b/net/minecraft/server/EntityHorseAbstract.java -@@ -5,6 +5,7 @@ +@@ -6,6 +6,7 @@ import java.util.UUID; import java.util.function.Predicate; import javax.annotation.Nullable; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit - public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable { + public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable { -@@ -33,6 +34,7 @@ - private float bS; - protected boolean bD = true; - protected int bE; +@@ -34,6 +35,7 @@ + private float bR; + protected boolean bB = true; + protected int bC; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -210,7 +212,7 @@ +@@ -218,7 +220,7 @@ public void loadChest() { InventorySubcontainer inventorysubcontainer = this.inventoryChest; @@ -25,7 +25,7 @@ if (inventorysubcontainer != null) { inventorysubcontainer.b((IInventoryListener) this); int i = Math.min(inventorysubcontainer.getSize(), this.inventoryChest.getSize()); -@@ -333,7 +335,7 @@ +@@ -334,7 +336,7 @@ } public int getMaxDomestication() { @@ -34,7 +34,7 @@ } @Override -@@ -394,7 +396,7 @@ +@@ -405,7 +407,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -43,7 +43,7 @@ flag = true; } -@@ -470,7 +472,7 @@ +@@ -481,7 +483,7 @@ super.movementTick(); if (!this.world.isClientSide && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTicks == 0) { @@ -51,18 +51,18 @@ + this.heal(1.0F, RegainReason.REGEN); // CraftBukkit } - if (this.eO()) { -@@ -717,6 +719,7 @@ + if (this.fm()) { +@@ -718,6 +720,7 @@ if (this.getOwnerUUID() != null) { - nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString()); + nbttagcompound.a("Owner", this.getOwnerUUID()); } + nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit if (!this.inventoryChest.getItem(0).isEmpty()) { nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); -@@ -744,6 +747,11 @@ - if (!s.isEmpty()) { - this.setOwnerUUID(UUID.fromString(s)); +@@ -745,6 +748,11 @@ + if (uuid != null) { + this.setOwnerUUID(uuid); } + // CraftBukkit start + if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) { @@ -70,9 +70,9 @@ + } + // CraftBukkit end - AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); - -@@ -801,6 +809,18 @@ + if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) { + ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("SaddleItem")); +@@ -796,6 +804,18 @@ @Override public void b(int i) { @@ -89,5 +89,5 @@ + } + // CraftBukkit end this.canSlide = true; - this.eW(); - } + this.eV(); + this.fo(); diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch index 3fbbb65533..0d08161796 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 -@@ -15,10 +15,24 @@ +@@ -16,10 +16,24 @@ import java.util.function.Predicate; import javax.annotation.Nullable; @@ -19,15 +19,15 @@ + public abstract class EntityHuman extends EntityLiving { - public static final EntitySize bp = EntitySize.b(0.6F, 1.8F); -- private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bp).put(EntityPose.SLEEPING, EntityHuman.ap).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); + public static final EntitySize bo = EntitySize.b(0.6F, 1.8F); +- private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bo).put(EntityPose.SLEEPING, EntityHuman.ao).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); + // CraftBukkit - decompile error -+ private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bp).put(EntityPose.SLEEPING, EntityHuman.ap).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); ++ private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bo).put(EntityPose.SLEEPING, EntityHuman.ao).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); private static final DataWatcherObject c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); private static final DataWatcherObject d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b); - protected static final DataWatcherObject bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); -@@ -27,10 +41,10 @@ - protected static final DataWatcherObject bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); + protected static final DataWatcherObject bp = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); +@@ -28,10 +42,10 @@ + protected static final DataWatcherObject bs = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); private long e; public final PlayerInventory inventory = new PlayerInventory(this); - protected InventoryEnderChest enderChest = new InventoryEnderChest(); @@ -36,16 +36,15 @@ public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int bz; + protected int by; + public float bz; public float bA; - public float bB; -@@ -58,6 +72,17 @@ +@@ -57,6 +71,16 @@ @Nullable public EntityFishingHook hookedFish; + // CraftBukkit start + public boolean fauxSleeping; -+ public String spawnWorld = ""; + public int oldLevel = -1; + + @Override @@ -54,19 +53,19 @@ + } + // CraftBukkit end + - public EntityHuman(World world, GameProfile gameprofile) { + public EntityHuman(World world, BlockPosition blockposition, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); - this.bV = ItemStack.a; -@@ -206,7 +231,7 @@ + this.bS = ItemStack.b; +@@ -194,7 +218,7 @@ ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD); - if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a(TagsFluid.WATER)) { + if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a((Tag) TagsFluid.WATER)) { - this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true)); + this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit } } -@@ -379,7 +404,8 @@ +@@ -359,7 +383,8 @@ if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION)) { if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) { @@ -76,7 +75,7 @@ } if (this.foodData.c() && this.ticksLived % 10 == 0) { -@@ -563,6 +589,30 @@ +@@ -544,6 +569,30 @@ entityitem.setMot((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } @@ -107,30 +106,7 @@ return entityitem; } } -@@ -637,6 +687,14 @@ - } - - this.setScore(nbttagcompound.getInt("Score")); -+ -+ // CraftBukkit start -+ this.spawnWorld = nbttagcompound.getString("SpawnWorld"); -+ if ("".equals(spawnWorld)) { -+ this.spawnWorld = this.world.getServer().getWorlds().get(0).getName(); -+ } -+ // CraftBukkit end -+ - if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { - this.g = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.bR = nbttagcompound.getBoolean("SpawnForced"); -@@ -687,6 +745,7 @@ - if (!this.getShoulderEntityRight().isEmpty()) { - nbttagcompound.set("ShoulderEntityRight", this.getShoulderEntityRight()); - } -+ nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds - - } - -@@ -700,16 +759,17 @@ +@@ -670,16 +719,17 @@ if (this.isInvulnerable(damagesource)) { return false; } else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) { @@ -138,7 +114,7 @@ return false; } else { this.ticksFarFromPlayer = 0; - if (this.getHealth() <= 0.0F) { + if (this.dk()) { return false; } else { - this.releaseShoulderEntities(); @@ -150,7 +126,7 @@ } if (this.world.getDifficulty() == EnumDifficulty.EASY) { -@@ -721,7 +781,13 @@ +@@ -691,7 +741,13 @@ } } @@ -165,7 +141,7 @@ } } } -@@ -736,10 +802,29 @@ +@@ -706,10 +762,29 @@ } public boolean a(EntityHuman entityhuman) { @@ -198,8 +174,8 @@ } @Override -@@ -770,8 +855,13 @@ - +@@ -746,8 +821,13 @@ + } } + // CraftBukkit start @@ -213,24 +189,24 @@ if (!this.isInvulnerable(damagesource)) { f = this.applyArmorModifier(damagesource, f); f = this.applyMagicModifier(damagesource, f); -@@ -797,6 +887,7 @@ +@@ -773,6 +853,7 @@ } } + return false; // CraftBukkit } - public void openSign(TileEntitySign tileentitysign) {} -@@ -939,7 +1030,7 @@ + @Override +@@ -928,7 +1009,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; -- this.ey(); -+ // this.ey(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt +- this.resetAttackCooldown(); ++ // this.resetAttackCooldown(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -978,8 +1069,15 @@ +@@ -967,8 +1048,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isBurning()) { @@ -248,20 +224,20 @@ } } -@@ -1007,8 +1105,11 @@ +@@ -996,8 +1084,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) { + // CraftBukkit start - Only apply knockback if the damage hits + if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) { - entityliving.a(this, 0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); + entityliving.a(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); - entityliving.damageEntity(DamageSource.playerAttack(this), f4); + } + // CraftBukkit end } } -@@ -1017,9 +1118,26 @@ +@@ -1006,9 +1097,26 @@ } if (entity instanceof EntityPlayer && entity.velocityChanged) { @@ -288,7 +264,7 @@ } if (flag2) { -@@ -1064,7 +1182,14 @@ +@@ -1053,7 +1161,14 @@ this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -304,7 +280,7 @@ } if (this.world instanceof WorldServer && f5 > 2.0F) { -@@ -1080,6 +1205,11 @@ +@@ -1069,6 +1184,11 @@ if (flag4) { entity.extinguish(); } @@ -316,62 +292,19 @@ } } -@@ -1139,15 +1269,15 @@ - return this.bT; +@@ -1129,17 +1249,40 @@ } -- public Either sleep(BlockPosition blockposition) { -- EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); -- -+ // CraftBukkit start - moved bed result checks from below into separate method -+ private Either getBedResult(BlockPosition blockposition, EnumDirection enumdirection) { - if (!this.world.isClientSide) { - if (this.isSleeping() || !this.isAlive()) { - return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); - } - -- if (!this.world.worldProvider.isOverworld()) { -+ // CraftBukkit - moved world and biome check from BlockBed interact handling here -+ if (!world.worldProvider.canRespawn() || world.getBiome(blockposition) == Biomes.NETHER || !this.world.worldProvider.isOverworld()) { - return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); - } - -@@ -1177,6 +1307,34 @@ - } - } - } -+ return Either.right(Unit.INSTANCE); -+ } -+ -+ public Either sleep(BlockPosition blockposition) { -+ // CraftBukkit start - moved checks into separate method above, add force + public Either sleep(BlockPosition blockposition) { ++ // CraftBukkit start + return this.sleep(blockposition, false); + } + + public Either sleep(BlockPosition blockposition, boolean force) { -+ EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); -+ Either bedResult = this.getBedResult(blockposition, enumdirection); -+ -+ if (bedResult.left().orElse(null) == EntityHuman.EnumBedResult.OTHER_PROBLEM) { -+ return bedResult; // return immediately if the result is not bypassable by plugins -+ } -+ -+ if (force) { -+ bedResult = Either.right(Unit.INSTANCE); -+ } -+ -+ if (this.getBukkitEntity() instanceof Player) { -+ bedResult = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedEnterEvent(this, blockposition, bedResult); -+ -+ if (bedResult.left().isPresent()) { -+ return bedResult; -+ } -+ } + // CraftBukkit end - this.entitySleep(blockposition); this.sleepTicks = 0; -@@ -1211,11 +1369,28 @@ + return Either.right(Unit.INSTANCE); } public void wakeup(boolean flag, boolean flag1) { @@ -400,21 +333,9 @@ this.sleepTicks = flag ? 0 : 100; } -@@ -1267,9 +1442,11 @@ - - this.g = blockposition; - this.bR = flag; -+ this.spawnWorld = this.world.worldData.getName(); // CraftBukkit - } else { - this.g = null; - this.bR = false; -+ this.spawnWorld = ""; // CraftBukkit - } - - } -@@ -1341,7 +1518,11 @@ +@@ -1249,7 +1392,11 @@ this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z); - this.aM = f; + this.aL = f; this.fallDistance = 0.0F; - this.setFlag(7, false); + // CraftBukkit start @@ -423,9 +344,9 @@ + } + // CraftBukkit end } else { - super.e(vec3d); + super.f(vec3d); } -@@ -1467,12 +1648,24 @@ +@@ -1379,12 +1526,24 @@ } public void startGliding() { @@ -451,7 +372,7 @@ } @Override -@@ -1687,26 +1880,31 @@ +@@ -1599,26 +1758,31 @@ protected void releaseShoulderEntities() { if (this.e + 20L < this.world.getTime()) { diff --git a/nms-patches/EntityIllagerIllusioner.patch b/nms-patches/EntityIllagerIllusioner.patch index d4ec47b58b..88c538872a 100644 --- a/nms-patches/EntityIllagerIllusioner.patch +++ b/nms-patches/EntityIllagerIllusioner.patch @@ -9,7 +9,7 @@ this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300)); this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300)); this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300)); -@@ -173,7 +173,7 @@ +@@ -169,7 +169,7 @@ @Override protected void j() { @@ -18,7 +18,7 @@ } @Override -@@ -210,7 +210,7 @@ +@@ -206,7 +206,7 @@ @Override protected void j() { diff --git a/nms-patches/EntityInsentient.patch b/nms-patches/EntityInsentient.patch index 84f4bdaeea..7eaedccac4 100644 --- a/nms-patches/EntityInsentient.patch +++ b/nms-patches/EntityInsentient.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/EntityInsentient.java +++ b/net/minecraft/server/EntityInsentient.java -@@ -9,6 +9,18 @@ +@@ -10,6 +10,18 @@ import java.util.UUID; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; -+import org.bukkit.entity.LivingEntity; ++import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityCombustByEntityEvent; -+import org.bukkit.event.entity.EntityPickupItemEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityTargetEvent; ++import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.EntityUnleashEvent; +import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; +// CraftBukkit end @@ -19,25 +19,25 @@ public abstract class EntityInsentient extends EntityLiving { private static final DataWatcherObject b = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); -@@ -27,7 +39,7 @@ +@@ -28,7 +40,7 @@ public final float[] dropChanceHand; - private final NonNullList by; + private final NonNullList bx; public final float[] dropChanceArmor; - private boolean canPickUpLoot; + // private boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving public boolean persistent; - private final Map bB; + private final Map bA; public MinecraftKey lootTableKey; -@@ -40,6 +52,8 @@ - private BlockPosition bH; - private float bI; +@@ -41,6 +53,8 @@ + private BlockPosition bG; + private float bH; + public boolean aware = true; // CraftBukkit + protected EntityInsentient(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.bx = NonNullList.a(2, ItemStack.a); -@@ -63,6 +77,9 @@ + this.bw = NonNullList.a(2, ItemStack.b); +@@ -64,6 +78,9 @@ this.initPathfinder(); } @@ -47,7 +47,7 @@ } protected void initPathfinder() {} -@@ -130,7 +147,38 @@ +@@ -144,7 +161,38 @@ } public void setGoalTarget(@Nullable EntityLiving entityliving) { @@ -86,7 +86,7 @@ } @Override -@@ -343,16 +391,26 @@ +@@ -361,16 +409,26 @@ nbttagcompound.setBoolean("NoAI", this.isNoAI()); } @@ -94,8 +94,8 @@ } @Override - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); + public void loadData(NBTTagCompound nbttagcompound) { + super.loadData(nbttagcompound); + + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it if (nbttagcompound.hasKeyOfType("CanPickUpLoot", 1)) { @@ -115,7 +115,7 @@ NBTTagList nbttaglist; int i; -@@ -399,6 +457,11 @@ +@@ -417,6 +475,11 @@ } this.setNoAI(nbttagcompound.getBoolean("NoAI")); @@ -127,7 +127,7 @@ } @Override -@@ -406,6 +469,11 @@ +@@ -424,6 +487,11 @@ super.a(damagesource, flag); this.lootTableKey = null; } @@ -139,17 +139,38 @@ @Override protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) { -@@ -465,11 +533,17 @@ - ItemStack itemstack1 = this.getEquipment(enumitemslot); - boolean flag = this.a(itemstack, itemstack1, enumitemslot); +@@ -480,7 +548,7 @@ + protected void b(EntityItem entityitem) { + ItemStack itemstack = entityitem.getItemStack(); -- if (flag && this.g(itemstack)) { +- if (this.g(itemstack)) { ++ if (this.g(itemstack, entityitem)) { // CraftBukkit - add item + this.a(entityitem); + this.receive(entityitem, itemstack.getCount()); + entityitem.die(); +@@ -489,15 +557,29 @@ + } + + public boolean g(ItemStack itemstack) { ++ // CraftBukkit start - add item ++ return this.g(itemstack, null); ++ } ++ ++ public boolean g(ItemStack itemstack, EntityItem entityitem) { ++ // CraftBukkit end + EnumItemSlot enumitemslot = j(itemstack); + ItemStack itemstack1 = this.getEquipment(enumitemslot); + boolean flag = this.a(itemstack, itemstack1); + +- if (flag && this.canPickup(itemstack)) { + // CraftBukkit start -+ boolean canPickup = flag && this.g(itemstack); -+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled(); ++ boolean canPickup = flag && this.canPickup(itemstack); ++ if (entityitem != null) { ++ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled(); ++ } + if (canPickup) { + // CraftBukkit end - double d0 = (double) this.d(enumitemslot); + double d0 = (double) this.e(enumitemslot); if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { + this.forceDrops = true; // CraftBukkit @@ -157,55 +178,96 @@ + this.forceDrops = false; // CraftBukkit } - this.setSlot(enumitemslot, itemstack); -@@ -554,11 +628,11 @@ - if (entityhuman != null) { - double d0 = entityhuman.h(this); + this.b(enumitemslot, itemstack); +@@ -610,18 +692,18 @@ + EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); -- if (d0 > 16384.0D && this.isTypeNotPersistent(d0)) { -+ if (d0 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check + if (entityhuman != null) { +- double d0 = entityhuman.h(this); ++ double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error + int i = this.getEntityType().e().f(); + int j = i * i; + +- if (d0 > (double) j && this.isTypeNotPersistent(d0)) { ++ if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check this.die(); } -- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D && this.isTypeNotPersistent(d0)) { -+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check + int k = this.getEntityType().e().g(); + int l = k * k; + +- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.isTypeNotPersistent(d0)) { ++ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check this.die(); - } else if (d0 < 1024.0D) { + } else if (d0 < (double) l) { this.ticksFarFromPlayer = 0; -@@ -573,6 +647,7 @@ +@@ -636,6 +718,7 @@ @Override protected final void doTick() { ++this.ticksFarFromPlayer; + if (!this.aware) return; // CraftBukkit this.world.getMethodProfiler().enter("sensing"); - this.bw.a(); + this.bv.a(); this.world.getMethodProfiler().exit(); -@@ -951,12 +1026,24 @@ +@@ -1014,6 +1097,12 @@ if (!this.isAlive()) { - return false; + return EnumInteractionResult.PASS; } else if (this.getLeashHolder() == entityhuman) { + // CraftBukkit start - fire PlayerUnleashEntityEvent + if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) { + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); -+ return false; ++ return EnumInteractionResult.PASS; + } + // CraftBukkit end this.unleash(true, !entityhuman.abilities.canInstantlyBuild); - return true; + return EnumInteractionResult.a(this.world.isClientSide); } else { - ItemStack itemstack = entityhuman.b(enumhand); +@@ -1032,6 +1121,12 @@ + ItemStack itemstack = entityhuman.b(enumhand); - if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) { -+ // CraftBukkit start - fire PlayerLeashEntityEvent -+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); -+ return false; -+ } -+ // CraftBukkit end - this.setLeashHolder(entityhuman, true); - itemstack.subtract(1); - return true; -@@ -1002,6 +1089,7 @@ + if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) { ++ // CraftBukkit start - fire PlayerLeashEntityEvent ++ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.setLeashHolder(entityhuman, true); + itemstack.subtract(1); + return EnumInteractionResult.a(this.world.isClientSide); +@@ -1047,7 +1142,7 @@ + if (itemstack.getItem() instanceof ItemMonsterEgg) { + if (!this.world.isClientSide) { + ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); +- Optional optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), this.world, this.getPositionVector(), itemstack); ++ Optional optional = itemmonsteregg.a(entityhuman, this, (EntityTypes) this.getEntityType(), this.world, this.getPositionVector(), itemstack); // CraftBukkit - decompile error + + optional.ifPresent((entityinsentient) -> { + this.a(entityhuman, entityinsentient); +@@ -1098,7 +1193,7 @@ + if (this.dead) { + return null; + } else { +- T t0 = (EntityInsentient) entitytypes.a(this.world); ++ T t0 = entitytypes.a(this.world); // CraftBukkit - decompile error + + t0.u(this); + t0.setCanPickupLoot(this.canPickupLoot()); +@@ -1128,7 +1223,12 @@ + } + } + +- this.world.addEntity(t0); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, t0, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) { ++ return null; ++ } ++ this.world.addEntity(t0, CreatureSpawnEvent.SpawnReason.DROWNED); ++ // CraftBukkit end + this.die(); + return t0; + } +@@ -1141,6 +1241,7 @@ if (this.leashHolder != null) { if (!this.isAlive() || !this.leashHolder.isAlive()) { @@ -213,9 +275,9 @@ this.unleash(true, true); } -@@ -1017,7 +1105,9 @@ - +@@ -1157,7 +1258,9 @@ this.leashHolder = null; + this.bF = null; if (!this.world.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.LEAD); @@ -223,15 +285,15 @@ } if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { -@@ -1086,6 +1176,7 @@ +@@ -1207,6 +1310,7 @@ + boolean flag1 = super.a(entity, flag); - this.setLeashHolder(EntityLeash.a(this.world, blockposition), true); - } else { -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit - this.unleash(false, true); - } + if (flag1 && this.isLeashed()) { ++ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit + this.unleash(true, true); + } -@@ -1193,7 +1284,14 @@ +@@ -1339,7 +1443,14 @@ int i = EnchantmentManager.getFireAspectEnchantmentLevel(this); if (i > 0) { @@ -247,3 +309,11 @@ } boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f); +@@ -1401,6 +1512,7 @@ + @Override + protected void bJ() { + super.bJ(); ++ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit + this.unleash(true, false); + } + } diff --git a/nms-patches/EntityIronGolem.patch b/nms-patches/EntityIronGolem.patch index de71313ec1..d8e31ccac5 100644 --- a/nms-patches/EntityIronGolem.patch +++ b/nms-patches/EntityIronGolem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityIronGolem.java +++ b/net/minecraft/server/EntityIronGolem.java -@@ -59,7 +59,7 @@ +@@ -58,7 +58,7 @@ @Override protected void C(Entity entity) { if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) { diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch index f95107f33b..16c665dc91 100644 --- a/nms-patches/EntityItem.patch +++ b/nms-patches/EntityItem.patch @@ -35,7 +35,7 @@ this.lastX = this.locX(); this.lastY = this.locY(); -@@ -102,9 +110,11 @@ +@@ -103,9 +111,11 @@ } } @@ -45,9 +45,9 @@ } + // CraftBukkit end */ - this.impulse |= this.aC(); + this.impulse |= this.aG(); if (!this.world.isClientSide) { -@@ -116,6 +126,12 @@ +@@ -117,6 +127,12 @@ } if (!this.world.isClientSide && this.age >= 6000) { @@ -60,7 +60,7 @@ this.die(); } -@@ -185,10 +201,11 @@ +@@ -192,10 +208,11 @@ private static void a(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) { ItemStack itemstack2 = a(itemstack, itemstack1, 64); @@ -73,17 +73,8 @@ a(entityitem, itemstack, itemstack1); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); entityitem.age = Math.min(entityitem.age, entityitem1.age); -@@ -199,7 +216,7 @@ - } - - @Override -- protected void burn(int i) { -+ protected void burn(float i) { // CraftBukkit - int -> float - this.damageEntity(DamageSource.FIRE, (float) i); - } - -@@ -210,6 +227,11 @@ - } else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { +@@ -219,6 +236,11 @@ + } else if (!this.getItemStack().getItem().a(damagesource)) { return false; } else { + // CraftBukkit start @@ -94,7 +85,7 @@ this.velocityChanged(); this.f = (int) ((float) this.f - f); if (this.f <= 0) { -@@ -271,6 +293,40 @@ +@@ -280,6 +302,40 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -135,7 +126,7 @@ if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) { entityhuman.receive(this, i); if (itemstack.isEmpty()) { -@@ -313,7 +369,9 @@ +@@ -323,7 +379,9 @@ } public void setItemStack(ItemStack itemstack) { @@ -144,4 +135,4 @@ + this.getDataWatcher().markDirty(EntityItem.ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty } - @Nullable + @Override diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch index e98633986e..13cff21e36 100644 --- a/nms-patches/EntityItemFrame.patch +++ b/nms-patches/EntityItemFrame.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityItemFrame.java +++ b/net/minecraft/server/EntityItemFrame.java -@@ -52,16 +52,27 @@ +@@ -53,16 +53,27 @@ @Override protected void updateBoundingBox() { if (this.direction != null) { @@ -22,7 +22,7 @@ - double d4 = (double) this.getHangingWidth(); - double d5 = (double) this.getHangingHeight(); - double d6 = (double) this.getHangingWidth(); -- EnumDirection.EnumAxis enumdirection_enumaxis = this.direction.m(); +- EnumDirection.EnumAxis enumdirection_enumaxis = this.direction.n(); + double d1 = (double) blockPosition.getX() + 0.5D - (double) direction.getAdjacentX() * 0.46875D; + double d2 = (double) blockPosition.getY() + 0.5D - (double) direction.getAdjacentY() * 0.46875D; + double d3 = (double) blockPosition.getZ() + 0.5D - (double) direction.getAdjacentZ() * 0.46875D; @@ -33,11 +33,11 @@ + double d4 = (double) width; + double d5 = (double) height; + double d6 = (double) width; -+ EnumDirection.EnumAxis enumdirection_enumaxis = direction.m(); ++ EnumDirection.EnumAxis enumdirection_enumaxis = direction.n(); switch (enumdirection_enumaxis) { case X: -@@ -77,9 +88,10 @@ +@@ -78,9 +89,10 @@ d4 /= 32.0D; d5 /= 32.0D; d6 /= 32.0D; @@ -49,7 +49,7 @@ @Override public boolean survives() { -@@ -109,6 +121,11 @@ +@@ -130,6 +142,11 @@ return false; } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) { if (!this.world.isClientSide) { @@ -59,9 +59,9 @@ + } + // CraftBukkit end this.b(damagesource.getEntity(), false); - this.a(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F); + this.playSound(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F); } -@@ -194,6 +211,12 @@ +@@ -217,6 +234,12 @@ } public void setItem(ItemStack itemstack, boolean flag) { @@ -74,12 +74,12 @@ if (!itemstack.isEmpty()) { itemstack = itemstack.cloneItemStack(); itemstack.setCount(1); -@@ -201,7 +224,7 @@ +@@ -224,7 +247,7 @@ } this.getDataWatcher().set(EntityItemFrame.ITEM, itemstack); - if (!itemstack.isEmpty()) { + if (!itemstack.isEmpty() && playSound) { // CraftBukkit - this.a(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F); + this.playSound(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F); } diff --git a/nms-patches/EntityLargeFireball.patch b/nms-patches/EntityLargeFireball.patch index f435c057e9..31b75323a7 100644 --- a/nms-patches/EntityLargeFireball.patch +++ b/nms-patches/EntityLargeFireball.patch @@ -20,8 +20,8 @@ } @Override -@@ -25,7 +29,15 @@ - +@@ -18,7 +22,15 @@ + if (!this.world.isClientSide) { boolean flag = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); - this.world.createExplosion((Entity) null, this.locX(), this.locY(), this.locZ(), (float) this.yield, flag, flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); @@ -37,9 +37,9 @@ this.die(); } -@@ -41,7 +53,8 @@ - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); +@@ -49,7 +61,8 @@ + public void loadData(NBTTagCompound nbttagcompound) { + super.loadData(nbttagcompound); if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { - this.yield = nbttagcompound.getInt("ExplosionPower"); + // CraftBukkit - set bukkitYield when setting explosionpower diff --git a/nms-patches/EntityLeash.patch b/nms-patches/EntityLeash.patch index 2d415b3ba5..a6ef65309c 100644 --- a/nms-patches/EntityLeash.patch +++ b/nms-patches/EntityLeash.patch @@ -1,13 +1,14 @@ --- a/net/minecraft/server/EntityLeash.java +++ b/net/minecraft/server/EntityLeash.java -@@ -1,5 +1,7 @@ - package net.minecraft.server; - -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+ - import java.util.Iterator; +@@ -4,6 +4,8 @@ import java.util.List; import javax.annotation.Nullable; + ++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit ++ + public class EntityLeash extends EntityHanging { + + public EntityLeash(EntityTypes entitytypes, World world) { @@ -29,6 +31,7 @@ @Override protected void updateBoundingBox() { diff --git a/nms-patches/EntityLightning.patch b/nms-patches/EntityLightning.patch index acbce9dfd6..61e5022b2a 100644 --- a/nms-patches/EntityLightning.patch +++ b/nms-patches/EntityLightning.patch @@ -9,22 +9,10 @@ public class EntityLightning extends Entity { private int lifeTicks; -@@ -13,9 +15,11 @@ - private final boolean e; - @Nullable - private EntityPlayer f; -+ public boolean isEffect; // CraftBukkit +@@ -45,7 +47,24 @@ + this.a(4); + } - public EntityLightning(World world, double d0, double d1, double d2, boolean flag) { - super(EntityTypes.LIGHTNING_BOLT, world); -+ this.isEffect = flag; // CraftBukkit - this.ac = true; - this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F); - this.lifeTicks = 2; -@@ -43,7 +47,24 @@ - public void tick() { - super.tick(); - if (this.lifeTicks == 2) { - this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + // CraftBukkit start - Use relative location for far away sounds + // this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); @@ -47,7 +35,7 @@ this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); } -@@ -59,7 +80,7 @@ +@@ -61,7 +80,7 @@ } } @@ -55,9 +43,9 @@ + if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect if (this.world.isClientSide) { this.world.c(2); - } else if (!this.e) { -@@ -87,14 +108,22 @@ - BlockPosition blockposition = new BlockPosition(this); + } else if (!this.isEffect) { +@@ -89,7 +108,11 @@ + IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition); if (this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) { - this.world.setTypeUpdate(blockposition, iblockdata); @@ -69,8 +57,9 @@ } for (int j = 0; j < i; ++j) { - BlockPosition blockposition1 = blockposition.b(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); +@@ -97,7 +120,11 @@ + iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition1); if (this.world.getType(blockposition1).isAir() && iblockdata.canPlace(this.world, blockposition1)) { - this.world.setTypeUpdate(blockposition1, iblockdata); + // CraftBukkit start - add "!isEffect" diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch index 4198f94667..fe50480d4b 100644 --- a/nms-patches/EntityLiving.patch +++ b/nms-patches/EntityLiving.patch @@ -1,13 +1,12 @@ --- a/net/minecraft/server/EntityLiving.java +++ b/net/minecraft/server/EntityLiving.java -@@ -18,6 +18,25 @@ +@@ -21,6 +21,24 @@ import javax.annotation.Nullable; - import org.apache.commons.lang3.tuple.Pair; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.ArrayList; +import com.google.common.base.Function; -+import com.google.common.collect.Lists; +import org.bukkit.Location; +import org.bukkit.craftbukkit.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -26,16 +25,16 @@ public abstract class EntityLiving extends Entity { private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); -@@ -100,6 +119,20 @@ - private float bH; +@@ -106,6 +124,20 @@ private float bI; - protected BehaviorController bo; + private float bJ; + protected BehaviorController bn; + // CraftBukkit start + public int expToDrop; + public int maxAirTicks = 300; + boolean forceDrops; + ArrayList drops = new ArrayList(); -+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; ++ public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; + public boolean collides = true; + public boolean canPickUpLoot; + @@ -47,17 +46,18 @@ protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -110,7 +143,8 @@ - this.updateEffects = true; - this.activeItem = ItemStack.a; - this.initAttributes(); +@@ -117,7 +149,9 @@ + this.activeItem = ItemStack.b; + this.bF = Optional.empty(); + this.attributeMap = new AttributeMapBase(AttributeDefaults.a(entitytypes)); - this.setHealth(this.getMaxHealth()); ++ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor + this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue()); this.i = true; - this.aH = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); - this.Z(); -@@ -170,7 +204,13 @@ + this.aG = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); + this.ac(); +@@ -184,7 +218,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); @@ -72,16 +72,16 @@ } } -@@ -318,7 +358,7 @@ +@@ -406,7 +446,7 @@ - protected void cD() { + protected void cT() { ++this.deathTicks; - if (this.deathTicks == 20) { + if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) this.die(); for (int i = 0; i < 20; ++i) { -@@ -464,6 +504,17 @@ +@@ -567,6 +607,17 @@ } } @@ -99,7 +99,7 @@ if (nbttagcompound.hasKeyOfType("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -501,9 +552,32 @@ +@@ -604,9 +655,32 @@ } @@ -132,7 +132,7 @@ try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -513,6 +587,12 @@ +@@ -616,6 +690,12 @@ this.a(mobeffect, true); })) { if (!this.world.isClientSide) { @@ -145,7 +145,7 @@ iterator.remove(); this.b(mobeffect); } -@@ -523,6 +603,17 @@ +@@ -626,6 +706,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -163,8 +163,8 @@ if (this.updateEffects) { if (!this.world.isClientSide) { -@@ -632,7 +723,13 @@ - this.datawatcher.set(EntityLiving.e, 0); +@@ -735,7 +826,13 @@ + this.datawatcher.set(EntityLiving.f, 0); } + // CraftBukkit start @@ -177,7 +177,7 @@ if (this.world.isClientSide) { return false; } else { -@@ -641,7 +738,14 @@ +@@ -744,7 +841,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { @@ -193,7 +193,7 @@ iterator.remove(); } -@@ -666,18 +770,44 @@ +@@ -769,18 +873,44 @@ return (MobEffect) this.effects.get(mobeffectlist); } @@ -239,7 +239,7 @@ return true; } else { return false; -@@ -701,13 +831,39 @@ +@@ -804,13 +934,39 @@ return this.getMonsterType() == EnumMonsterType.UNDEAD; } @@ -280,7 +280,7 @@ if (mobeffect != null) { this.b(mobeffect); -@@ -744,20 +900,55 @@ +@@ -847,20 +1003,55 @@ } @@ -337,16 +337,16 @@ this.datawatcher.set(EntityLiving.HEALTH, MathHelper.a(f, 0.0F, this.getMaxHealth())); } -@@ -767,7 +958,7 @@ +@@ -874,7 +1065,7 @@ return false; } else if (this.world.isClientSide) { return false; -- } else if (this.getHealth() <= 0.0F) { +- } else if (this.dk()) { + } else if (this.dead || this.killed || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die return false; } else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -779,17 +970,19 @@ +@@ -886,17 +1077,19 @@ this.ticksFarFromPlayer = 0; float f1 = f; @@ -369,7 +369,7 @@ this.damageShield(f); f2 = f; f = 0.0F; -@@ -809,20 +1002,39 @@ +@@ -916,20 +1109,39 @@ if ((float) this.noDamageTicks > 10.0F) { if (f <= this.lastDamage) { @@ -403,20 +403,20 @@ + if (this instanceof EntityAnimal) { + ((EntityAnimal) this).resetLove(); + if (this instanceof EntityTameableAnimal) { -+ ((EntityTameableAnimal) this).getGoalSit().setSitting(false); ++ ((EntityTameableAnimal) this).setWillSit(false); + } + } + // CraftBukkit end + - this.ax = 0.0F; + this.aw = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -943,19 +1155,29 @@ +@@ -1050,19 +1262,29 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; + // CraftBukkit start -+ ItemStack itemstack1 = ItemStack.a; ++ ItemStack itemstack1 = ItemStack.b; for (int j = 0; j < i; ++j) { EnumHand enumhand = aenumhand[j]; - ItemStack itemstack1 = this.b(enumhand); @@ -445,7 +445,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING)); -@@ -963,13 +1185,15 @@ +@@ -1070,13 +1292,15 @@ } this.setHealth(1.0F); @@ -465,12 +465,12 @@ } } -@@ -1086,28 +1310,48 @@ +@@ -1193,28 +1417,48 @@ boolean flag = this.lastDamageByPlayerTime > 0; + this.dropInventory(); // CraftBukkit - from below - if (this.isDropExperience() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { + if (this.cV() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { this.a(damagesource, flag); this.dropDeathLoot(damagesource, i, flag); + // CraftBukkit start - Call death event @@ -516,7 +516,7 @@ } -@@ -1205,9 +1449,14 @@ +@@ -1335,9 +1579,14 @@ int i = this.e(f, f1); if (i > 0) { @@ -525,23 +525,23 @@ + return true; + } + // CraftBukkit end - this.a(this.getSoundFall(i), 1.0F, 1.0F); - this.cZ(); + this.playSound(this.getSoundFall(i), 1.0F, 1.0F); + this.playBlockStepSound(); - this.damageEntity(DamageSource.FALL, (float) i); + // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up return true; } else { return flag; -@@ -1249,7 +1498,7 @@ +@@ -1377,7 +1626,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.ARMOR_TOUGHNESS).getValue()); +- this.damageArmor(damagesource, f); ++ // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) + f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1262,7 +1511,8 @@ +@@ -1390,7 +1639,8 @@ } else { int i; @@ -551,7 +551,7 @@ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1293,28 +1543,173 @@ +@@ -1421,28 +1671,173 @@ } } @@ -630,7 +630,7 @@ + + EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); + if (damagesource.getEntity() instanceof EntityHuman) { -+ ((EntityHuman) damagesource.getEntity()).ey(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired ++ ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired + } + if (event.isCancelled()) { + return false; @@ -660,7 +660,7 @@ + // Apply damage to armor + if (!damagesource.ignoresArmor()) { + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); -+ this.damageArmor(armorDamage); ++ this.damageArmor(damagesource, armorDamage); + } - f = Math.max(f - this.getAbsorptionHearts(), 0.0F); @@ -671,12 +671,12 @@ + this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound + this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING)); + Entity entity = damagesource.j(); - ++ + if (entity instanceof EntityLiving) { + this.shieldBlock((EntityLiving) entity); + } + } -+ + + absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); + this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; @@ -735,15 +735,7 @@ } public CombatTracker getCombatTracker() { -@@ -1401,6 +1796,7 @@ - public AttributeMapBase getAttributeMap() { - if (this.attributeMap == null) { - this.attributeMap = new AttributeMapServer(); -+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit - } - - return this.attributeMap; -@@ -1771,6 +2167,7 @@ +@@ -1814,6 +2209,7 @@ } if (this.onGround && !this.world.isClientSide) { @@ -751,7 +743,7 @@ this.setFlag(7, false); } } else { -@@ -2168,6 +2565,7 @@ +@@ -2319,6 +2715,7 @@ } if (!this.world.isClientSide) { @@ -759,7 +751,7 @@ this.setFlag(7, flag); } -@@ -2279,6 +2677,7 @@ +@@ -2439,6 +2836,7 @@ } public boolean hasLineOfSight(Entity entity) { @@ -767,7 +759,7 @@ Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ()); Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ()); -@@ -2296,12 +2695,12 @@ +@@ -2456,12 +2854,12 @@ @Override public boolean isInteractable() { @@ -782,7 +774,7 @@ } @Override -@@ -2484,7 +2883,27 @@ +@@ -2645,7 +3043,27 @@ } else { if (!this.activeItem.isEmpty() && this.isHandRaised()) { this.b(this.activeItem, 16); @@ -808,10 +800,10 @@ + + this.a(this.getRaisedHand(), itemstack); + // CraftBukkit end - this.dH(); + this.clearActiveItem(); } -@@ -2571,10 +2990,18 @@ +@@ -2732,10 +3150,18 @@ } if (flag2) { @@ -833,7 +825,7 @@ } } -@@ -2661,7 +3088,7 @@ +@@ -2832,7 +3258,7 @@ } public void entityWakeup() { @@ -842,12 +834,12 @@ World world = this.world; this.world.getClass(); -@@ -2725,7 +3152,7 @@ +@@ -2899,7 +3325,7 @@ Pair pair = (Pair) iterator.next(); - if (!world.isClientSide && pair.getLeft() != null && world.random.nextFloat() < (Float) pair.getRight()) { -- entityliving.addEffect(new MobEffect((MobEffect) pair.getLeft())); -+ entityliving.addEffect(new MobEffect((MobEffect) pair.getLeft()), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit + if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { +- entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst())); ++ entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst()), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit } } } diff --git a/nms-patches/EntityLlamaSpit.patch b/nms-patches/EntityLlamaSpit.patch deleted file mode 100644 index f12d79985d..0000000000 --- a/nms-patches/EntityLlamaSpit.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/EntityLlamaSpit.java -+++ b/net/minecraft/server/EntityLlamaSpit.java -@@ -6,7 +6,7 @@ - - public class EntityLlamaSpit extends Entity implements IProjectile { - -- public EntityLlama shooter; -+ public EntityLiving shooter; // CraftBukkit - type - private NBTTagCompound c; - - public EntityLlamaSpit(EntityTypes entitytypes, World world) { -@@ -91,6 +91,7 @@ - } - - public void a(MovingObjectPosition movingobjectposition) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event - MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); - - if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY && this.shooter != null) { diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch index 82bb600f7a..4e55d8a4a2 100644 --- a/nms-patches/EntityMinecartAbstract.patch +++ b/nms-patches/EntityMinecartAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityMinecartAbstract.java +++ b/net/minecraft/server/EntityMinecartAbstract.java -@@ -8,6 +8,15 @@ +@@ -10,6 +10,15 @@ import java.util.Map; import javax.annotation.Nullable; @@ -16,16 +16,16 @@ public abstract class EntityMinecartAbstract extends Entity { private static final DataWatcherObject b = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); -@@ -17,7 +26,7 @@ - private static final DataWatcherObject f = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); +@@ -20,7 +29,7 @@ private static final DataWatcherObject g = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.i); + private static final ImmutableMap> an = ImmutableMap.of(EntityPose.STANDING, ImmutableList.of(0, 1, -1), EntityPose.CROUCHING, ImmutableList.of(0, 1, -1), EntityPose.SWIMMING, ImmutableList.of(0, 1)); private boolean ao; - private static final Map> ap = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { + private static final Map> ap = (Map) SystemUtils.a(Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { // CraftBukkit - decompile error BaseBlockPosition baseblockposition = EnumDirection.WEST.p(); BaseBlockPosition baseblockposition1 = EnumDirection.EAST.p(); BaseBlockPosition baseblockposition2 = EnumDirection.NORTH.p(); -@@ -45,6 +54,17 @@ +@@ -48,6 +57,17 @@ private double au; private double av; @@ -43,7 +43,7 @@ protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); this.i = true; -@@ -100,6 +120,19 @@ +@@ -168,6 +188,19 @@ if (this.isInvulnerable(damagesource)) { return false; } else { @@ -63,7 +63,7 @@ this.d(-this.n()); this.c(10); this.velocityChanged(); -@@ -107,6 +140,15 @@ +@@ -175,6 +208,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { @@ -79,7 +79,7 @@ this.ejectPassengers(); if (flag && !this.hasCustomName()) { this.die(); -@@ -152,6 +194,14 @@ +@@ -227,6 +269,14 @@ @Override public void tick() { @@ -94,8 +94,8 @@ if (this.getType() > 0) { this.c(this.getType() - 1); } -@@ -164,7 +214,7 @@ - this.af(); +@@ -239,7 +289,7 @@ + this.ai(); } - this.doPortalTick(); @@ -103,7 +103,7 @@ if (this.world.isClientSide) { if (this.aq > 0) { double d0 = this.locX() + (this.ar - this.locX()) / (double) this.aq; -@@ -227,6 +277,18 @@ +@@ -302,6 +352,18 @@ } this.setYawPitch(this.yaw, this.pitch); @@ -122,7 +122,7 @@ if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && b(this.getMot()) > 0.01D) { List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); -@@ -235,8 +297,26 @@ +@@ -310,8 +372,26 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -149,7 +149,7 @@ entity.collide(this); } } -@@ -248,6 +328,14 @@ +@@ -323,6 +403,14 @@ Entity entity1 = (Entity) iterator.next(); if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { @@ -164,7 +164,7 @@ entity1.collide(this); } } -@@ -258,7 +346,7 @@ +@@ -333,7 +421,7 @@ } protected double getMaxSpeed() { @@ -173,7 +173,7 @@ } public void a(int i, int j, int k, boolean flag) {} -@@ -269,12 +357,16 @@ +@@ -344,12 +432,16 @@ this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0)); if (this.onGround) { @@ -192,7 +192,7 @@ } } -@@ -461,7 +553,7 @@ +@@ -536,7 +628,7 @@ } protected void decelerate() { @@ -201,7 +201,7 @@ this.setMot(this.getMot().d(d0, 0.0D, d0)); } -@@ -544,6 +636,14 @@ +@@ -619,6 +711,14 @@ if (!this.world.isClientSide) { if (!entity.noclip && !this.noclip) { if (!this.w(entity)) { @@ -216,7 +216,7 @@ double d0 = entity.locX() - this.locX(); double d1 = entity.locZ() - this.locZ(); double d2 = d0 * d0 + d1 * d1; -@@ -679,4 +779,26 @@ +@@ -754,4 +854,26 @@ private EnumMinecartType() {} } diff --git a/nms-patches/EntityMinecartCommandBlock.patch b/nms-patches/EntityMinecartCommandBlock.patch index 7dae1a82ba..650ed8041d 100644 --- a/nms-patches/EntityMinecartCommandBlock.patch +++ b/nms-patches/EntityMinecartCommandBlock.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityMinecartCommandBlock.java +++ b/net/minecraft/server/EntityMinecartCommandBlock.java -@@ -104,5 +104,12 @@ +@@ -103,5 +103,12 @@ public CommandListenerWrapper getWrapper() { - return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.aX(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); + return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.be(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); } + + // CraftBukkit start diff --git a/nms-patches/EntityMinecartContainer.patch b/nms-patches/EntityMinecartContainer.patch index b0dd7268c6..b43e3bf6e6 100644 --- a/nms-patches/EntityMinecartContainer.patch +++ b/nms-patches/EntityMinecartContainer.patch @@ -61,15 +61,15 @@ + protected EntityMinecartContainer(EntityTypes entitytypes, World world) { super(entitytypes, world); -- this.items = NonNullList.a(36, ItemStack.a); -+ this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513 +- this.items = NonNullList.a(36, ItemStack.b); ++ this.items = NonNullList.a(this.getSize(), ItemStack.b); // CraftBukkit - SPIGOT-3513 this.c = true; } protected EntityMinecartContainer(EntityTypes entitytypes, double d0, double d1, double d2, World world) { super(entitytypes, world, d0, d1, d2); -- this.items = NonNullList.a(36, ItemStack.a); -+ this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513 +- this.items = NonNullList.a(36, ItemStack.b); ++ this.items = NonNullList.a(this.getSize(), ItemStack.b); // CraftBukkit - SPIGOT-3513 this.c = true; } diff --git a/nms-patches/EntityMushroomCow.patch b/nms-patches/EntityMushroomCow.patch index e3e460cc68..b69ce75cce 100644 --- a/nms-patches/EntityMushroomCow.patch +++ b/nms-patches/EntityMushroomCow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityMushroomCow.java +++ b/net/minecraft/server/EntityMushroomCow.java -@@ -3,6 +3,10 @@ +@@ -4,6 +4,10 @@ import java.util.Random; import java.util.UUID; import org.apache.commons.lang3.tuple.Pair; @@ -9,37 +9,42 @@ +import org.bukkit.event.entity.EntityTransformEvent; +// CraftBukkit end - public class EntityMushroomCow extends EntityCow { + public class EntityMushroomCow extends EntityCow implements IShearable { -@@ -81,9 +85,14 @@ - int i; +@@ -75,6 +79,11 @@ + this.playSound(soundeffect, 1.0F, 1.0F); + return EnumInteractionResult.a(this.world.isClientSide); + } else if (itemstack.getItem() == Items.SHEARS && this.canShear()) { ++ // CraftBukkit start ++ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.shear(SoundCategory.PLAYERS); + if (!this.world.isClientSide) { + itemstack.damage(1, entityhuman, (entityhuman1) -> { +@@ -121,7 +130,7 @@ + this.world.playSound((EntityHuman) null, (Entity) this, SoundEffects.ENTITY_MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F); + if (!this.world.s_()) { + ((WorldServer) this.world).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D); +- this.die(); ++ // this.die(); // CraftBukkit - moved down + EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.world); - if (itemstack.getItem() == Items.SHEARS && !this.isBaby()) { -+ // CraftBukkit start -+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { -+ return false; -+ } -+ // CraftBukkit end - this.world.addParticle(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 0.0D, 0.0D, 0.0D); - if (!this.world.isClientSide) { -- this.die(); -+ // this.die(); // CraftBukkit - moved down - EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.world); + entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch); +@@ -137,7 +146,14 @@ + } - entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch); -@@ -99,7 +108,14 @@ - } - - entitycow.setInvulnerable(this.isInvulnerable()); -- this.world.addEntity(entitycow); -+ // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { -+ return false; -+ } -+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); + entitycow.setInvulnerable(this.isInvulnerable()); +- this.world.addEntity(entitycow); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { ++ return; ++ } ++ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); + -+ this.die(); // CraftBukkit - from above -+ // CraftBukkit end ++ this.die(); // CraftBukkit - from above ++ // CraftBukkit end - for (i = 0; i < 5; ++i) { - this.world.addEntity(new EntityItem(this.world, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().d.getBlock()))); + for (int i = 0; i < 5; ++i) { + this.world.addEntity(new EntityItem(this.world, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().d.getBlock()))); diff --git a/nms-patches/EntityOcelot.patch b/nms-patches/EntityOcelot.patch index ef1bc5ce63..9fa78330f4 100644 --- a/nms-patches/EntityOcelot.patch +++ b/nms-patches/EntityOcelot.patch @@ -8,18 +8,18 @@ + return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit } - @Override -@@ -139,7 +139,8 @@ - if ((this.bz == null || this.bz.h()) && !this.isTrusting() && this.i(itemstack) && entityhuman.h((Entity) this) < 9.0D) { + public static AttributeProvider.Builder eL() { +@@ -135,7 +135,8 @@ + if ((this.by == null || this.by.h()) && !this.isTrusting() && this.k(itemstack) && entityhuman.h((Entity) this) < 9.0D) { this.a(entityhuman, itemstack); if (!this.world.isClientSide) { - 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.setTrusting(true); - this.s(true); + this.u(true); this.world.broadcastEntityEffect(this, (byte) 41); -@@ -249,9 +250,9 @@ +@@ -244,9 +245,9 @@ private final EntityOcelot i; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { diff --git a/nms-patches/EntityPanda.patch b/nms-patches/EntityPanda.patch index 07edbb9fb7..146868d9ff 100644 --- a/nms-patches/EntityPanda.patch +++ b/nms-patches/EntityPanda.patch @@ -8,34 +8,34 @@ + public class EntityPanda extends EntityAnimal { - private static final DataWatcherObject bx = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.b); -@@ -448,7 +450,7 @@ + private static final DataWatcherObject bw = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.b); +@@ -445,7 +447,7 @@ @Override - protected void a(EntityItem entityitem) { + protected void b(EntityItem entityitem) { - if (this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem)) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem))).isCancelled()) { // CraftBukkit + this.a(entityitem); ItemStack itemstack = entityitem.getItemStack(); - this.setSlot(EnumItemSlot.MAINHAND, itemstack); -@@ -672,7 +674,7 @@ +@@ -667,7 +669,7 @@ @Override protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { - if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).em()) { + if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) { - entityinsentient.setGoalTarget(entityliving); + entityinsentient.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit } } -@@ -776,9 +778,9 @@ +@@ -771,9 +773,9 @@ private final EntityPanda i; public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { -- Predicate predicate = IEntitySelector.f; -+ // Predicate predicate = IEntitySelector.f; // CraftBukkit - decompile error +- Predicate predicate = IEntitySelector.g; ++ // Predicate predicate = IEntitySelector.g; // CraftBukkit - decompile error - super(entitypanda, oclass, f, d0, d1, predicate::test); -+ super(entitypanda, oclass, f, d0, d1, IEntitySelector.f::test); // CraftBukkit - decompile error ++ super(entitypanda, oclass, f, d0, d1, IEntitySelector.g::test); // CraftBukkit - decompile error this.i = entitypanda; } diff --git a/nms-patches/EntityParrot.patch b/nms-patches/EntityParrot.patch index 530d24c68a..38c254a669 100644 --- a/nms-patches/EntityParrot.patch +++ b/nms-patches/EntityParrot.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/EntityParrot.java +++ b/net/minecraft/server/EntityParrot.java -@@ -21,7 +21,7 @@ +@@ -20,7 +20,7 @@ }; - private static final Item bF = Items.COOKIE; - private static final Set bG = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); -- private static final Map, SoundEffect> bH = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map, SoundEffect> bH = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error + private static final Item bD = Items.COOKIE; + private static final Set bE = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); +- private static final Map, SoundEffect> bF = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ private static final Map, SoundEffect> bF = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error hashmap.put(EntityTypes.BLAZE, SoundEffects.ENTITY_PARROT_IMITATE_BLAZE); hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.ENTITY_PARROT_IMITATE_SPIDER); hashmap.put(EntityTypes.CREEPER, SoundEffects.ENTITY_PARROT_IMITATE_CREEPER); -@@ -185,7 +185,7 @@ +@@ -187,7 +187,7 @@ } if (!this.world.isClientSide) { @@ -18,7 +18,7 @@ this.tame(entityhuman); this.world.broadcastEntityEffect(this, (byte) 7); } else { -@@ -199,7 +199,7 @@ +@@ -201,7 +201,7 @@ itemstack.subtract(1); } @@ -27,13 +27,12 @@ if (entityhuman.isCreative() || !this.isInvulnerable()) { this.damageEntity(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -336,7 +336,8 @@ +@@ -330,7 +330,7 @@ + if (this.isInvulnerable(damagesource)) { return false; } else { - if (this.goalSit != null) { -- this.goalSit.setSitting(false); -+ // CraftBukkit - moved into EntityLiving.d(DamageSource, float) -+ // this.goalSit.setSitting(false); - } - +- this.setWillSit(false); ++ // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) return super.damageEntity(damagesource, f); + } + } diff --git a/nms-patches/EntityPhantom.patch b/nms-patches/EntityPhantom.patch index 3548537728..960e8aebd4 100644 --- a/nms-patches/EntityPhantom.patch +++ b/nms-patches/EntityPhantom.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityPhantom.java +++ b/net/minecraft/server/EntityPhantom.java -@@ -214,7 +214,7 @@ +@@ -207,7 +207,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) { diff --git a/nms-patches/EntityPig.patch b/nms-patches/EntityPig.patch index 7336cab5af..d50e205f56 100644 --- a/nms-patches/EntityPig.patch +++ b/nms-patches/EntityPig.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/server/EntityPig.java +++ b/net/minecraft/server/EntityPig.java -@@ -2,6 +2,10 @@ - +@@ -3,6 +3,10 @@ + import com.google.common.collect.UnmodifiableIterator; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end + - public class EntityPig extends EntityAnimal { + public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable { - private static final DataWatcherObject bw = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); -@@ -160,7 +164,13 @@ - entitypigzombie.setCustomNameVisible(this.getCustomNameVisible()); - } - -- this.world.addEntity(entitypigzombie); -+ // CraftBukkit start -+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { -+ return; -+ } -+ // CraftBukkit - added a reason for spawning this creature -+ this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); -+ // CraftBukkit end - this.die(); - } + private static final DataWatcherObject bv = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); +@@ -204,7 +208,13 @@ + } + entitypigzombie.setPersistent(); +- this.world.addEntity(entitypigzombie); ++ // CraftBukkit start ++ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { ++ return; ++ } ++ // CraftBukkit - added a reason for spawning this creature ++ this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ // CraftBukkit end + this.die(); + } else { + super.onLightningStrike(entitylightning); diff --git a/nms-patches/EntityPigZombie.patch b/nms-patches/EntityPigZombie.patch index a8ebd1217a..b3f4a68920 100644 --- a/nms-patches/EntityPigZombie.patch +++ b/nms-patches/EntityPigZombie.patch @@ -1,42 +1,38 @@ --- a/net/minecraft/server/EntityPigZombie.java +++ b/net/minecraft/server/EntityPigZombie.java -@@ -134,16 +134,27 @@ - } else { - Entity entity = damagesource.getEntity(); - -- if (entity instanceof EntityHuman && !((EntityHuman) entity).isCreative() && this.hasLineOfSight(entity)) { -+ // CraftBukkit start -+ boolean result = super.damageEntity(damagesource, f); -+ -+ if (result && entity instanceof EntityHuman && !((EntityHuman) entity).isCreative() && this.hasLineOfSight(entity)) { - this.i((EntityLiving) entity); - } - -- return super.damageEntity(damagesource, f); -+ return result; -+ // CraftBukkit end - } +@@ -35,7 +35,7 @@ + protected void m() { + this.goalSelector.a(2, new PathfinderGoalZombieAttack(this, 1.0D, false)); + this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); ++ this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::b)); + this.targetSelector.a(3, new PathfinderGoalUniversalAngerReset<>(this, true)); + } +@@ -108,7 +108,7 @@ + }).filter((entitypigzombie) -> { + return !entitypigzombie.r(this.getGoalTarget()); + }).forEach((entitypigzombie) -> { +- entitypigzombie.setGoalTarget(this.getGoalTarget()); ++ entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit + }); } - private boolean i(EntityLiving entityliving) { -- this.angerLevel = this.ez(); +@@ -132,7 +132,16 @@ + + @Override + public void anger() { +- this.setAnger(EntityPigZombie.bw.a(this.random)); + // CraftBukkit start -+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entityliving == null) ? null : entityliving.getBukkitEntity(), this.ez()); ++ Entity entity = ((WorldServer) this.world).getEntity(getAngerTarget()); ++ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.bw.a(this.random)); + this.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ return false; ++ this.setAngerTarget(null); ++ return; + } -+ this.angerLevel = event.getNewAnger(); ++ this.setAnger(event.getNewAnger()); + // CraftBukkit end - this.soundDelay = this.random.nextInt(40); - this.setLastDamager(entityliving); - return true; -@@ -209,7 +220,7 @@ - @Override - protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { - if (entityinsentient instanceof EntityPigZombie && this.e.hasLineOfSight(entityliving) && ((EntityPigZombie) entityinsentient).i(entityliving)) { -- entityinsentient.setGoalTarget(entityliving); -+ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - } + } - } + public static boolean b(EntityTypes entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) { diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index b107062778..98a52d3c94 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityPlayer.java +++ b/net/minecraft/server/EntityPlayer.java -@@ -13,10 +13,31 @@ +@@ -14,6 +14,27 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -28,12 +28,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { private static final Logger LOGGER = LogManager.getLogger(); -- public String locale = "en_US"; -+ public String locale = "en_us"; // CraftBukkit - lowercase - public PlayerConnection playerConnection; - public final MinecraftServer server; - public final PlayerInteractManager playerInteractManager; -@@ -52,6 +73,20 @@ +@@ -56,6 +77,20 @@ public int ping; public boolean viewingCredits; @@ -52,12 +47,12 @@ + // CraftBukkit end + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { - super((World) worldserver, gameprofile); - playerinteractmanager.player = this; -@@ -62,8 +97,50 @@ + super(worldserver, worldserver.getSpawn(), gameprofile); + this.spawnDimension = World.OVERWORLD; +@@ -66,8 +101,55 @@ this.advancementDataPlayer = minecraftserver.getPlayerList().f(this); - this.H = 1.0F; - this.a(worldserver); + this.G = 1.0F; + this.b(worldserver); + + // CraftBukkit start + this.displayName = this.getName(); @@ -70,7 +65,7 @@ + public final BlockPosition getSpawnPoint(WorldServer worldserver) { + BlockPosition blockposition = worldserver.getSpawn(); + -+ if (worldserver.worldProvider.g() && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) { ++ if (worldserver.getDimensionManager().hasSkyLight() && worldserver.worldDataServer.getGameType() != EnumGamemode.ADVENTURE) { + int i = Math.max(0, this.server.a(worldserver)); + int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ())); + @@ -82,18 +77,23 @@ + i = 1; + } + -+ int k = (i * 2 + 1) * (i * 2 + 1); -+ int l = this.u(k); -+ int i1 = (new Random()).nextInt(k); ++ long k = (long) (i * 2 + 1); ++ long l = k * k; ++ int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; ++ int j1 = this.u(i1); ++ int k1 = (new Random()).nextInt(i1); + -+ for (int j1 = 0; j1 < k; ++j1) { -+ int k1 = (i1 + l * j1) % k; -+ int l1 = k1 % (i * 2 + 1); -+ int i2 = k1 / (i * 2 + 1); -+ BlockPosition blockposition1 = worldserver.getWorldProvider().a(blockposition.getX() + l1 - i, blockposition.getZ() + i2 - i, false); ++ for (int l1 = 0; l1 < i1; ++l1) { ++ int i2 = (k1 + j1 * l1) % i1; ++ int j2 = i2 % (i * 2 + 1); ++ int k2 = i2 / (i * 2 + 1); ++ BlockPosition blockposition1 = WorldProviderNormal.a(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i, false); + + if (blockposition1 != null) { -+ return blockposition1; ++ this.setPositionRotation(blockposition1, 0.0F, 0.0F); ++ if (worldserver.getCubes(this)) { ++ break; ++ } + } + } + } @@ -102,18 +102,31 @@ + } + // CraftBukkit end + - private void a(WorldServer worldserver) { + private void b(WorldServer worldserver) { BlockPosition blockposition = worldserver.getSpawn(); -@@ -133,6 +210,7 @@ +@@ -137,11 +219,20 @@ if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { - this.recipeBook.a(nbttagcompound.getCompound("recipeBook")); + this.recipeBook.a(nbttagcompound.getCompound("recipeBook"), this.server.getCraftingManager()); } + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit if (this.isSleeping()) { this.entityWakeup(); -@@ -157,7 +235,20 @@ + } + ++ // CraftBukkit start ++ String spawnWorld = nbttagcompound.getString("SpawnWorld"); ++ CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld); ++ if (oldWorld != null) { ++ this.spawnDimension = oldWorld.getHandle().getDimensionKey(); ++ } ++ // CraftBukkit end ++ + if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { + this.spawn = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); + this.spawnForced = nbttagcompound.getBoolean("SpawnForced"); +@@ -174,7 +265,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -135,41 +148,49 @@ NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -168,7 +259,33 @@ - } +@@ -191,7 +295,7 @@ + nbttagcompound.setInt("SpawnY", this.spawn.getY()); + nbttagcompound.setInt("SpawnZ", this.spawn.getZ()); + nbttagcompound.setBoolean("SpawnForced", this.spawnForced); +- DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.spawnDimension.a()); ++ DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.spawnDimension.a()); // CraftBukkit - decompile error + Logger logger = EntityPlayer.LOGGER; - nbttagcompound.set("recipeBook", this.recipeBook.save()); + logger.getClass(); +@@ -199,8 +303,32 @@ + nbttagcompound.set("SpawnDimension", nbtbase); + }); + } + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit -+ } + ++ } + + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(World world) { + super.spawnIn(world); + if (world == null) { + this.dead = false; + Vec3D position = null; -+ if (this.spawnWorld != null && !this.spawnWorld.equals("")) { -+ CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld); -+ if (cworld != null && this.getBed() != null) { -+ world = cworld.getHandle(); -+ position = EntityHuman.getBed(cworld.getHandle(), this.getBed(), false).orElse(null); ++ if (this.spawnDimension != null) { ++ world = this.getWorldServer().getServer().getHandle().getServer().getWorldServer(this.spawnDimension); ++ if (world != null && this.getSpawn() != null) { ++ position = EntityHuman.getBed((WorldServer) world, this.getSpawn(), false, false).orElse(null); + } + } + if (world == null || position == null) { + world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); -+ position = new Vec3D(world.getSpawn()); ++ position = Vec3D.a(((WorldServer) world).getSpawn()); + } + this.world = world; + this.setPosition(position.getX(), position.getY(), position.getZ()); + } -+ this.dimension = ((WorldServer) this.world).getWorldProvider().getDimensionManager(); + this.playerInteractManager.a((WorldServer) world); } + // CraftBukkit end public void a(int i) { float f = (float) this.getExpToLevel(); -@@ -223,6 +340,11 @@ +@@ -255,6 +383,11 @@ @Override public void tick() { @@ -181,7 +202,7 @@ this.playerInteractManager.a(); --this.invulnerableTicks; if (this.noDamageTicks > 0) { -@@ -290,7 +412,7 @@ +@@ -322,7 +455,7 @@ } if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastSentSaturationZero) { @@ -190,7 +211,7 @@ this.lastHealthSent = this.getHealth(); this.lastFoodSent = this.foodData.getFoodLevel(); this.lastSentSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -321,6 +443,12 @@ +@@ -353,6 +486,12 @@ this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.lastExpTotalScored)); } @@ -203,7 +224,7 @@ if (this.expLevel != this.lastExpLevelScored) { this.lastExpLevelScored = this.expLevel; this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastExpLevelScored)); -@@ -335,6 +463,16 @@ +@@ -367,6 +506,16 @@ CriterionTriggers.p.a(this); } @@ -220,7 +241,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -345,7 +483,8 @@ +@@ -377,7 +526,8 @@ } private void a(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -230,7 +251,7 @@ scoreboardscore.setScore(i); }); } -@@ -353,9 +492,46 @@ +@@ -385,9 +535,46 @@ @Override public void die(DamageSource damagesource) { boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES); @@ -279,10 +300,11 @@ this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> { if (!future.isSuccess()) { -@@ -386,11 +562,18 @@ +@@ -421,12 +608,18 @@ + if (this.world.getGameRules().getBoolean(GameRules.FORGIVE_DEAD_PLAYERS)) { + this.eW(); } - - this.releaseShoulderEntities(); +- - if (!this.isSpectator()) { - this.d(damagesource); + // SPIGOT-5478 must be called manually now @@ -301,7 +323,7 @@ EntityLiving entityliving = this.getKillingEntity(); if (entityliving != null) { -@@ -416,10 +599,12 @@ +@@ -462,10 +655,12 @@ String s = this.getName(); String s1 = entity.getName(); @@ -316,7 +338,7 @@ } else { this.a(StatisticList.MOB_KILLS); } -@@ -437,7 +622,8 @@ +@@ -483,7 +678,8 @@ int i = scoreboardteam.getColor().b(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -326,7 +348,7 @@ } } -@@ -481,16 +667,26 @@ +@@ -527,17 +723,27 @@ } private boolean canPvP() { @@ -337,63 +359,52 @@ @Nullable @Override - public Entity a(DimensionManager dimensionmanager) { + public Entity a(WorldServer worldserver) { - this.worldChangeInvuln = true; + // CraftBukkit start -+ return a(dimensionmanager, TeleportCause.UNKNOWN); ++ return a(worldserver, TeleportCause.UNKNOWN); + } + + @Nullable -+ public Entity a(DimensionManager dimensionmanager, PlayerTeleportEvent.TeleportCause cause) { ++ public Entity a(WorldServer worldserver, PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end + if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 + // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension - DimensionManager dimensionmanager1 = this.dimension; + WorldServer worldserver1 = this.getWorldServer(); + ResourceKey resourcekey = worldserver1.getDimensionKey(); -- if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) { -+ if (dimensionmanager1.getType() == DimensionManager.THE_END && dimensionmanager.getType() == DimensionManager.OVERWORLD) { // CraftBukkit - getType() + if (resourcekey == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) { + this.worldChangeInvuln = true; // CraftBukkit - Moved down from above this.decouple(); this.getWorldServer().removePlayer(this); if (!this.viewingCredits) { -@@ -503,8 +699,10 @@ - } else { - WorldServer worldserver = this.server.getWorldServer(dimensionmanager1); +@@ -548,6 +754,8 @@ -- this.dimension = dimensionmanager; -+ // this.dimension = dimensionmanager; // CraftBukkit - WorldServer worldserver1 = this.server.getWorldServer(dimensionmanager); + return this; + } else { + // CraftBukkit start + /* - WorldData worlddata = worldserver1.getWorldData(); + WorldData worlddata = worldserver.getWorldData(); - this.playerConnection.sendPacket(new PacketPlayOutRespawn(dimensionmanager, WorldData.c(worlddata.getSeed()), worlddata.getType(), this.playerInteractManager.getGameMode())); -@@ -514,6 +712,8 @@ + this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getTypeKey(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); +@@ -557,6 +765,8 @@ playerlist.d(this); - worldserver.removePlayer(this); + worldserver1.removePlayer(this); this.dead = false; + */ + // CraftBukkit end double d0 = this.locX(); double d1 = this.locY(); double d2 = this.locZ(); -@@ -523,6 +723,7 @@ - float f2 = f1; - - worldserver.getMethodProfiler().enter("moving"); -+ if (worldserver1 == null) { } else // CraftBukkit - empty to fall through to null to event - if (dimensionmanager1 == DimensionManager.OVERWORLD && dimensionmanager == DimensionManager.NETHER) { - this.cr = this.getPositionVector(); - d0 /= 8.0D; -@@ -540,7 +741,26 @@ - f = 0.0F; +@@ -593,7 +803,26 @@ + } } - this.setPositionRotation(d0, d1, d2, f1, f); + // CraftBukkit start + Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = (worldserver1 == null) ? null : new Location(worldserver1.getWorld(), d0, d1, d2, f1, f); -+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, 128, true, dimensionmanager.getType() == DimensionManager.THE_END ? 0 : 16); ++ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), d0, d1, d2, f1, f); ++ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, 128, true, resourcekey == World.THE_END ? 0 : 16); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled() || event.getTo() == null) { + return null; @@ -403,64 +414,41 @@ + if (exit == null) { + return null; + } -+ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); ++ worldserver = ((CraftWorld) exit.getWorld()).getHandle(); + d0 = exit.getX(); + d1 = exit.getY(); + d2 = exit.getZ(); + // CraftBukkit end + + // this.setPositionRotation(d0, d1, d2, f1, f); // CraftBukkit - PlayerTeleportEvent handles position changes - worldserver.getMethodProfiler().exit(); - worldserver.getMethodProfiler().enter("placing"); - double d4 = Math.min(-2.9999872E7D, worldserver1.getWorldBorder().c() + 16.0D); -@@ -550,13 +770,19 @@ + worldserver1.getMethodProfiler().exit(); + worldserver1.getMethodProfiler().enter("placing"); + double d4 = Math.min(-2.9999872E7D, worldserver.getWorldBorder().e() + 16.0D); +@@ -604,25 +833,74 @@ - d0 = MathHelper.a(d0, d4, d6); - d2 = MathHelper.a(d2, d5, d7); + d0 = MathHelper.a(d0, d4, d5); + d2 = MathHelper.a(d2, d3, d6); - this.setPositionRotation(d0, d1, d2, f1, f); -- if (dimensionmanager == DimensionManager.THE_END) { -- int i = MathHelper.floor(this.locX()); -- int j = MathHelper.floor(this.locY()) - 1; -- int k = MathHelper.floor(this.locZ()); + // this.setPositionRotation(d0, d1, d2, f1, f); // CraftBukkit - PlayerTeleportEvent handles position changes + // CraftBukkit start - PlayerPortalEvent implementation + Vec3D exitVelocity = Vec3D.a; + BlockPosition exitPosition = new BlockPosition(d0, d1, d2); -+ if (dimensionmanager.getType() == DimensionManager.THE_END) { // CraftBukkit - getType() + if (worldserver.getDimensionKey() == World.THE_END) { +- int i = MathHelper.floor(this.locX()); +- int j = MathHelper.floor(this.locY()) - 1; +- int k = MathHelper.floor(this.locZ()); +- +- WorldServer.a(worldserver); +- this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F); +- this.setMot(Vec3D.a); +- } else if (!worldserver.getTravelAgent().findAndTeleport(this, f2)) { +- worldserver.getTravelAgent().createPortal(this); +- worldserver.getTravelAgent().findAndTeleport(this, f2); + int i = exitPosition.getX(); + int j = exitPosition.getY() - 1; + int k = exitPosition.getZ(); + if (event.getCanCreatePortal()) { -+ // CraftBukkit end - boolean flag = true; - boolean flag1 = false; -+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver1); // CraftBukkit - Use BlockStateListPopulator - - for (int l = -2; l <= 2; ++l) { - for (int i1 = -2; i1 <= 2; ++i1) { -@@ -566,23 +792,80 @@ - int i2 = k + i1 * 0 - l * 1; - boolean flag2 = j1 < 0; - -- worldserver1.setTypeUpdate(new BlockPosition(k1, l1, i2), flag2 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData()); -+ blockList.setTypeAndData(new BlockPosition(k1, l1, i2), flag2 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData(), 3); // CraftBukkit - } - } - } - -- this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F); -- this.setMot(Vec3D.a); -- } else if (!worldserver1.getTravelAgent().findAndTeleport(this, f2)) { -- worldserver1.getTravelAgent().createPortal(this); -- worldserver1.getTravelAgent().findAndTeleport(this, f2); -+ // CraftBukkit start -+ org.bukkit.World bworld = worldserver1.getWorld(); -+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List) (List) blockList.getList(), bworld, this.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); -+ -+ this.world.getServer().getPluginManager().callEvent(portalEvent); -+ if (!portalEvent.isCancelled()) { -+ blockList.updateList(); -+ } ++ WorldServer.a(worldserver, this); + } + // handled below for PlayerTeleportEvent + // this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F); @@ -470,10 +458,10 @@ + // this.setMot(Vec3D.a); + exitVelocity = Vec3D.a; + } else { -+ ShapeDetector.Shape portalShape = worldserver1.getTravelAgent().findAndTeleport(this, exitPosition, f2, event.getSearchRadius(), true); ++ ShapeDetector.Shape portalShape = worldserver.getTravelAgent().findAndTeleport(this, exitPosition, f2, event.getSearchRadius(), true); + if (portalShape == null && event.getCanCreatePortal()) { -+ if (worldserver1.getTravelAgent().createPortal(this, exitPosition, event.getCreationRadius())) { // Only check for new portal if creation succeeded -+ portalShape = worldserver1.getTravelAgent().findAndTeleport(this, exitPosition, f2, event.getSearchRadius(), true); ++ if (worldserver.getTravelAgent().createPortal(this, exitPosition, event.getCreationRadius())) { // Only check for new portal if creation succeeded ++ portalShape = worldserver.getTravelAgent().findAndTeleport(this, exitPosition, f2, event.getSearchRadius(), true); + } + } + // Check if portal was found @@ -489,7 +477,7 @@ + // CraftBukkit end } - worldserver.getMethodProfiler().exit(); + worldserver1.getMethodProfiler().exit(); + // CraftBukkit start - PlayerTeleportEvent + PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause); + Bukkit.getServer().getPluginManager().callEvent(tpEvent); @@ -501,32 +489,29 @@ + if (exit == null) { + return null; + } -+ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); ++ worldserver = ((CraftWorld) exit.getWorld()).getHandle(); + this.worldChangeInvuln = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds -+ dimensionmanager = worldserver1.getWorldProvider().getDimensionManager(); + -+ this.dimension = dimensionmanager; -+ -+ this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.worldProvider.getDimensionManager().getType(), WorldData.c(this.world.getWorldData().getSeed()), this.world.getWorldData().getType(), this.playerInteractManager.getGameMode())); ++ this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getTypeKey(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); + this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(this.world.getDifficulty(), this.world.getWorldData().isDifficultyLocked())); + PlayerList playerlist = this.server.getPlayerList(); + + playerlist.d(this); -+ worldserver.removePlayer(this); ++ worldserver1.removePlayer(this); + this.dead = false; + + this.setMot(exitVelocity); + // CraftBukkit end - this.spawnIn(worldserver1); - worldserver1.addPlayerPortal(this); - this.triggerDimensionAdvancements(worldserver); + this.spawnIn(worldserver); + worldserver.addPlayerPortal(this); + this.triggerDimensionAdvancements(worldserver1); - this.playerConnection.a(this.locX(), this.locY(), this.locZ(), f1, f); + this.playerConnection.teleport(exit); // CraftBukkit - use internal teleport without event + this.playerConnection.syncPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) - this.playerInteractManager.a(worldserver1); + this.playerInteractManager.a(worldserver); this.playerConnection.sendPacket(new PacketPlayOutAbilities(this.abilities)); - playerlist.a(this, worldserver1); -@@ -599,6 +882,11 @@ + playerlist.a(this, worldserver); +@@ -639,6 +917,11 @@ this.lastSentExp = -1; this.lastHealthSent = -1.0F; this.lastFoodSent = -1; @@ -538,26 +523,69 @@ return this; } } -@@ -640,9 +928,16 @@ +@@ -680,10 +963,8 @@ this.activeContainer.c(); } - @Override -+ @Override - public Either sleep(BlockPosition blockposition) { -- return super.sleep(blockposition).ifRight((unit) -> { -+ // CraftBukkit start - add force parameter -+ return this.sleep(blockposition, false); +- public Either sleep(BlockPosition blockposition) { +- EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); +- ++ // CraftBukkit start - moved bed result checks from below into separate method ++ private Either getBedResult(BlockPosition blockposition, EnumDirection enumdirection) { + if (!this.isSleeping() && this.isAlive()) { + if (!this.world.getDimensionManager().isNatural()) { + return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); +@@ -709,7 +990,36 @@ + } + } + +- Either either = super.sleep(blockposition).ifRight((unit) -> { ++ return Either.right(Unit.INSTANCE); ++ } ++ } ++ } else { ++ return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); ++ } + } + + @Override + public Either sleep(BlockPosition blockposition, boolean force) { ++ EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); ++ Either bedResult = this.getBedResult(blockposition, enumdirection); ++ ++ if (bedResult.left().orElse(null) == EntityHuman.EnumBedResult.OTHER_PROBLEM) { ++ return bedResult; // return immediately if the result is not bypassable by plugins ++ } ++ ++ if (force) { ++ bedResult = Either.right(Unit.INSTANCE); ++ } ++ ++ bedResult = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedEnterEvent(this, blockposition, bedResult); ++ if (bedResult.left().isPresent()) { ++ return bedResult; ++ } ++ ++ { ++ { ++ { ++ Either either = super.sleep(blockposition, force).ifRight((unit) -> { + this.a(StatisticList.SLEEP_IN_BED); + CriterionTriggers.q.a(this); + }); +@@ -718,9 +1028,8 @@ + return either; + } + } +- } else { +- return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); + } + // CraftBukkit end -+ return super.sleep(blockposition, force).ifRight((unit) -> { - this.a(StatisticList.SLEEP_IN_BED); - CriterionTriggers.q.a(this); - }); -@@ -650,6 +945,7 @@ + } + + @Override +@@ -747,6 +1056,7 @@ @Override public void wakeup(boolean flag, boolean flag1) { @@ -565,7 +593,7 @@ if (this.isSleeping()) { this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2)); } -@@ -723,8 +1019,9 @@ +@@ -818,8 +1128,9 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -576,7 +604,7 @@ } @Override -@@ -739,6 +1036,24 @@ +@@ -834,6 +1145,24 @@ this.nextContainerCounter(); Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this); @@ -600,8 +628,8 @@ + // CraftBukkit end if (container == null) { if (this.isSpectator()) { - this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); -@@ -746,9 +1061,11 @@ + this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true); +@@ -841,9 +1170,11 @@ return OptionalInt.empty(); } else { @@ -615,7 +643,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -761,13 +1078,24 @@ +@@ -856,13 +1187,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -642,7 +670,7 @@ this.activeContainer.addSlotListener(this); } -@@ -812,6 +1140,11 @@ +@@ -907,6 +1249,11 @@ public void a(Container container, NonNullList nonnulllist) { this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); @@ -654,15 +682,15 @@ } @Override -@@ -821,6 +1154,7 @@ +@@ -916,6 +1263,7 @@ @Override public void closeInventory() { + CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); - this.m(); + this.o(); } -@@ -855,7 +1189,7 @@ +@@ -950,7 +1298,7 @@ @Override public void a(Statistic statistic, int i) { this.serverStatisticManager.b(this, statistic, i); @@ -671,7 +699,7 @@ scoreboardscore.addScore(i); }); } -@@ -863,7 +1197,7 @@ +@@ -958,7 +1306,7 @@ @Override public void a(Statistic statistic) { this.serverStatisticManager.setStatistic(this, statistic, 0); @@ -680,33 +708,32 @@ } @Override -@@ -912,8 +1246,17 @@ +@@ -1007,7 +1355,16 @@ public void triggerHealthUpdate() { this.lastHealthSent = -1.0E8F; + this.lastSentExp = -1; // CraftBukkit - Added to reset - } - ++ } ++ + // CraftBukkit start - Support multi-line messages + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) { -+ this.sendMessage(component); ++ this.sendMessage(component, SystemUtils.b); + } -+ } + } + // CraftBukkit end -+ + @Override public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT)); -@@ -967,12 +1310,14 @@ +@@ -1062,12 +1419,14 @@ this.lastSentExp = -1; this.lastHealthSent = -1.0F; this.lastFoodSent = -1; - this.recipeBook.a((RecipeBook) entityplayer.recipeBook); + // this.recipeBook.a((RecipeBook) entityplayer.recipeBook); // CraftBukkit this.removeQueue.addAll(entityplayer.removeQueue); - this.cm = entityplayer.cm; - this.cr = entityplayer.cr; + this.ck = entityplayer.ck; + this.cp = entityplayer.cp; this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); this.setShoulderEntityRight(entityplayer.getShoulderEntityRight()); + @@ -714,7 +741,7 @@ } @Override -@@ -1040,6 +1385,18 @@ +@@ -1135,6 +1494,18 @@ @Override public void a(EnumGamemode enumgamemode) { @@ -731,27 +758,29 @@ + // CraftBukkit end + this.playerInteractManager.setGameMode(enumgamemode); - this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); + this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.d, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -1090,6 +1447,17 @@ +@@ -1184,7 +1555,19 @@ + return s; } ++ public String locale = "en_us"; // CraftBukkit - add, lowercase public void a(PacketPlayInSettings packetplayinsettings) { + // CraftBukkit start + if (getMainHand() != packetplayinsettings.getMainHand()) { + PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); + this.server.server.getPluginManager().callEvent(event); + } -+ if (!this.locale.equals(packetplayinsettings.b())) { -+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.b()); ++ if (!this.locale.equals(packetplayinsettings.locale)) { ++ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.locale); + this.server.server.getPluginManager().callEvent(event); + } + this.clientViewDistance = packetplayinsettings.viewDistance; + // CraftBukkit end - this.locale = packetplayinsettings.b(); - this.ch = packetplayinsettings.d(); - this.ci = packetplayinsettings.e(); -@@ -1126,13 +1494,13 @@ + this.cf = packetplayinsettings.d(); + this.cg = packetplayinsettings.e(); + this.getDataWatcher().set(EntityPlayer.bp, (byte) packetplayinsettings.f()); +@@ -1220,13 +1603,13 @@ if (entity instanceof EntityHuman) { this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()})); } else { @@ -767,7 +796,7 @@ } @Override -@@ -1156,7 +1524,7 @@ +@@ -1250,7 +1633,7 @@ this.spectatedEntity = (Entity) (entity == null ? this : entity); if (entity1 != this.spectatedEntity) { this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity)); @@ -776,7 +805,7 @@ } } -@@ -1185,7 +1553,7 @@ +@@ -1279,7 +1662,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -785,7 +814,7 @@ } @Override -@@ -1206,9 +1574,16 @@ +@@ -1300,9 +1683,16 @@ return this.advancementDataPlayer; } @@ -802,7 +831,7 @@ if (worldserver == this.world) { this.playerConnection.a(d0, d1, d2, f, f1); } else { -@@ -1231,6 +1606,9 @@ +@@ -1323,6 +1713,9 @@ this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().updateClient(this); } @@ -812,7 +841,7 @@ } -@@ -1285,4 +1663,144 @@ +@@ -1409,4 +1802,144 @@ return entityitem; } } @@ -847,9 +876,9 @@ + } + + if (type == WeatherType.DOWNFALL) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0)); ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0)); + } else { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0)); ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.c, 0)); + } + } + @@ -860,20 +889,20 @@ + if (this.weather == null) { + // Vanilla + if (oldRain != newRain) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, newRain)); ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, newRain)); + } + } else { + // Plugin + if (pluginRainPositionPrevious != pluginRainPosition) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, pluginRainPosition)); ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, pluginRainPosition)); + } + } + + if (oldThunder != newThunder) { + if (weather == WeatherType.DOWNFALL || weather == null) { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, newThunder)); ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, newThunder)); + } else { -+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, 0)); ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, 0)); + } + } + } diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch index 670e591010..e83e891373 100644 --- a/nms-patches/EntityPotion.patch +++ b/nms-patches/EntityPotion.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityPotion.java +++ b/net/minecraft/server/EntityPotion.java -@@ -6,6 +6,13 @@ +@@ -4,6 +4,13 @@ + import java.util.List; + import java.util.function.Predicate; import javax.annotation.Nullable; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.HashMap; +import java.util.Map; @@ -12,9 +12,9 @@ +import org.bukkit.entity.LivingEntity; +// CraftBukkit end - public class EntityPotion extends EntityProjectile { + public class EntityPotion extends EntityProjectileThrowable { -@@ -79,7 +86,7 @@ +@@ -69,7 +76,7 @@ if (flag) { this.splash(); @@ -23,7 +23,7 @@ if (this.isLingering()) { this.a(itemstack, potionregistry); } else { -@@ -116,6 +123,7 @@ +@@ -106,6 +113,7 @@ private void a(List list, @Nullable Entity entity) { AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); List list1 = this.world.a(EntityLiving.class, axisalignedbb); @@ -31,7 +31,7 @@ if (!list1.isEmpty()) { Iterator iterator = list1.iterator(); -@@ -133,21 +141,46 @@ +@@ -123,21 +131,46 @@ d1 = 1.0D; } @@ -42,7 +42,20 @@ + } + } + } -+ + +- while (iterator1.hasNext()) { +- MobEffect mobeffect = (MobEffect) iterator1.next(); +- MobEffectList mobeffectlist = mobeffect.getMobEffect(); +- +- if (mobeffectlist.isInstant()) { +- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1); +- } else { +- int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); +- +- if (i > 20) { +- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles())); +- } +- } + org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected); + if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process + for (LivingEntity victim : event.getAffectedEntities()) { @@ -68,20 +81,7 @@ + } + } + // CraftBukkit end - -- while (iterator1.hasNext()) { -- MobEffect mobeffect = (MobEffect) iterator1.next(); -- MobEffectList mobeffectlist = mobeffect.getMobEffect(); -- -- if (mobeffectlist.isInstant()) { -- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1); -- } else { -- int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); -- -- if (i > 20) { -- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles())); -- } -- } ++ + if (mobeffectlist.isInstant()) { + mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1); + } else { @@ -92,7 +92,7 @@ } } } -@@ -179,7 +212,14 @@ +@@ -173,7 +206,14 @@ entityareaeffectcloud.setColor(nbttagcompound.getInt("CustomPotionColor")); } @@ -108,22 +108,24 @@ } public boolean isLingering() { -@@ -191,10 +231,18 @@ - Block block = iblockdata.getBlock(); +@@ -184,11 +224,19 @@ + IBlockData iblockdata = this.world.getType(blockposition); - if (block == Blocks.FIRE) { -- this.world.douseFire((EntityHuman) null, blockposition.shift(enumdirection), enumdirection.opposite()); + if (iblockdata.a((Tag) TagsBlock.FIRE)) { +- this.world.a(blockposition, false); + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.shift(enumdirection), Blocks.AIR.getBlockData()).isCancelled()) { -+ this.world.douseFire((EntityHuman) null, blockposition.shift(enumdirection), enumdirection.opposite()); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { ++ this.world.a(blockposition, false); + } + // CraftBukkit end - } else if (block == Blocks.CAMPFIRE && (Boolean) iblockdata.get(BlockCampfire.b)) { + } else if (BlockCampfire.g(iblockdata)) { - this.world.a((EntityHuman) null, 1009, blockposition, 0); +- BlockCampfire.c((GeneratorAccess) this.world, blockposition, iblockdata); - this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.b, false)); + // CraftBukkit start + if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.set(BlockCampfire.b, false)).isCancelled()) { // PAIL rename LIT + this.world.a((EntityHuman) null, 1009, blockposition, 0); ++ BlockCampfire.c((GeneratorAccess) this.world, blockposition, iblockdata); + this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.b, false)); + } + // CraftBukkit end diff --git a/nms-patches/EntityProjectile.patch b/nms-patches/EntityProjectile.patch index a079704758..56393daeaa 100644 --- a/nms-patches/EntityProjectile.patch +++ b/nms-patches/EntityProjectile.patch @@ -1,31 +1,14 @@ --- a/net/minecraft/server/EntityProjectile.java +++ b/net/minecraft/server/EntityProjectile.java -@@ -32,6 +32,7 @@ - this(entitytypes, entityliving.locX(), entityliving.getHeadY() - 0.10000000149011612D, entityliving.locZ(), world); - this.shooter = entityliving; - this.shooterId = entityliving.getUniqueID(); -+ this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit - } +@@ -42,6 +42,11 @@ - public void a(Entity entity, float f, float f1, float f2, float f3, float f4) { -@@ -83,7 +84,7 @@ - break; - } - -- if (this.shooter != null && this.ticksLived < 2 && this.ap == null) { -+ if (this.shooter != null && this.ticksLived < 2 && this.ap == null && this.shooter == entity) { // CraftBukkit - MC-88491 - this.ap = entity; - this.aq = 3; - break; -@@ -103,6 +104,11 @@ - this.c(((MovingObjectPositionBlock) movingobjectposition).getBlockPosition()); - } else { - this.a(movingobjectposition); -+ // CraftBukkit start -+ if (this.dead) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); -+ } -+ // CraftBukkit end - } + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && !flag) { + this.a(movingobjectposition); ++ // CraftBukkit start ++ if (this.dead) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); ++ } ++ // CraftBukkit end } + Vec3D vec3d = this.getMot(); diff --git a/nms-patches/EntityProjectileThrowable.patch b/nms-patches/EntityProjectileThrowable.patch index 73c0fe5551..f6e0b5cbca 100644 --- a/nms-patches/EntityProjectileThrowable.patch +++ b/nms-patches/EntityProjectileThrowable.patch @@ -3,26 +3,24 @@ @@ -18,8 +18,8 @@ public void setItem(ItemStack itemstack) { - if (itemstack.getItem() != this.i() || itemstack.hasTag()) { -- this.getDataWatcher().set(EntityProjectileThrowable.e, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { + if (itemstack.getItem() != this.getDefaultItem() || itemstack.hasTag()) { +- this.getDataWatcher().set(EntityProjectileThrowable.b, SystemUtils.a((Object) itemstack.cloneItemStack(), (itemstack1) -> { - itemstack1.setCount(1); -+ this.getDataWatcher().set(EntityProjectileThrowable.e, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error ++ this.getDataWatcher().set(EntityProjectileThrowable.b, SystemUtils.a(itemstack.cloneItemStack(), (itemstack1) -> { // CraftBukkit - decompile error + if (!itemstack1.isEmpty()) itemstack1.setCount(1); // CraftBukkit })); } -@@ -27,7 +27,13 @@ +@@ -27,6 +27,12 @@ - protected abstract Item i(); + protected abstract Item getDefaultItem(); -- protected ItemStack getItem() { + // CraftBukkit start -+ public Item getDefaultItem() { -+ return i(); ++ public Item getDefaultItemPublic() { ++ return getDefaultItem(); + } + // CraftBukkit end + -+ public ItemStack getItem() { // PAIL protected -> public - return (ItemStack) this.getDataWatcher().get(EntityProjectileThrowable.e); + public ItemStack getItem() { + return (ItemStack) this.getDataWatcher().get(EntityProjectileThrowable.b); } - diff --git a/nms-patches/EntityPufferFish.patch b/nms-patches/EntityPufferFish.patch index 4cf6c70394..10c8f55b77 100644 --- a/nms-patches/EntityPufferFish.patch +++ b/nms-patches/EntityPufferFish.patch @@ -6,13 +6,13 @@ if (entityinsentient.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) { - entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0)); + entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit - this.a(SoundEffects.ENTITY_PUFFER_FISH_STING, 1.0F, 1.0F); + this.playSound(SoundEffects.ENTITY_PUFFER_FISH_STING, 1.0F, 1.0F); } -@@ -126,7 +126,7 @@ +@@ -129,7 +129,7 @@ + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.j, 0.0F)); + } - if (entityhuman instanceof EntityPlayer && i > 0 && entityhuman.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) { - ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutGameStateChange(9, 0.0F)); - entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0)); + entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch index c79a4394e8..f05dcee267 100644 --- a/nms-patches/EntityRabbit.patch +++ b/nms-patches/EntityRabbit.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityRabbit.java @@ -17,8 +17,14 @@ super(entitytypes, world); - this.bq = new EntityRabbit.ControllerJumpRabbit(this); + this.bp = new EntityRabbit.ControllerJumpRabbit(this); this.moveController = new EntityRabbit.ControllerMoveRabbit(this); + this.initializePathFinderGoals(); // CraftBukkit - moved code + } @@ -15,7 +15,7 @@ @Override protected void initPathfinder() { -@@ -286,7 +292,7 @@ +@@ -285,7 +291,7 @@ if (i == 99) { this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D); this.goalSelector.a(4, new EntityRabbit.PathfinderGoalKillerRabbitMeleeAttack(this)); @@ -24,7 +24,7 @@ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityWolf.class, true)); if (!this.hasCustomName()) { -@@ -402,9 +408,23 @@ +@@ -401,9 +407,23 @@ Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE); if (integer == 0) { diff --git a/nms-patches/EntityRaider.patch b/nms-patches/EntityRaider.patch index fed93f7f42..47e3e224fe 100644 --- a/nms-patches/EntityRaider.patch +++ b/nms-patches/EntityRaider.patch @@ -9,7 +9,7 @@ } } } -@@ -397,7 +397,7 @@ +@@ -398,7 +398,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); @@ -18,16 +18,16 @@ } } -@@ -414,7 +414,7 @@ +@@ -415,7 +415,7 @@ while (iterator.hasNext()) { EntityRaider entityraider = (EntityRaider) iterator.next(); - entityraider.setGoalTarget(entityliving); + entityraider.setGoalTarget(this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit - entityraider.q(true); + entityraider.setAggressive(true); } -@@ -488,7 +488,7 @@ +@@ -489,7 +489,7 @@ private final T b; diff --git a/nms-patches/EntityRavager.patch b/nms-patches/EntityRavager.patch index c6c1265c8c..3cb559e0d7 100644 --- a/nms-patches/EntityRavager.patch +++ b/nms-patches/EntityRavager.patch @@ -9,7 +9,7 @@ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, true)); this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); -@@ -126,7 +126,7 @@ +@@ -119,7 +119,7 @@ IBlockData iblockdata = this.world.getType(blockposition); Block block = iblockdata.getBlock(); diff --git a/nms-patches/EntitySheep.patch b/nms-patches/EntitySheep.patch index bab2ee959d..0f8e9d9b28 100644 --- a/nms-patches/EntitySheep.patch +++ b/nms-patches/EntitySheep.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySheep.java +++ b/net/minecraft/server/EntitySheep.java -@@ -9,10 +9,16 @@ +@@ -8,10 +8,16 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -10,38 +10,37 @@ +import org.bukkit.inventory.InventoryView; +// CraftBukkit end + - public class EntitySheep extends EntityAnimal { + public class EntitySheep extends EntityAnimal implements IShearable { - private static final DataWatcherObject bw = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); -- private static final Map bx = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { -+ private static final Map bx = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error + private static final DataWatcherObject bv = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); +- private static final Map bw = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { ++ private static final Map bw = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL); enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL); enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL); -@@ -141,6 +147,12 @@ - ItemStack itemstack = entityhuman.b(enumhand); +@@ -138,6 +144,11 @@ - if (itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { -+ // CraftBukkit start -+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { -+ return false; -+ } -+ // CraftBukkit end -+ - this.shear(); - if (!this.world.isClientSide) { + if (itemstack.getItem() == Items.SHEARS) { + if (!this.world.isClientSide && this.canShear()) { ++ // CraftBukkit start ++ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.shear(SoundCategory.PLAYERS); itemstack.damage(1, entityhuman, (entityhuman1) -> { -@@ -160,7 +172,9 @@ - int i = 1 + this.random.nextInt(3); + entityhuman1.broadcastItemBreak(enumhand); +@@ -158,7 +169,9 @@ + int i = 1 + this.random.nextInt(3); - for (int j = 0; j < i; ++j) { -+ this.forceDrops = true; // CraftBukkit - EntityItem entityitem = this.a((IMaterial) EntitySheep.bx.get(this.getColor()), 1); -+ this.forceDrops = false; // CraftBukkit + for (int j = 0; j < i; ++j) { ++ this.forceDrops = true; // CraftBukkit + EntityItem entityitem = this.a((IMaterial) EntitySheep.bw.get(this.getColor()), 1); ++ this.forceDrops = false; // CraftBukkit - if (entityitem != null) { - entityitem.setMot(entityitem.getMot().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); -@@ -247,6 +261,12 @@ + if (entityitem != null) { + entityitem.setMot(entityitem.getMot().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); +@@ -248,6 +261,12 @@ @Override public void blockEaten() { @@ -54,7 +53,7 @@ this.setSheared(false); if (this.isBaby()) { this.setAge(60); -@@ -265,7 +285,7 @@ +@@ -266,7 +285,7 @@ EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); InventoryCrafting inventorycrafting = a(enumcolor, enumcolor1); @@ -63,7 +62,7 @@ return recipecrafting.a(inventorycrafting); }).map(ItemStack::getItem); -@@ -283,10 +303,18 @@ +@@ -284,10 +303,18 @@ public boolean canUse(EntityHuman entityhuman) { return false; } diff --git a/nms-patches/EntityShulker.patch b/nms-patches/EntityShulker.patch index c7db62e8a0..686fb898bd 100644 --- a/nms-patches/EntityShulker.patch +++ b/nms-patches/EntityShulker.patch @@ -11,7 +11,7 @@ public class EntityShulker extends EntityGolem implements IMonster { -@@ -46,7 +50,7 @@ +@@ -31,7 +35,7 @@ this.goalSelector.a(4, new EntityShulker.a()); this.goalSelector.a(7, new EntityShulker.e()); this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); @@ -20,27 +20,24 @@ this.targetSelector.a(2, new EntityShulker.d(this)); this.targetSelector.a(3, new EntityShulker.c(this)); } -@@ -300,8 +304,17 @@ - EnumDirection enumdirection = aenumdirection[k]; +@@ -279,6 +283,16 @@ + EnumDirection enumdirection = this.g(blockposition1); - if (this.world.a(blockposition1.shift(enumdirection), (Entity) this)) { -- this.datawatcher.set(EntityShulker.b, enumdirection); -- flag = true; -+ // CraftBukkit start -+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.world.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ())); -+ this.world.getServer().getPluginManager().callEvent(teleport); -+ if (!teleport.isCancelled()) { -+ Location to = teleport.getTo(); -+ blockposition1 = new BlockPosition(to.getX(), to.getY(), to.getZ()); -+ -+ this.datawatcher.set(EntityShulker.b, enumdirection); -+ flag = true; -+ } -+ // CraftBukkit end - break; - } - } -@@ -344,6 +357,7 @@ + if (enumdirection != null) { ++ // CraftBukkit start ++ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.world.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ())); ++ this.world.getServer().getPluginManager().callEvent(teleport); ++ if (!teleport.isCancelled()) { ++ Location to = teleport.getTo(); ++ blockposition1 = new BlockPosition(to.getX(), to.getY(), to.getZ()); ++ } else { ++ return false; ++ } ++ // CraftBukkit end + this.datawatcher.set(EntityShulker.b, enumdirection); + this.playSound(SoundEffects.ENTITY_SHULKER_TELEPORT, 1.0F, 1.0F); + this.datawatcher.set(EntityShulker.c, Optional.of(blockposition1)); +@@ -319,6 +333,7 @@ } this.f((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); diff --git a/nms-patches/EntityShulkerBullet.patch b/nms-patches/EntityShulkerBullet.patch index d90a5b70d7..3c5a3ddc9b 100644 --- a/nms-patches/EntityShulkerBullet.patch +++ b/nms-patches/EntityShulkerBullet.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityShulkerBullet.java +++ b/net/minecraft/server/EntityShulkerBullet.java -@@ -40,8 +40,29 @@ +@@ -34,8 +34,21 @@ this.target = entity; this.dir = EnumDirection.UP; this.a(enumdirection_enumaxis); @@ -8,14 +8,6 @@ } + // CraftBukkit start -+ public EntityLiving getShooter() { -+ return this.shooter; -+ } -+ -+ public void setShooter(EntityLiving e) { -+ this.shooter = e; -+ } -+ + public Entity getTarget() { + return this.target; + } @@ -30,20 +22,12 @@ @Override public SoundCategory getSoundCategory() { return SoundCategory.HOSTILE; -@@ -298,6 +319,7 @@ - } - - protected void a(MovingObjectPosition movingobjectposition) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event - if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { - Entity entity = ((MovingObjectPositionEntity) movingobjectposition).getEntity(); - boolean flag = entity.damageEntity(DamageSource.a(this, this.shooter).c(), 4.0F); -@@ -305,7 +327,7 @@ - if (flag) { - this.a(this.shooter, entity); - if (entity instanceof EntityLiving) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit - } +@@ -255,7 +268,7 @@ + if (flag) { + this.a(entityliving, entity); + if (entity instanceof EntityLiving) { +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200)); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } - } else { + } + diff --git a/nms-patches/EntitySilverfish.patch b/nms-patches/EntitySilverfish.patch index e6b810bf44..87febd5632 100644 --- a/nms-patches/EntitySilverfish.patch +++ b/nms-patches/EntitySilverfish.patch @@ -9,19 +9,19 @@ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); } -@@ -160,6 +160,11 @@ +@@ -156,6 +156,11 @@ IBlockData iblockdata = world.getType(blockposition); if (BlockMonsterEggs.h(iblockdata)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.d(iblockdata.getBlock())).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.c(iblockdata.getBlock())).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, BlockMonsterEggs.d(iblockdata.getBlock()), 3); + world.setTypeAndData(blockposition, BlockMonsterEggs.c(iblockdata.getBlock()), 3); this.a.doSpawnEffect(); this.a.die(); -@@ -206,6 +211,11 @@ +@@ -202,6 +207,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockMonsterEggs) { diff --git a/nms-patches/EntitySkeletonAbstract.patch b/nms-patches/EntitySkeletonAbstract.patch index 11a5d0c0be..69648a2d60 100644 --- a/nms-patches/EntitySkeletonAbstract.patch +++ b/nms-patches/EntitySkeletonAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySkeletonAbstract.java +++ b/net/minecraft/server/EntitySkeletonAbstract.java -@@ -156,8 +156,19 @@ +@@ -154,8 +154,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)); @@ -15,7 +15,7 @@ + world.addEntity(entityarrow); + } + // CraftBukkit end - this.a(SoundEffects.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); + this.playSound(SoundEffects.ENTITY_SKELETON_SHOOT, 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/EntitySkeletonWither.patch b/nms-patches/EntitySkeletonWither.patch index 0080cae398..a907a477d5 100644 --- a/nms-patches/EntitySkeletonWither.patch +++ b/nms-patches/EntitySkeletonWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySkeletonWither.java +++ b/net/minecraft/server/EntitySkeletonWither.java -@@ -74,7 +74,7 @@ +@@ -80,7 +80,7 @@ return false; } else { if (entity instanceof EntityLiving) { diff --git a/nms-patches/EntitySlime.patch b/nms-patches/EntitySlime.patch index 29b456d8db..b155a96a5e 100644 --- a/nms-patches/EntitySlime.patch +++ b/nms-patches/EntitySlime.patch @@ -14,7 +14,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { -@@ -153,7 +160,7 @@ +@@ -147,7 +154,7 @@ @Override public EntityTypes getEntityType() { @@ -23,16 +23,16 @@ } @Override -@@ -163,6 +170,19 @@ - if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) { - int j = 2 + this.random.nextInt(3); +@@ -161,6 +168,19 @@ + int j = i / 2; + int k = 2 + this.random.nextInt(3); + // CraftBukkit start -+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j); ++ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled() && event.getCount() > 0) { -+ j = event.getCount(); ++ k = event.getCount(); + } else { + super.die(); + return; @@ -40,15 +40,14 @@ + List slimes = new ArrayList<>(j); + // CraftBukkit end + - for (int k = 0; k < j; ++k) { - float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F; - float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F; -@@ -179,8 +199,18 @@ + for (int l = 0; l < k; ++l) { + float f1 = ((float) (l % 2) - 0.5F) * f; + float f2 = ((float) (l / 2) - 0.5F) * f; +@@ -175,8 +195,17 @@ entityslime.setInvulnerable(this.isInvulnerable()); - entityslime.setSize(i / 2, true); - entityslime.setPositionRotation(this.locX() + (double) f, this.locY() + 0.5D, this.locZ() + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); + entityslime.setSize(j, true); + entityslime.setPositionRotation(this.locX() + (double) f1, this.locY() + 0.5D, this.locZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F); - this.world.addEntity(entityslime); -+ + slimes.add(entityslime); // CraftBukkit + } + diff --git a/nms-patches/EntitySmallFireball.patch b/nms-patches/EntitySmallFireball.patch index 00a87999f9..b166c73282 100644 --- a/nms-patches/EntitySmallFireball.patch +++ b/nms-patches/EntitySmallFireball.patch @@ -13,7 +13,7 @@ public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world); + // CraftBukkit start -+ if (this.shooter != null && this.shooter instanceof EntityInsentient) { ++ if (this.getShooter() != null && this.getShooter() instanceof EntityInsentient) { + isIncendiary = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); + } + // CraftBukkit end @@ -21,34 +21,33 @@ public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) { @@ -24,7 +31,16 @@ - if (!entity.isFireProof()) { - int i = entity.ad(); + Entity entity1 = this.getShooter(); + int i = entity.getFireTicks(); -- entity.setOnFire(5); -+ // CraftBukkit start - Entity damage by entity event + combust event -+ if (isIncendiary) { -+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5); -+ entity.world.getServer().getPluginManager().callEvent(event); +- entity.setOnFire(5); ++ // CraftBukkit start - Entity damage by entity event + combust event ++ if (isIncendiary) { ++ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5); ++ entity.world.getServer().getPluginManager().callEvent(event); + -+ if (!event.isCancelled()) { -+ entity.setOnFire(event.getDuration(), false); -+ } ++ if (!event.isCancelled()) { ++ entity.setOnFire(event.getDuration(), false); + } -+ // CraftBukkit end - boolean flag = entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F); ++ } ++ // CraftBukkit end + boolean flag = entity.damageEntity(DamageSource.fireball(this, entity1), 5.0F); - if (flag) { -@@ -33,11 +49,11 @@ - entity.g(i); - } - } -- } else if (this.shooter == null || !(this.shooter instanceof EntityInsentient) || this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { -+ } else if (isIncendiary) { // CraftBukkit - MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; + if (!flag) { +@@ -43,10 +59,10 @@ + if (!this.world.isClientSide) { + Entity entity = this.getShooter(); + +- if (entity == null || !(entity instanceof EntityInsentient) || this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { ++ if (isIncendiary) { // CraftBukkit BlockPosition blockposition = movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()); - if (this.world.isEmpty(blockposition)) { + if (this.world.isEmpty(blockposition) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { // CraftBukkit - this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition)); } } diff --git a/nms-patches/EntitySnowman.patch b/nms-patches/EntitySnowman.patch index 483aded538..a44a8085e7 100644 --- a/nms-patches/EntitySnowman.patch +++ b/nms-patches/EntitySnowman.patch @@ -8,10 +8,10 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +// CraftBukkit end - public class EntitySnowman extends EntityGolem implements IRangedEntity { + public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity { -@@ -62,7 +65,7 @@ - } +@@ -60,7 +63,7 @@ + int k = MathHelper.floor(this.locZ()); if (this.world.getBiome(new BlockPosition(i, 0, k)).getAdjustedTemperature(new BlockPosition(i, j, k)) > 1.0F) { - this.damageEntity(DamageSource.BURN, 1.0F); @@ -19,7 +19,7 @@ } if (!this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { -@@ -78,7 +81,7 @@ +@@ -76,7 +79,7 @@ BlockPosition blockposition = new BlockPosition(i, j, k); if (this.world.getType(blockposition).isAir() && this.world.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.world, blockposition)) { @@ -28,15 +28,15 @@ } } } -@@ -110,6 +113,11 @@ +@@ -107,6 +110,11 @@ + ItemStack itemstack = entityhuman.b(enumhand); - if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin()) { + if (itemstack.getItem() == Items.SHEARS && this.canShear()) { ++ // CraftBukkit start ++ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.shear(SoundCategory.PLAYERS); if (!this.world.isClientSide) { -+ // CraftBukkit start -+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) { -+ return false; -+ } -+ // CraftBukkit end - this.setHasPumpkin(false); itemstack.damage(1, entityhuman, (entityhuman1) -> { - entityhuman1.broadcastItemBreak(enumhand); diff --git a/nms-patches/EntitySpider.patch b/nms-patches/EntitySpider.patch index fb84bc387c..98d6eebb47 100644 --- a/nms-patches/EntitySpider.patch +++ b/nms-patches/EntitySpider.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/EntitySpider.java +++ b/net/minecraft/server/EntitySpider.java -@@ -125,7 +125,7 @@ - +@@ -123,7 +123,7 @@ entityskeleton.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F); entityskeleton.prepare(generatoraccess, difficultydamagescaler, enummobspawn, (GroupDataEntity) null, (NBTTagCompound) null); + entityskeleton.startRiding(this); - generatoraccess.addEntity(entityskeleton); + generatoraccess.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason - entityskeleton.startRiding(this); } -@@ -140,7 +140,7 @@ + if (object == null) { +@@ -137,7 +137,7 @@ MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).a; if (mobeffectlist != null) { diff --git a/nms-patches/EntityTNTPrimed.patch b/nms-patches/EntityTNTPrimed.patch index bc8f7c3d38..120712f36b 100644 --- a/nms-patches/EntityTNTPrimed.patch +++ b/nms-patches/EntityTNTPrimed.patch @@ -30,7 +30,7 @@ + this.die(); + // CraftBukkit end } else { - this.aC(); + this.aG(); if (this.world.isClientSide) { @@ -71,9 +77,16 @@ } diff --git a/nms-patches/EntityThrownExpBottle.patch b/nms-patches/EntityThrownExpBottle.patch index 3cef308b55..c942cc9e23 100644 --- a/nms-patches/EntityThrownExpBottle.patch +++ b/nms-patches/EntityThrownExpBottle.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/EntityThrownExpBottle.java +++ b/net/minecraft/server/EntityThrownExpBottle.java -@@ -27,9 +27,18 @@ - @Override +@@ -28,9 +28,18 @@ protected void a(MovingObjectPosition movingobjectposition) { + super.a(movingobjectposition); if (!this.world.isClientSide) { -- this.world.triggerEffect(2002, new BlockPosition(this), PotionUtil.a(Potions.WATER)); +- this.world.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); + // CraftBukkit - moved to after event -+ // this.world.triggerEffect(2002, new BlockPosition(this), PotionUtil.a(Potions.WATER)); ++ // this.world.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); int i = 3 + this.world.random.nextInt(5) + this.world.random.nextInt(5); + // CraftBukkit start + org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, i); + i = event.getExperience(); + if (event.getShowEffect()) { -+ this.world.triggerEffect(2002, new BlockPosition(this), PotionUtil.a(Potions.WATER)); ++ this.world.triggerEffect(2002, this.getChunkCoordinates(), PotionUtil.a(Potions.WATER)); + } + // CraftBukkit end + diff --git a/nms-patches/EntityThrownTrident.patch b/nms-patches/EntityThrownTrident.patch index 5849b96952..e3256f1cea 100644 --- a/nms-patches/EntityThrownTrident.patch +++ b/nms-patches/EntityThrownTrident.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/EntityThrownTrident.java +++ b/net/minecraft/server/EntityThrownTrident.java -@@ -131,7 +131,7 @@ - EntityLightning entitylightning = new EntityLightning(this.world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, false); +@@ -132,7 +132,7 @@ + entitylightning.c(Vec3D.c((BaseBlockPosition) blockposition)); entitylightning.d(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); -- ((WorldServer) this.world).strikeLightning(entitylightning); +- this.world.addEntity(entitylightning); + ((WorldServer) this.world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit soundeffect = SoundEffects.ITEM_TRIDENT_THUNDER; f1 = 5.0F; diff --git a/nms-patches/EntityTrackerEntry.patch b/nms-patches/EntityTrackerEntry.patch index 8cee802d79..d56735c925 100644 --- a/nms-patches/EntityTrackerEntry.patch +++ b/nms-patches/EntityTrackerEntry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityTrackerEntry.java +++ b/net/minecraft/server/EntityTrackerEntry.java -@@ -9,6 +9,11 @@ +@@ -11,6 +11,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,7 +12,7 @@ public class EntityTrackerEntry { private static final Logger LOGGER = LogManager.getLogger(); -@@ -29,8 +34,12 @@ +@@ -31,8 +36,12 @@ private List p; private boolean q; private boolean r; @@ -26,7 +26,7 @@ this.m = Vec3D.a; this.p = Collections.emptyList(); this.b = worldserver; -@@ -50,16 +59,17 @@ +@@ -52,16 +61,17 @@ if (!list.equals(this.p)) { this.p = list; @@ -48,7 +48,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -104,6 +114,17 @@ +@@ -106,6 +116,17 @@ boolean flag2 = flag1 || this.tickCounter % 60 == 0; boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1; @@ -66,7 +66,7 @@ if (this.tickCounter > 0 || this.tracker instanceof EntityArrow) { long k = PacketPlayOutEntity.a(vec3d.x); long l = PacketPlayOutEntity.a(vec3d.y); -@@ -142,6 +163,7 @@ +@@ -144,6 +165,7 @@ } this.c(); @@ -74,7 +74,7 @@ if (flag2) { this.d(); } -@@ -150,6 +172,7 @@ +@@ -152,6 +174,7 @@ this.yRot = i; this.xRot = j; } @@ -82,7 +82,7 @@ this.q = false; } -@@ -165,7 +188,27 @@ +@@ -167,7 +190,27 @@ ++this.tickCounter; if (this.tracker.velocityChanged) { @@ -111,7 +111,7 @@ this.tracker.velocityChanged = false; } -@@ -180,14 +223,17 @@ +@@ -182,14 +225,17 @@ PlayerConnection playerconnection = entityplayer.playerConnection; entityplayer.playerConnection.getClass(); @@ -131,10 +131,10 @@ + // CraftBukkit end } - Packet packet = this.tracker.L(); -@@ -204,6 +250,12 @@ - AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap(); - Collection collection = attributemapserver.c(); + Packet packet = this.tracker.O(); +@@ -205,6 +251,12 @@ + if (this.tracker instanceof EntityLiving) { + Collection collection = ((EntityLiving) this.tracker).getAttributeMap().b(); + // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health + if (this.tracker.getId() == entityplayer.getId()) { @@ -145,7 +145,7 @@ if (!collection.isEmpty()) { consumer.accept(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection)); } -@@ -232,6 +284,11 @@ +@@ -238,6 +290,11 @@ } } @@ -157,8 +157,8 @@ if (this.tracker instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) this.tracker; Iterator iterator = entityliving.getEffects().iterator(); -@@ -273,6 +330,11 @@ - Set set = attributemapserver.getAttributes(); +@@ -278,6 +335,11 @@ + Set set = ((EntityLiving) this.tracker).getAttributeMap().getAttributes(); if (!set.isEmpty()) { + // CraftBukkit start - Send scaled max health diff --git a/nms-patches/EntityTurtle.patch b/nms-patches/EntityTurtle.patch index 1d0a372c69..587655e1af 100644 --- a/nms-patches/EntityTurtle.patch +++ b/nms-patches/EntityTurtle.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityTurtle.java +++ b/net/minecraft/server/EntityTurtle.java -@@ -255,7 +255,9 @@ - protected void l() { - super.l(); +@@ -252,7 +252,9 @@ + protected void m() { + super.m(); if (!this.isBaby() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.SCUTE, 1); @@ -10,7 +10,7 @@ } } -@@ -282,7 +284,9 @@ +@@ -279,7 +281,9 @@ @Override public void onLightningStrike(EntityLightning entitylightning) { @@ -20,8 +20,8 @@ } static class g extends NavigationGuardian { -@@ -443,8 +447,12 @@ - } else if (this.g.bD > 200) { +@@ -438,8 +442,12 @@ + } else if (this.g.bC > 200) { World world = this.g.world; + // CraftBukkit start @@ -30,10 +30,10 @@ world.setTypeAndData(this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1), 3); + } + // CraftBukkit end - this.g.r(false); - this.g.s(false); + this.g.setHasEgg(false); + this.g.u(false); this.g.setLoveTicks(600); -@@ -530,7 +538,7 @@ +@@ -519,7 +527,7 @@ --this.e; return false; } else { diff --git a/nms-patches/EntityTypes.patch b/nms-patches/EntityTypes.patch index e74c238b46..70f255ea63 100644 --- a/nms-patches/EntityTypes.patch +++ b/nms-patches/EntityTypes.patch @@ -1,15 +1,24 @@ --- a/net/minecraft/server/EntityTypes.java +++ b/net/minecraft/server/EntityTypes.java -@@ -130,7 +130,7 @@ - private MinecraftKey bi; - private final EntitySize bj; +@@ -12,7 +12,7 @@ + public class EntityTypes { -- private static EntityTypes a(String s, EntityTypes.a entitytypes_a) { -+ private static EntityTypes a(String s, EntityTypes.a entitytypes_a) { // CraftBukkit - decompile error - return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_a.a(s)); + private static final Logger LOGGER = LogManager.getLogger(); +- public static final EntityTypes AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(Integer.MAX_VALUE)); ++ public static final EntityTypes AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds + public static final EntityTypes ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10)); + public static final EntityTypes ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20)); + public static final EntityTypes BAT = a("bat", EntityTypes.Builder.a(EntityBat::new, EnumCreatureType.AMBIENT).a(0.5F, 0.9F).trackingRange(5)); +@@ -136,7 +136,7 @@ + private MinecraftKey bp; + private final EntitySize bq; + +- private static EntityTypes a(String s, EntityTypes.Builder entitytypes_builder) { ++ private static EntityTypes a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error + return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s)); } -@@ -159,10 +159,16 @@ +@@ -168,10 +168,16 @@ @Nullable public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { @@ -28,7 +37,7 @@ } @Nullable -@@ -195,7 +201,7 @@ +@@ -204,7 +210,7 @@ t0.setCustomName(ichatbasecomponent); } @@ -37,7 +46,7 @@ return t0; } } -@@ -328,7 +334,7 @@ +@@ -347,7 +353,7 @@ } return entity; @@ -46,22 +55,12 @@ } private static Optional b(NBTTagCompound nbttagcompound, World world) { -@@ -345,7 +351,8 @@ - } - - public int getUpdateInterval() { -- return this != EntityTypes.PLAYER && this != EntityTypes.EVOKER_FANGS ? (this == EntityTypes.EYE_OF_ENDER ? 4 : (this == EntityTypes.FISHING_BOBBER ? 5 : (this != EntityTypes.SMALL_FIREBALL && this != EntityTypes.DRAGON_FIREBALL && this != EntityTypes.FIREBALL && this != EntityTypes.WITHER_SKULL && this != EntityTypes.SNOWBALL && this != EntityTypes.LLAMA_SPIT && this != EntityTypes.ENDER_PEARL && this != EntityTypes.EGG && this != EntityTypes.POTION && this != EntityTypes.EXPERIENCE_BOTTLE && this != EntityTypes.FIREWORK_ROCKET && this != EntityTypes.TNT ? (this != EntityTypes.ARROW && this != EntityTypes.SPECTRAL_ARROW && this != EntityTypes.TRIDENT && this != EntityTypes.ITEM && this != EntityTypes.FALLING_BLOCK && this != EntityTypes.EXPERIENCE_ORB ? (this != EntityTypes.ITEM_FRAME && this != EntityTypes.LEASH_KNOT && this != EntityTypes.PAINTING && this != EntityTypes.AREA_EFFECT_CLOUD && this != EntityTypes.END_CRYSTAL ? 3 : Integer.MAX_VALUE) : 20) : 10))) : 2; -+ // CraftBukkit - SPIGOT-3729: track area effect clouds -+ return this != EntityTypes.PLAYER && this != EntityTypes.EVOKER_FANGS ? (this == EntityTypes.EYE_OF_ENDER ? 4 : (this == EntityTypes.FISHING_BOBBER ? 5 : (this != EntityTypes.SMALL_FIREBALL && this != EntityTypes.DRAGON_FIREBALL && this != EntityTypes.FIREBALL && this != EntityTypes.WITHER_SKULL && this != EntityTypes.SNOWBALL && this != EntityTypes.LLAMA_SPIT && this != EntityTypes.ENDER_PEARL && this != EntityTypes.EGG && this != EntityTypes.POTION && this != EntityTypes.EXPERIENCE_BOTTLE && this != EntityTypes.FIREWORK_ROCKET && this != EntityTypes.TNT ? (this != EntityTypes.ARROW && this != EntityTypes.SPECTRAL_ARROW && this != EntityTypes.TRIDENT && this != EntityTypes.ITEM && this != EntityTypes.FALLING_BLOCK && this != EntityTypes.EXPERIENCE_ORB ? (this != EntityTypes.ITEM_FRAME && this != EntityTypes.LEASH_KNOT && this != EntityTypes.PAINTING && this != EntityTypes.END_CRYSTAL ? 3 : Integer.MAX_VALUE) : 20) : 10))) : 2; - } - - public boolean isDeltaTracking() { -@@ -377,7 +384,7 @@ - this.f = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; +@@ -399,7 +405,7 @@ + this.g = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } -- public static EntityTypes.a a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { -+ public static EntityTypes.a a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error - return new EntityTypes.a<>(entitytypes_b, enumcreaturetype); +- public static EntityTypes.Builder a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { ++ public static EntityTypes.Builder a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error + return new EntityTypes.Builder<>(entitytypes_b, enumcreaturetype); } diff --git a/nms-patches/EntityVex.patch b/nms-patches/EntityVex.patch index ba140cd0eb..b049459a5e 100644 --- a/nms-patches/EntityVex.patch +++ b/nms-patches/EntityVex.patch @@ -17,7 +17,7 @@ this.targetSelector.a(2, new EntityVex.b(this)); this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); } -@@ -189,7 +190,7 @@ +@@ -186,7 +187,7 @@ @Override public void c() { diff --git a/nms-patches/EntityVillager.patch b/nms-patches/EntityVillager.patch index 68e55bc514..aed36be9c3 100644 --- a/nms-patches/EntityVillager.patch +++ b/nms-patches/EntityVillager.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityVillager.java +++ b/net/minecraft/server/EntityVillager.java -@@ -16,6 +16,16 @@ - import java.util.function.BiPredicate; +@@ -18,6 +18,16 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftVillager; @@ -17,7 +17,7 @@ public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder { -@@ -60,7 +70,7 @@ +@@ -64,7 +74,7 @@ @Override public BehaviorController getBehaviorController() { @@ -26,17 +26,26 @@ } @Override -@@ -124,7 +134,7 @@ +@@ -83,7 +93,7 @@ + public void b(WorldServer worldserver) { + BehaviorController behaviorcontroller = this.getBehaviorController(); + +- behaviorcontroller.b(worldserver, (EntityLiving) this); ++ behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error + this.bn = behaviorcontroller.h(); + this.a(this.getBehaviorController()); + } +@@ -133,7 +143,7 @@ @Override protected void mobTick() { - this.world.getMethodProfiler().enter("brain"); + this.world.getMethodProfiler().enter("villagerBrain"); - this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); + this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error this.world.getMethodProfiler().exit(); - if (!this.et() && this.bB > 0) { - --this.bB; -@@ -134,7 +144,7 @@ - this.bC = false; + if (this.bM) { + this.bM = false; +@@ -147,7 +157,7 @@ + this.bB = false; } - this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0)); @@ -44,7 +53,7 @@ } } -@@ -353,7 +363,14 @@ +@@ -358,7 +368,14 @@ while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); @@ -60,30 +69,39 @@ } } -@@ -661,7 +678,12 @@ - entitywitch.setCustomNameVisible(this.getCustomNameVisible()); - } +@@ -387,7 +404,7 @@ + @Override + public void saveData(NBTTagCompound nbttagcompound) { + super.saveData(nbttagcompound); +- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); ++ DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error + Logger logger = EntityVillager.LOGGER; -- this.world.addEntity(entitywitch); -+ // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { -+ return; -+ } -+ this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); -+ // CraftBukkit end - this.die(); - } + logger.getClass(); +@@ -695,7 +712,12 @@ + } -@@ -811,7 +833,7 @@ + entitywitch.setPersistent(); +- this.world.addEntity(entitywitch); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { ++ return; ++ } ++ this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ // CraftBukkit end + this.die(); + } else { + super.onLightningStrike(entitylightning); +@@ -812,7 +834,7 @@ } private void b(long i) { -- this.bo.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, (Object) i); -+ this.bo.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, i); // CraftBukkit - decompile error +- this.bn.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, (Object) i); ++ this.bn.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, i); // CraftBukkit - decompile error } private boolean c(long i) { -@@ -860,7 +882,7 @@ +@@ -845,7 +867,7 @@ if (entityirongolem != null) { if (entityirongolem.a((GeneratorAccess) this.world, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) this.world)) { @@ -92,19 +110,21 @@ return entityirongolem; } -@@ -922,13 +944,13 @@ +@@ -923,7 +945,7 @@ @Override public void entitySleep(BlockPosition blockposition) { super.entitySleep(blockposition); -- this.bo.setMemory(MemoryModuleType.LAST_SLEPT, (Object) MinecraftSerializableLong.a(this.world.getTime())); -+ this.bo.setMemory(MemoryModuleType.LAST_SLEPT, MinecraftSerializableLong.a(this.world.getTime())); // CraftBukkit - decompile error +- this.bn.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.world.getTime()); ++ this.bn.setMemory(MemoryModuleType.LAST_SLEPT, this.world.getTime()); // CraftBukkit - decompile error + this.bn.removeMemory(MemoryModuleType.WALK_TARGET); + this.bn.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } - +@@ -931,7 +953,7 @@ @Override public void entityWakeup() { super.entityWakeup(); -- this.bo.setMemory(MemoryModuleType.LAST_WOKEN, (Object) MinecraftSerializableLong.a(this.world.getTime())); -+ this.bo.setMemory(MemoryModuleType.LAST_WOKEN, MinecraftSerializableLong.a(this.world.getTime())); // CraftBukkit - decompile error +- this.bn.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime()); ++ this.bn.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error } private boolean d(long i) { diff --git a/nms-patches/EntityVillagerAbstract.patch b/nms-patches/EntityVillagerAbstract.patch index aa226200f8..f4aaf7d02f 100644 --- a/nms-patches/EntityVillagerAbstract.patch +++ b/nms-patches/EntityVillagerAbstract.patch @@ -22,7 +22,7 @@ + return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant; + } + // CraftBukkit end - private static final DataWatcherObject bx = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b); + private static final DataWatcherObject bw = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b); @Nullable private EntityHuman tradingPlayer; @Nullable @@ -32,7 +32,7 @@ public EntityVillagerAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -231,7 +246,16 @@ +@@ -214,7 +229,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); if (merchantrecipe != null) { diff --git a/nms-patches/EntityVillagerTrader.patch b/nms-patches/EntityVillagerTrader.patch index 8950133f16..30d07d0cb1 100644 --- a/nms-patches/EntityVillagerTrader.patch +++ b/nms-patches/EntityVillagerTrader.patch @@ -13,7 +13,7 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { -@@ -92,7 +98,16 @@ +@@ -89,7 +95,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); if (merchantrecipe != null) { diff --git a/nms-patches/EntityWitch.patch b/nms-patches/EntityWitch.patch index b98cdca05e..fa3659afd0 100644 --- a/nms-patches/EntityWitch.patch +++ b/nms-patches/EntityWitch.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityWitch.java +++ b/net/minecraft/server/EntityWitch.java -@@ -96,7 +96,7 @@ +@@ -93,7 +93,7 @@ while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); diff --git a/nms-patches/EntityWither.patch b/nms-patches/EntityWither.patch index 224030f988..5e1db61a8e 100644 --- a/nms-patches/EntityWither.patch +++ b/nms-patches/EntityWither.patch @@ -14,8 +14,8 @@ public class EntityWither extends EntityMonster implements IRangedEntity { private static final DataWatcherObject b = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b); -@@ -188,14 +195,38 @@ - i = this.eq() - 1; +@@ -188,16 +195,40 @@ + i = this.getInvul() - 1; if (i <= 0) { Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; + // CraftBukkit start @@ -29,34 +29,36 @@ + // CraftBukkit end - this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect); -- this.world.b(1023, new BlockPosition(this), 0); -+ // CraftBukkit start - Use relative location for far away sounds -+ // this.world.b(1023, new BlockPosition(this), 0); -+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; -+ for (EntityPlayer player : (List) MinecraftServer.getServer().getPlayerList().players) { -+ double deltaX = this.locX() - player.locX(); -+ double deltaZ = this.locZ() - player.locZ(); -+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; -+ if (distanceSquared > viewDistance * viewDistance) { -+ double deltaLength = Math.sqrt(distanceSquared); -+ double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance; -+ double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance; -+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true)); -+ } else { -+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) this.locX(), (int) this.locY(), (int) this.locZ()), 0, true)); + if (!this.isSilent()) { +- this.world.b(1023, this.getChunkCoordinates(), 0); ++ // CraftBukkit start - Use relative location for far away sounds ++ // this.world.b(1023, new BlockPosition(this), 0); ++ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; ++ for (EntityPlayer player : (List) MinecraftServer.getServer().getPlayerList().players) { ++ double deltaX = this.locX() - player.locX(); ++ double deltaZ = this.locZ() - player.locZ(); ++ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; ++ if (distanceSquared > viewDistance * viewDistance) { ++ double deltaLength = Math.sqrt(distanceSquared); ++ double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance; ++ double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance; ++ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true)); ++ } else { ++ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true)); ++ } + } -+ } -+ // CraftBukkit end ++ // CraftBukkit end + } } - this.s(i); + this.setInvul(i); if (this.ticksLived % 10 == 0) { - this.heal(10.0F); + this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit } } else { -@@ -247,9 +278,11 @@ +@@ -249,9 +280,11 @@ if (entityliving != this && entityliving.isAlive() && this.hasLineOfSight(entityliving)) { if (entityliving instanceof EntityHuman) { if (!((EntityHuman) entityliving).abilities.isInvulnerable) { @@ -68,10 +70,10 @@ this.setHeadTarget(i, entityliving.getId()); } break; -@@ -285,6 +318,11 @@ +@@ -287,6 +320,11 @@ IBlockData iblockdata = this.world.getType(blockposition); - if (b(iblockdata)) { + if (c(iblockdata)) { + // CraftBukkit start + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + continue; @@ -80,7 +82,7 @@ flag = this.world.a(blockposition, true, this) || flag; } } -@@ -298,7 +336,7 @@ +@@ -300,7 +338,7 @@ } if (this.ticksLived % 20 == 0) { diff --git a/nms-patches/EntityWitherSkull.patch b/nms-patches/EntityWitherSkull.patch index e8a79ed50d..a9a2c4d6cf 100644 --- a/nms-patches/EntityWitherSkull.patch +++ b/nms-patches/EntityWitherSkull.patch @@ -7,31 +7,27 @@ + public class EntityWitherSkull extends EntityFireball { - private static final DataWatcherObject f = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.i); -@@ -35,11 +37,11 @@ - Entity entity = ((MovingObjectPositionEntity) movingobjectposition).getEntity(); + private static final DataWatcherObject e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.i); +@@ -43,7 +45,7 @@ + if (entity.isAlive()) { + this.a(entityliving, entity); + } else { +- entityliving.heal(5.0F); ++ entityliving.heal(5.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit + } + } + } else { +@@ -60,7 +62,7 @@ + } - if (this.shooter != null) { -- if (entity.damageEntity(DamageSource.mobAttack(this.shooter), 8.0F)) { -+ if (entity.damageEntity(DamageSource.projectile(this, shooter), 8.0F)) { // CraftBukkit - if (entity.isAlive()) { - this.a(this.shooter, entity); - } else { -- this.shooter.heal(5.0F); -+ this.shooter.heal(5.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit - } - } - } else { -@@ -56,14 +58,22 @@ - } - - if (b0 > 0) { -- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1)); -+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit - } + if (b0 > 0) { +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1)); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } +@@ -73,7 +75,15 @@ + if (!this.world.isClientSide) { Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; - this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), 1.0F, false, explosion_effect); diff --git a/nms-patches/EntityWolf.patch b/nms-patches/EntityWolf.patch index 62cbbf9a33..91f336ea2e 100644 --- a/nms-patches/EntityWolf.patch +++ b/nms-patches/EntityWolf.patch @@ -9,20 +9,20 @@ +import org.bukkit.event.entity.EntityTargetEvent.TargetReason; +// CraftBukkit end + - public class EntityWolf extends EntityTameableAnimal { + public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable { - private static final DataWatcherObject bA = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i); -@@ -41,7 +46,7 @@ + private static final DataWatcherObject by = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i); +@@ -43,7 +48,7 @@ this.goalSelector.a(10, new PathfinderGoalRandomLookaround(this)); this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this)); this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this)); - this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); + this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bz)); - this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bw)); - this.targetSelector.a(5, new PathfinderGoalNearestAttackableTarget<>(this, EntitySkeletonAbstract.class, false)); -@@ -60,6 +65,22 @@ - this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D); + this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::b)); + this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bx)); + this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bv)); +@@ -55,6 +60,24 @@ + return EntityInsentient.p().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 2.0D); } + // CraftBukkit - add overriden version @@ -32,50 +32,30 @@ + return false; + } + entityliving = getGoalTarget(); ++ /* // PAIL + if (entityliving == null) { + this.setAngry(false); + } else if (!this.isTamed()) { + this.setAngry(true); + } ++ */ + return true; + } + // CraftBukkit end + @Override - public void setGoalTarget(@Nullable EntityLiving entityliving) { - super.setGoalTarget(entityliving); -@@ -94,6 +115,11 @@ - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - this.setAngry(nbttagcompound.getBoolean("Angry")); -+ // CraftBukkit start - moved from below, SPIGOT-4893 -+ if (this.getGoalTarget() == null && this.isAngry()) { -+ this.setAngry(false); -+ } -+ // CraftBukkit end - if (nbttagcompound.hasKeyOfType("CollarColor", 99)) { - this.setCollarColor(EnumColor.fromColorIndex(nbttagcompound.getInt("CollarColor"))); - } -@@ -130,7 +156,7 @@ - this.world.broadcastEntityEffect(this, (byte) 8); - } - -- if (!this.world.isClientSide && this.getGoalTarget() == null && this.isAngry()) { -+ if (false && !this.world.isClientSide && this.getGoalTarget() == null && this.isAngry()) { // CraftBukkit - SPIGOT-4893 - this.setAngry(false); - } - -@@ -210,7 +236,8 @@ + protected void initDatawatcher() { + super.initDatawatcher(); +@@ -194,7 +217,7 @@ + } else { Entity entity = damagesource.getEntity(); - if (this.goalSit != null) { -- this.goalSit.setSitting(false); -+ // CraftBukkit - moved into EntityLiving.d(DamageSource, float) -+ // this.goalSit.setSitting(false); - } - +- this.setWillSit(false); ++ // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float) if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { -@@ -237,7 +264,7 @@ + f = (f + 1.0F) / 2.0F; + } +@@ -219,7 +242,7 @@ super.setTamed(flag); if (flag) { this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(20.0D); @@ -84,24 +64,25 @@ } else { this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(8.0D); } -@@ -261,7 +288,7 @@ +@@ -243,7 +266,7 @@ itemstack.subtract(1); } - this.heal((float) item.getFoodInfo().getNutrition()); + this.heal((float) item.getFoodInfo().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit - return true; + return EnumInteractionResult.SUCCESS; } -@@ -290,14 +317,15 @@ - this.goalSit.setSitting(!this.isSitting()); - this.jumping = false; - this.navigation.o(); -- this.setGoalTarget((EntityLiving) null); -+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason - } - } else if (item == Items.BONE && !this.isAngry()) { - if (!entityhuman.abilities.canInstantlyBuild) { +@@ -254,7 +277,7 @@ + this.setWillSit(!this.isWillSit()); + this.jumping = false; + this.navigation.o(); +- this.setGoalTarget((EntityLiving) null); ++ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason + return EnumInteractionResult.SUCCESS; + } + +@@ -276,7 +299,8 @@ itemstack.subtract(1); } diff --git a/nms-patches/EntityZombie.patch b/nms-patches/EntityZombie.patch index 239356c679..d276af182e 100644 --- a/nms-patches/EntityZombie.patch +++ b/nms-patches/EntityZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityZombie.java +++ b/net/minecraft/server/EntityZombie.java -@@ -8,6 +8,15 @@ +@@ -9,6 +9,15 @@ import java.util.function.Predicate; import javax.annotation.Nullable; @@ -15,18 +15,18 @@ + public class EntityZombie extends EntityMonster { - protected static final IAttribute d = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); + private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); @@ -23,6 +32,7 @@ - private boolean bB; - private int bC; + private boolean bz; + private int bA; public int drownedConversionTime; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -144,7 +154,10 @@ +@@ -138,7 +148,10 @@ public void tick() { - if (!this.world.isClientSide && this.isAlive()) { + if (!this.world.isClientSide && this.isAlive() && !this.isNoAI()) { if (this.isDrownConverting()) { - --this.drownedConversionTime; + // CraftBukkit start - Use wall time instead of ticks for conversion @@ -34,9 +34,9 @@ + this.drownedConversionTime -= elapsedTicks; + // CraftBukkit end if (this.drownedConversionTime < 0) { - this.ev(); + this.eQ(); } -@@ -161,6 +174,7 @@ +@@ -155,6 +168,7 @@ } super.tick(); @@ -44,7 +44,7 @@ } @Override -@@ -193,6 +207,7 @@ +@@ -187,6 +201,7 @@ } public void startDrownedConversion(int i) { @@ -52,34 +52,27 @@ this.drownedConversionTime = i; this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true); } -@@ -236,7 +251,13 @@ - } - - entityzombie.setInvulnerable(this.isInvulnerable()); -- this.world.addEntity(entityzombie); -+ // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombie, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) { -+ ((Zombie) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam -+ return; -+ } -+ // CraftBukkit end -+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.DROWNED); // CraftBukkit - added spawn reason - this.die(); +@@ -206,6 +221,7 @@ + entityzombie.u(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d()); + entityzombie.u(entityzombie.eL() && this.eV()); } ++ else { ((Zombie) getBukkitEntity()).setConversionTime(-1); } // SPIGOT-5208: End conversion to stop event spam + } -@@ -298,8 +319,8 @@ - if (this.world.getType(blockposition).a((IBlockAccess) this.world, blockposition, (Entity) entityzombie) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { + +@@ -239,8 +255,8 @@ + if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, this.world, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); - if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.i((Entity) entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { + if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.i(entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { - this.world.addEntity(entityzombie); - entityzombie.setGoalTarget(entityliving); + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit + entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit - entityzombie.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombie)), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); - this.getAttributeInstance(EntityZombie.d).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); - entityzombie.getAttributeInstance(EntityZombie.d).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); -@@ -323,7 +344,14 @@ - float f = this.world.getDamageScaler(new BlockPosition(this)).b(); + entityzombie.prepare(this.world, this.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); + this.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); + entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); +@@ -264,7 +280,14 @@ + float f = this.world.getDamageScaler(this.getChunkCoordinates()).b(); if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { - entity.setOnFire(2 * (int) f); @@ -94,16 +87,16 @@ } } -@@ -413,7 +441,7 @@ +@@ -354,7 +377,7 @@ EntityZombieVillager entityzombievillager = (EntityZombieVillager) EntityTypes.ZOMBIE_VILLAGER.a(this.world); entityzombievillager.u(entityvillager); - entityvillager.die(); + // entityvillager.die(); // CraftBukkit - moved down - entityzombievillager.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombievillager)), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null); + entityzombievillager.prepare(this.world, this.world.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); entityzombievillager.setVillagerData(entityvillager.getVillagerData()); - entityzombievillager.a((NBTBase) entityvillager.eN().a((DynamicOps) DynamicOpsNBT.a).getValue()); -@@ -431,7 +459,13 @@ + entityzombievillager.a((NBTBase) entityvillager.fj().a((DynamicOps) DynamicOpsNBT.a).getValue()); +@@ -372,7 +395,13 @@ } entityzombievillager.setInvulnerable(this.isInvulnerable()); @@ -115,15 +108,15 @@ + entityvillager.die(); // CraftBukkit - from above + this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason + // CraftBukkit end - this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0); - } - -@@ -478,7 +512,7 @@ - entitychicken1.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F); - entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); - entitychicken1.r(true); -- generatoraccess.addEntity(entitychicken1); -+ generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit - this.startRiding(entitychicken1); + if (!this.isSilent()) { + this.world.a((EntityHuman) null, 1026, this.getChunkCoordinates(), 0); + } +@@ -423,7 +452,7 @@ + entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); + entitychicken1.setChickenJockey(true); + this.startRiding(entitychicken1); +- generatoraccess.addEntity(entitychicken1); ++ generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit + } } } diff --git a/nms-patches/EntityZombieHusk.patch b/nms-patches/EntityZombieHusk.patch index d566ec1f67..b4349ec3be 100644 --- a/nms-patches/EntityZombieHusk.patch +++ b/nms-patches/EntityZombieHusk.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityZombieHusk.java @@ -44,7 +44,7 @@ if (flag && this.getItemInMainHand().isEmpty() && entity instanceof EntityLiving) { - float f = this.world.getDamageScaler(new BlockPosition(this)).b(); + float f = this.world.getDamageScaler(this.getChunkCoordinates()).b(); - ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f)); + ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit diff --git a/nms-patches/EntityZombieVillager.patch b/nms-patches/EntityZombieVillager.patch index d1b7bd7de9..47012258e6 100644 --- a/nms-patches/EntityZombieVillager.patch +++ b/nms-patches/EntityZombieVillager.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityZombieVillager.java +++ b/net/minecraft/server/EntityZombieVillager.java -@@ -3,6 +3,11 @@ - import com.mojang.datafixers.Dynamic; +@@ -5,6 +5,11 @@ import java.util.UUID; import javax.annotation.Nullable; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.entity.ZombieVillager; @@ -12,15 +12,24 @@ public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { -@@ -13,6 +18,7 @@ - private NBTBase by; - private NBTTagCompound bz; - private int bA; +@@ -15,6 +20,7 @@ + private NBTBase bw; + private NBTTagCompound bx; + private int by; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -75,6 +81,10 @@ +@@ -31,7 +37,7 @@ + @Override + public void saveData(NBTTagCompound nbttagcompound) { + super.saveData(nbttagcompound); +- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); ++ DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error + Logger logger = EntityZombieVillager.LOGGER; + + logger.getClass(); +@@ -87,6 +93,10 @@ public void tick() { if (!this.world.isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -31,7 +40,7 @@ this.conversionTime -= i; if (this.conversionTime <= 0) { -@@ -83,6 +93,7 @@ +@@ -95,6 +105,7 @@ } super.tick(); @@ -39,7 +48,7 @@ } @Override -@@ -123,8 +134,11 @@ +@@ -138,8 +149,11 @@ this.conversionPlayer = uuid; this.conversionTime = i; this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true); @@ -53,7 +62,7 @@ this.world.broadcastEntityEffect(this, (byte) 16); } -@@ -166,7 +180,7 @@ +@@ -181,7 +195,7 @@ entityvillager.setAgeRaw(-24000); } @@ -62,7 +71,7 @@ entityvillager.setNoAI(this.isNoAI()); if (this.hasCustomName()) { entityvillager.setCustomName(this.getCustomName()); -@@ -178,7 +192,14 @@ +@@ -193,7 +207,14 @@ } entityvillager.setInvulnerable(this.isInvulnerable()); @@ -78,12 +87,12 @@ if (this.conversionPlayer != null) { EntityHuman entityhuman = worldserver.b(this.conversionPlayer); -@@ -188,7 +209,7 @@ +@@ -203,7 +224,7 @@ } } - entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); + entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit - worldserver.a((EntityHuman) null, 1027, new BlockPosition(this), 0); - } - + if (!this.isSilent()) { + worldserver.a((EntityHuman) null, 1027, this.getChunkCoordinates(), 0); + } diff --git a/nms-patches/ExpirableListEntry.patch b/nms-patches/ExpirableListEntry.patch index fdc0dde3b1..55b5350982 100644 --- a/nms-patches/ExpirableListEntry.patch +++ b/nms-patches/ExpirableListEntry.patch @@ -4,8 +4,8 @@ } protected ExpirableListEntry(T t0, JsonObject jsonobject) { -- super(t0, jsonobject); -+ super(checkExpiry(t0, jsonobject), jsonobject); +- super(t0); ++ super(checkExpiry(t0, jsonobject)); Date date; diff --git a/nms-patches/Explosion.patch b/nms-patches/Explosion.patch index 68b96fcbe8..ad41e34470 100644 --- a/nms-patches/Explosion.patch +++ b/nms-patches/Explosion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Explosion.java +++ b/net/minecraft/server/Explosion.java -@@ -14,6 +14,13 @@ +@@ -15,6 +15,13 @@ import java.util.Set; import javax.annotation.Nullable; @@ -14,13 +14,13 @@ public class Explosion { private final boolean a; -@@ -29,11 +36,12 @@ - private DamageSource j; +@@ -31,11 +38,12 @@ + private final ExplosionDamageCalculator k; private final List blocks = Lists.newArrayList(); - private final Map l = Maps.newHashMap(); + private final Map m = Maps.newHashMap(); + public boolean wasCanceled = false; // CraftBukkit - add field - public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { + public Explosion(World world, @Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { this.world = world; this.source = entity; - this.size = f; @@ -28,7 +28,7 @@ this.posX = d0; this.posY = d1; this.posZ = d2; -@@ -78,6 +86,11 @@ +@@ -85,6 +93,11 @@ } public void a() { @@ -40,25 +40,25 @@ Set set = Sets.newHashSet(); boolean flag = true; -@@ -116,7 +129,7 @@ - f -= (f2 + 0.3F) * 0.3F; +@@ -118,7 +131,7 @@ + f -= ((Float) optional.get() + 0.3F) * 0.3F; } -- if (f > 0.0F && (this.source == null || this.source.a(this, this.world, blockposition, iblockdata, f))) { -+ if (f > 0.0F && (this.source == null || this.source.a(this, this.world, blockposition, iblockdata, f)) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions +- if (f > 0.0F && this.k.a(this, this.world, blockposition, iblockdata, f)) { ++ if (f > 0.0F && this.k.a(this, this.world, blockposition, iblockdata, f) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions set.add(blockposition); } -@@ -160,7 +173,16 @@ +@@ -162,7 +175,16 @@ double d12 = (double) a(vec3d, entity); double d13 = (1.0D - d7) * d12; -- entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); +- entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); + // CraftBukkit start -+ // entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); ++ // entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); + CraftEventFactory.entityDamage = source; + entity.forceExplosionKnockback = false; -+ boolean wasDamaged = entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); ++ boolean wasDamaged = entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); + CraftEventFactory.entityDamage = null; + if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock) && !entity.forceExplosionKnockback) { + continue; @@ -67,7 +67,7 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -202,6 +224,51 @@ +@@ -204,6 +226,51 @@ Collections.shuffle(this.blocks, this.world.random); Iterator iterator = this.blocks.iterator(); @@ -119,9 +119,9 @@ while (iterator.hasNext()) { BlockPosition blockposition = (BlockPosition) iterator.next(); -@@ -216,8 +283,8 @@ +@@ -218,8 +285,8 @@ TileEntity tileentity = block.isTileEntity() ? this.world.getTileEntity(blockposition) : null; - LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.a).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); + LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.b).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); - if (this.b == Explosion.Effect.DESTROY) { - loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, this.size); @@ -130,20 +130,20 @@ } iblockdata.a(loottableinfo_builder).forEach((itemstack) -> { -@@ -247,7 +314,11 @@ +@@ -249,7 +316,11 @@ BlockPosition blockposition2 = (BlockPosition) iterator1.next(); - if (this.c.nextInt(3) == 0 && this.world.getType(blockposition2).isAir() && this.world.getType(blockposition2.down()).g(this.world, blockposition2.down())) { -- this.world.setTypeUpdate(blockposition2, Blocks.FIRE.getBlockData()); + if (this.c.nextInt(3) == 0 && this.world.getType(blockposition2).isAir() && this.world.getType(blockposition2.down()).i(this.world, blockposition2.down())) { +- this.world.setTypeUpdate(blockposition2, BlockFireAbstract.a((IBlockAccess) this.world, blockposition2)); + // CraftBukkit start - Ignition by explosion + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition2, Blocks.FIRE.getBlockData()); ++ this.world.setTypeUpdate(blockposition2, BlockFireAbstract.a((IBlockAccess) this.world, blockposition2)); + } + // CraftBukkit end } } } -@@ -255,6 +326,7 @@ +@@ -257,6 +328,7 @@ } private static void a(ObjectArrayList> objectarraylist, ItemStack itemstack, BlockPosition blockposition) { diff --git a/nms-patches/FluidTypeFlowing.patch b/nms-patches/FluidTypeFlowing.patch index 8858905981..142907abdd 100644 --- a/nms-patches/FluidTypeFlowing.patch +++ b/nms-patches/FluidTypeFlowing.patch @@ -15,7 +15,7 @@ public abstract class FluidTypeFlowing extends FluidType { -@@ -134,6 +142,15 @@ +@@ -110,6 +118,15 @@ Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1); if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { @@ -31,7 +31,7 @@ this.a(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); if (this.a((IWorldReader) generatoraccess, blockposition) >= 3) { this.a(generatoraccess, blockposition, fluid, iblockdata); -@@ -164,6 +181,15 @@ +@@ -140,6 +157,15 @@ IBlockData iblockdata1 = generatoraccess.getType(blockposition1); if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { @@ -47,7 +47,7 @@ this.a(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); } } -@@ -442,12 +468,23 @@ +@@ -418,12 +444,23 @@ if (fluid1.isEmpty()) { fluid = fluid1; diff --git a/nms-patches/FluidTypeLava.patch b/nms-patches/FluidTypeLava.patch index ec7bce2e94..54f189099a 100644 --- a/nms-patches/FluidTypeLava.patch +++ b/nms-patches/FluidTypeLava.patch @@ -11,7 +11,7 @@ + } + } + // CraftBukkit end - world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData()); + world.setTypeUpdate(blockposition1, BlockFireAbstract.a((IBlockAccess) world, blockposition1)); return; } @@ -55,6 +62,14 @@ @@ -26,12 +26,12 @@ + } + } + // CraftBukkit end - world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData()); + world.setTypeUpdate(blockposition2.up(), BlockFireAbstract.a((IBlockAccess) world, blockposition2)); } } @@ -144,7 +159,11 @@ - if (this.a(TagsFluid.LAVA) && fluid1.a(TagsFluid.WATER)) { + if (this.a((Tag) TagsFluid.LAVA) && fluid1.a((Tag) TagsFluid.WATER)) { if (iblockdata.getBlock() instanceof BlockFluids) { - generatoraccess.setTypeAndData(blockposition, Blocks.STONE.getBlockData(), 3); + // CraftBukkit start diff --git a/nms-patches/FoodMetaData.patch b/nms-patches/FoodMetaData.patch index 9e7382397a..909db70c48 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.eo()) { + } else if (flag && this.foodLevel >= 18 && entityhuman.eI()) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { - entityhuman.heal(1.0F); diff --git a/nms-patches/GameRules.patch b/nms-patches/GameRules.patch index ca155e5893..4a345e0de6 100644 --- a/nms-patches/GameRules.patch +++ b/nms-patches/GameRules.patch @@ -1,56 +1,58 @@ --- a/net/minecraft/server/GameRules.java +++ b/net/minecraft/server/GameRules.java -@@ -94,7 +94,7 @@ +@@ -106,7 +106,7 @@ } public > T get(GameRules.GameRuleKey gamerules_gamerulekey) { -- return (GameRules.GameRuleValue) this.H.get(gamerules_gamerulekey); -+ return (T) this.H.get(gamerules_gamerulekey); // CraftBukkit - decompile error +- return (GameRules.GameRuleValue) this.J.get(gamerules_gamerulekey); ++ return (T) this.J.get(gamerules_gamerulekey); // CraftBukkit - decompile error } public NBTTagCompound a() { -@@ -122,7 +122,7 @@ +@@ -137,8 +137,8 @@ } private static > void a(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey, GameRules.GameRuleDefinition gamerules_gameruledefinition) { - gamerules_gamerulevisitor.a(gamerules_gamerulekey, gamerules_gameruledefinition); +- gamerules_gameruledefinition.a(gamerules_gamerulevisitor, gamerules_gamerulekey); + gamerules_gamerulevisitor.a((GameRules.GameRuleKey) gamerules_gamerulekey, (GameRules.GameRuleDefinition) gamerules_gameruledefinition); // CraftBukkit - decompile error ++ ((GameRules.GameRuleDefinition) gamerules_gameruledefinition).a(gamerules_gamerulevisitor, (GameRules.GameRuleKey) gamerules_gamerulekey); // CraftBukkit - decompile error } public boolean getBoolean(GameRules.GameRuleKey gamerules_gamerulekey) { -@@ -173,7 +173,7 @@ +@@ -189,7 +189,7 @@ } @Override - protected void setValue(String s) { -+ public void setValue(String s) { // PAIL - private->public - this.a = Boolean.parseBoolean(s); ++ public void setValue(String s) { // PAIL - protected->public + this.b = Boolean.parseBoolean(s); } -@@ -223,7 +223,7 @@ +@@ -244,7 +244,7 @@ } @Override - protected void setValue(String s) { -+ public void setValue(String s) { // PAIL - private->public - this.a = b(s); ++ public void setValue(String s) { // PAIL - protected->public + this.b = c(s); } -@@ -272,7 +272,7 @@ +@@ -298,7 +298,7 @@ } - protected abstract void setValue(String s); + public abstract void setValue(String s); // PAIL - private->public - protected abstract String getValue(); + public abstract String getValue(); -@@ -302,7 +302,7 @@ +@@ -332,7 +332,7 @@ } public T getValue() { - return (GameRules.GameRuleValue) this.b.apply(this); + return this.b.apply(this); // CraftBukkit - decompile error } - } + public void a(GameRules.GameRuleVisitor gamerules_gamerulevisitor, GameRules.GameRuleKey gamerules_gamerulekey) { diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch index f41446d0cd..b41b2f002c 100644 --- a/nms-patches/HandshakeListener.patch +++ b/nms-patches/HandshakeListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/HandshakeListener.java +++ b/net/minecraft/server/HandshakeListener.java -@@ -1,7 +1,17 @@ +@@ -1,7 +1,16 @@ package net.minecraft.server; +// CraftBukkit start @@ -14,26 +14,25 @@ + private static final HashMap throttleTracker = new HashMap(); + private static int throttleCounter = 0; + // CraftBukkit end -+ - private final MinecraftServer a; - private final NetworkManager b; - -@@ -17,6 +27,41 @@ - this.b.setProtocol(EnumProtocol.LOGIN); + private static final IChatBaseComponent a = new ChatComponentText("Ignoring status request"); + private final MinecraftServer b; + private final NetworkManager c; +@@ -18,6 +27,41 @@ + this.c.setProtocol(EnumProtocol.LOGIN); ChatMessage chatmessage; + // CraftBukkit start - Connection throttle + try { + long currentTime = System.currentTimeMillis(); -+ long connectionThrottle = MinecraftServer.getServer().server.getConnectionThrottle(); -+ InetAddress address = ((java.net.InetSocketAddress) this.b.getSocketAddress()).getAddress(); ++ long connectionThrottle = this.b.server.getConnectionThrottle(); ++ InetAddress address = ((java.net.InetSocketAddress) this.c.getSocketAddress()).getAddress(); + + synchronized (throttleTracker) { + if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { + throttleTracker.put(address, currentTime); + chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting."); -+ this.b.sendPacket(new PacketLoginOutDisconnect(chatmessage)); -+ this.b.close(chatmessage); ++ this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage)); ++ this.c.close(chatmessage); + return; + } + @@ -59,12 +58,12 @@ + if (packethandshakinginsetprotocol.c() > SharedConstants.getGameVersion().getProtocolVersion()) { chatmessage = new ChatMessage("multiplayer.disconnect.outdated_server", new Object[]{SharedConstants.getGameVersion().getName()}); - this.b.sendPacket(new PacketLoginOutDisconnect(chatmessage)); -@@ -27,6 +72,7 @@ - this.b.close(chatmessage); + this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage)); +@@ -28,6 +72,7 @@ + this.c.close(chatmessage); } else { - this.b.setPacketListener(new LoginListener(this.a, this.b)); -+ ((LoginListener) this.b.i()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname + this.c.setPacketListener(new LoginListener(this.b, this.c)); ++ ((LoginListener) this.c.i()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname } break; case STATUS: diff --git a/nms-patches/IBlockAccess.patch b/nms-patches/IBlockAccess.patch index 86400b59a5..4bb9af12f6 100644 --- a/nms-patches/IBlockAccess.patch +++ b/nms-patches/IBlockAccess.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/IBlockAccess.java +++ b/net/minecraft/server/IBlockAccess.java -@@ -25,8 +25,8 @@ - return 256; +@@ -30,8 +30,8 @@ + return BlockPosition.a(axisalignedbb).map(this::getType); } - default MovingObjectPositionBlock rayTrace(RayTrace raytrace) { @@ -11,7 +11,7 @@ IBlockData iblockdata = this.getType(blockposition); Fluid fluid = this.getFluid(blockposition); Vec3D vec3d = raytrace1.b(); -@@ -39,6 +39,12 @@ +@@ -44,6 +44,12 @@ double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.b().distanceSquared(movingobjectpositionblock1.getPos()); return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1; @@ -24,7 +24,7 @@ }, (raytrace1) -> { Vec3D vec3d = raytrace1.b().d(raytrace1.a()); -@@ -96,7 +102,7 @@ +@@ -101,7 +107,7 @@ double d13 = d10 * (i1 > 0 ? 1.0D - MathHelper.h(d4) : MathHelper.h(d4)); double d14 = d11 * (j1 > 0 ? 1.0D - MathHelper.h(d5) : MathHelper.h(d5)); diff --git a/nms-patches/IChatBaseComponent.patch b/nms-patches/IChatBaseComponent.patch new file mode 100644 index 0000000000..64fce6922a --- /dev/null +++ b/nms-patches/IChatBaseComponent.patch @@ -0,0 +1,25 @@ +--- a/net/minecraft/server/IChatBaseComponent.java ++++ b/net/minecraft/server/IChatBaseComponent.java +@@ -22,8 +22,21 @@ + import java.util.Map.Entry; + import java.util.Optional; + import javax.annotation.Nullable; ++// CraftBukkit start ++import com.google.common.collect.Streams; ++import java.util.stream.Stream; + +-public interface IChatBaseComponent extends Message, IChatFormatted { ++public interface IChatBaseComponent extends Message, IChatFormatted, Iterable { ++ ++ default Stream stream() { ++ return Streams.concat(new Stream[]{Stream.of(this), this.getSiblings().stream().flatMap(IChatBaseComponent::stream)}); ++ } ++ ++ @Override ++ default Iterator iterator() { ++ return this.stream().iterator(); ++ } ++ // CraftBukkit end + + ChatModifier getChatModifier(); + diff --git a/nms-patches/IChunkLoader.patch b/nms-patches/IChunkLoader.patch index b9e728ffe5..f90191bcc3 100644 --- a/nms-patches/IChunkLoader.patch +++ b/nms-patches/IChunkLoader.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/IChunkLoader.java +++ b/net/minecraft/server/IChunkLoader.java -@@ -18,15 +18,54 @@ - this.a = new IOWorker(new RegionFileCache(file), "chunk"); +@@ -18,10 +18,49 @@ + this.a = new IOWorker(file, flag, "chunk"); } -- public NBTTagCompound getChunkData(DimensionManager dimensionmanager, Supplier supplier, NBTTagCompound nbttagcompound) { +- public NBTTagCompound getChunkData(ResourceKey resourcekey, Supplier supplier, NBTTagCompound nbttagcompound) { + // CraftBukkit start + private boolean check(ChunkProviderServer cps, int x, int z) throws IOException { + ChunkCoordIntPair pos = new ChunkCoordIntPair(x, z); @@ -32,7 +32,7 @@ + } + // CraftBukkit end + -+ public NBTTagCompound getChunkData(DimensionManager dimensionmanager, Supplier supplier, NBTTagCompound nbttagcompound, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException { ++ public NBTTagCompound getChunkData(ResourceKey resourcekey, Supplier supplier, NBTTagCompound nbttagcompound, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException { int i = a(nbttagcompound); boolean flag = true; @@ -51,9 +51,3 @@ if (i < 1493) { nbttagcompound = GameProfileSerializer.a(this.b, DataFixTypes.CHUNK, nbttagcompound, i, 1493); if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { - if (this.c == null) { -- this.c = PersistentStructureLegacy.a(dimensionmanager, (WorldPersistentData) supplier.get()); -+ this.c = PersistentStructureLegacy.a(dimensionmanager.getType(), (WorldPersistentData) supplier.get()); // CraftBukkit - getType - } - - nbttagcompound = this.c.a(nbttagcompound); diff --git a/nms-patches/ICommandListener.patch b/nms-patches/ICommandListener.patch index e9d99ff130..d28dc9f20a 100644 --- a/nms-patches/ICommandListener.patch +++ b/nms-patches/ICommandListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ICommandListener.java +++ b/net/minecraft/server/ICommandListener.java -@@ -20,6 +20,13 @@ +@@ -22,6 +22,13 @@ public boolean shouldBroadcastCommands() { return false; } @@ -13,8 +13,8 @@ + // CraftBukkit end }; - void sendMessage(IChatBaseComponent ichatbasecomponent); -@@ -29,4 +36,6 @@ + void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid); +@@ -31,4 +38,6 @@ boolean shouldSendFailure(); boolean shouldBroadcastCommands(); diff --git a/nms-patches/IDispenseBehavior.patch b/nms-patches/IDispenseBehavior.patch index c51176a961..b8b3fcf231 100644 --- a/nms-patches/IDispenseBehavior.patch +++ b/nms-patches/IDispenseBehavior.patch @@ -63,7 +63,7 @@ } @@ -127,8 +136,36 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).b(itemstack.getTag()); + EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag()); + // CraftBukkit start + World world = isourceblock.getWorld(); @@ -134,24 +134,24 @@ EntityArmorStand entityarmorstand = new EntityArmorStand(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); EntityTypes.a(world, (EntityHuman) null, (Entity) entityarmorstand, itemstack.getTag()); - entityarmorstand.yaw = enumdirection.n(); + entityarmorstand.yaw = enumdirection.o(); world.addEntity(entityarmorstand); - itemstack.subtract(1); + // itemstack.subtract(1); // CraftBukkit - Handled during event processing return itemstack; } })); -@@ -165,11 +230,40 @@ - double d3 = isourceblock.getX() + d0; - double d4 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F); - double d5 = isourceblock.getZ() + d2; +@@ -252,12 +317,41 @@ + @Override + public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); + // CraftBukkit start + World world = isourceblock.getWorld(); + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2)); ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getAdjacentX(), enumdirection.getAdjacentY(), enumdirection.getAdjacentZ())); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } @@ -173,9 +173,10 @@ + } + + itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); - EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), itemstack, d3, d4, d5, true); + EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), itemstack, isourceblock.getX(), isourceblock.getY(), isourceblock.getX(), true); - entityfireworks.shoot(d0, d1, d2, 0.5F, 1.0F); + IDispenseBehavior.a(isourceblock, entityfireworks, enumdirection); + entityfireworks.shoot((double) enumdirection.getAdjacentX(), (double) enumdirection.getAdjacentY(), (double) enumdirection.getAdjacentZ(), 0.5F, 1.0F); isourceblock.getWorld().addEntity(entityfireworks); - itemstack.subtract(1); + // itemstack.subtract(1); // Handled during event processing @@ -183,12 +184,12 @@ return itemstack; } -@@ -192,10 +286,39 @@ +@@ -280,10 +374,39 @@ double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); - world.addEntity((Entity) SystemUtils.a((Object) (new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5)), (entitysmallfireball) -> { -- entitysmallfireball.b(itemstack); +- entitysmallfireball.setItem(itemstack); - })); - itemstack.subtract(1); + // CraftBukkit start @@ -218,7 +219,7 @@ + } + + EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); -+ entitysmallfireball.b(itemstack1); ++ entitysmallfireball.setItem(itemstack1); + entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); + + world.addEntity(entitysmallfireball); @@ -227,7 +228,7 @@ return itemstack; } -@@ -219,9 +342,52 @@ +@@ -307,9 +430,52 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); World world = isourceblock.getWorld(); @@ -281,7 +282,7 @@ } else { return this.b.dispense(isourceblock, itemstack); } -@@ -245,13 +411,39 @@ +@@ -333,13 +499,39 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource) { @@ -322,7 +323,7 @@ itemstack.subtract(1); if (itemstack.isEmpty()) { return new ItemStack(item); -@@ -273,12 +465,40 @@ +@@ -361,12 +553,40 @@ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { World world = isourceblock.getWorld(); @@ -350,22 +351,22 @@ + } + // CraftBukkit end + - this.dispensed = true; + this.a(true); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); IBlockData iblockdata = world.getType(blockposition); - if (ItemFlintAndSteel.a(iblockdata, (GeneratorAccess) world, blockposition)) { -- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + if (BlockFireAbstract.a((GeneratorAccess) world, blockposition)) { +- world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition)); + // CraftBukkit start - Ignition by dispensing flint and steel + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, isourceblock.getBlockPosition()).isCancelled()) { -+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); ++ world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition)); + } + // CraftBukkit end - } else if (ItemFlintAndSteel.a(iblockdata)) { + } else if (BlockCampfire.h(iblockdata)) { world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true)); } else if (iblockdata.getBlock() instanceof BlockTNT) { -@@ -301,12 +521,57 @@ - this.dispensed = true; +@@ -389,12 +609,57 @@ + this.a(true); World world = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); + // CraftBukkit start @@ -395,7 +396,7 @@ + // CraftBukkit end if (!ItemBoneMeal.a(itemstack, world, blockposition) && !ItemBoneMeal.a(itemstack, world, blockposition, (EnumDirection) null)) { - this.dispensed = false; + this.a(false); } else if (!world.isClientSide) { world.triggerEffect(2005, blockposition, 0); } @@ -422,7 +423,7 @@ return itemstack; } -@@ -316,11 +581,40 @@ +@@ -404,11 +669,40 @@ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { World world = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); @@ -465,7 +466,7 @@ return itemstack; } })); -@@ -344,6 +638,30 @@ +@@ -432,6 +726,30 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); @@ -494,9 +495,9 @@ + // CraftBukkit end + if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) { - world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.m() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); + world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); TileEntity tileentity = world.getTileEntity(blockposition); -@@ -368,6 +686,30 @@ +@@ -456,6 +774,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; @@ -527,9 +528,9 @@ if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) { if (!world.isClientSide) { world.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3); -@@ -416,6 +758,30 @@ +@@ -503,6 +845,30 @@ + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); IBlockData iblockdata = world.getType(blockposition); - Block block = iblockdata.getBlock(); + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); @@ -555,48 +556,6 @@ + } + // CraftBukkit end + - if (block.a(TagsBlock.BEEHIVES) && (Integer) iblockdata.get(BlockBeehive.c) >= 5) { - ((BlockBeehive) iblockdata.getBlock()).a(world.getMinecraftWorld(), iblockdata, blockposition, (EntityHuman) null, TileEntityBeehive.ReleaseStatus.BEE_RELEASED); - this.dispensed = true; -@@ -432,6 +798,29 @@ - @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ // CraftBukkit end - - if (!world.p_()) { - this.dispensed = false; -@@ -443,6 +832,11 @@ - EntitySheep entitysheep = (EntitySheep) iterator1.next(); - - if (entitysheep.isAlive() && !entitysheep.isSheared() && !entitysheep.isBaby()) { -+ // CraftBukkit start -+ if (CraftEventFactory.callBlockShearEntityEvent(entitysheep, bukkitBlock, craftItem).isCancelled()) { -+ continue; -+ } -+ // CraftBukkit end - entitysheep.shear(); - if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { - itemstack.setCount(0); + if (iblockdata.a((Tag) TagsBlock.BEEHIVES, (blockbase_blockdata) -> { + return blockbase_blockdata.b(BlockBeehive.b); + }) && (Integer) iblockdata.get(BlockBeehive.b) >= 5) { diff --git a/nms-patches/IEntityAngerable.patch b/nms-patches/IEntityAngerable.patch new file mode 100644 index 0000000000..dbb196ef20 --- /dev/null +++ b/nms-patches/IEntityAngerable.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/IEntityAngerable.java ++++ b/net/minecraft/server/IEntityAngerable.java +@@ -98,7 +98,7 @@ + default void pacify() { + this.setLastDamager((EntityLiving) null); + this.setAngerTarget((UUID) null); +- this.setGoalTarget((EntityLiving) null); ++ this.setGoalTarget((EntityLiving) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit + this.setAnger(0); + } + +@@ -108,6 +108,8 @@ + + void setGoalTarget(@Nullable EntityLiving entityliving); + ++ boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit ++ + @Nullable + EntityLiving getGoalTarget(); + } diff --git a/nms-patches/IProjectile.patch b/nms-patches/IProjectile.patch new file mode 100644 index 0000000000..0f195b0bff --- /dev/null +++ b/nms-patches/IProjectile.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/server/IProjectile.java ++++ b/net/minecraft/server/IProjectile.java +@@ -4,6 +4,10 @@ + import java.util.UUID; + import javax.annotation.Nullable; + ++// CraftBukkit start ++import org.bukkit.entity.LivingEntity; ++// CraftBukkit end ++ + public abstract class IProjectile extends Entity { + + private UUID shooter; +@@ -19,6 +23,7 @@ + this.shooter = entity.getUniqueID(); + this.c = entity.getId(); + } ++ this.projectileSource = entity == null ? null : (LivingEntity) entity.getBukkitEntity(); // CraftBukkit + + } + +@@ -101,6 +106,7 @@ + } + + protected void a(MovingObjectPosition movingobjectposition) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event + MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); + + if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) { diff --git a/nms-patches/IRecipeComplex.patch b/nms-patches/IRecipeComplex.patch index ed9068af22..87925e273f 100644 --- a/nms-patches/IRecipeComplex.patch +++ b/nms-patches/IRecipeComplex.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/IRecipeComplex.java @@ -22,4 +22,11 @@ public ItemStack getResult() { - return ItemStack.a; + return ItemStack.b; } + + // CraftBukkit start diff --git a/nms-patches/IWorldWriter.patch b/nms-patches/IWorldWriter.patch index 4c6eae9240..af2348e0f5 100644 --- a/nms-patches/IWorldWriter.patch +++ b/nms-patches/IWorldWriter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/IWorldWriter.java +++ b/net/minecraft/server/IWorldWriter.java -@@ -17,4 +17,10 @@ +@@ -25,4 +25,10 @@ default boolean addEntity(Entity entity) { return false; } diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch index 949e9c0d7d..3724f90b6c 100644 --- a/nms-patches/InventoryCraftResult.patch +++ b/nms-patches/InventoryCraftResult.patch @@ -49,5 +49,5 @@ + // CraftBukkit end + public InventoryCraftResult() { - this.items = NonNullList.a(1, ItemStack.a); + this.items = NonNullList.a(1, ItemStack.b); } diff --git a/nms-patches/InventoryCrafting.patch b/nms-patches/InventoryCrafting.patch index 1738e42dbe..d749d7fc07 100644 --- a/nms-patches/InventoryCrafting.patch +++ b/nms-patches/InventoryCrafting.patch @@ -82,5 +82,5 @@ + // CraftBukkit end + public InventoryCrafting(Container container, int i, int j) { - this.items = NonNullList.a(i * j, ItemStack.a); + this.items = NonNullList.a(i * j, ItemStack.b); this.container = container; diff --git a/nms-patches/InventoryMerchant.patch b/nms-patches/InventoryMerchant.patch index e41418c394..a57eb6323f 100644 --- a/nms-patches/InventoryMerchant.patch +++ b/nms-patches/InventoryMerchant.patch @@ -59,5 +59,5 @@ + // CraftBukkit end + public InventoryMerchant(IMerchant imerchant) { - this.itemsInSlots = NonNullList.a(3, ItemStack.a); + this.itemsInSlots = NonNullList.a(3, ItemStack.b); this.merchant = imerchant; diff --git a/nms-patches/InventorySubcontainer.patch b/nms-patches/InventorySubcontainer.patch index 6f6421f372..2f197fe4ac 100644 --- a/nms-patches/InventorySubcontainer.patch +++ b/nms-patches/InventorySubcontainer.patch @@ -63,5 +63,5 @@ + this.bukkitOwner = owner; + // CraftBukkit end this.a = i; - this.items = NonNullList.a(i, ItemStack.a); + this.items = NonNullList.a(i, ItemStack.b); } diff --git a/nms-patches/ItemArmor.patch b/nms-patches/ItemArmor.patch index b81c7771c1..ea82db9e79 100644 --- a/nms-patches/ItemArmor.patch +++ b/nms-patches/ItemArmor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemArmor.java +++ b/net/minecraft/server/ItemArmor.java -@@ -4,6 +4,11 @@ +@@ -6,6 +6,11 @@ import java.util.List; import java.util.UUID; @@ -9,12 +9,12 @@ +import org.bukkit.event.block.BlockDispenseArmorEvent; +// CraftBukkit end + - public class ItemArmor extends Item { + public class ItemArmor extends Item implements ItemWearable { - private static final UUID[] k = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; -@@ -28,6 +33,32 @@ + private static final UUID[] j = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; +@@ -32,6 +37,32 @@ EntityLiving entityliving = (EntityLiving) list.get(0); - EnumItemSlot enumitemslot = EntityInsentient.h(itemstack); + EnumItemSlot enumitemslot = EntityInsentient.j(itemstack); ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + // CraftBukkit start + World world = isourceblock.getWorld(); diff --git a/nms-patches/ItemArmorStand.patch b/nms-patches/ItemArmorStand.patch index f527613776..4694e638ac 100644 --- a/nms-patches/ItemArmorStand.patch +++ b/nms-patches/ItemArmorStand.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/ItemArmorStand.java +++ b/net/minecraft/server/ItemArmorStand.java -@@ -41,6 +41,11 @@ - entityarmorstand.setPositionRotation(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F); - this.a(entityarmorstand, world.random); - EntityTypes.a(world, itemactioncontext.getEntity(), (Entity) entityarmorstand, itemstack.getTag()); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityarmorstand).isCancelled()) { -+ return EnumInteractionResult.FAIL; -+ } -+ // CraftBukkit end - world.addEntity(entityarmorstand); - world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ENTITY_ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); - } +@@ -27,6 +27,11 @@ + + entityarmorstand.setPositionRotation(entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), f, 0.0F); + this.a(entityarmorstand, world.random); ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityarmorstand).isCancelled()) { ++ return EnumInteractionResult.FAIL; ++ } ++ // CraftBukkit end + world.addEntity(entityarmorstand); + world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ENTITY_ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F); + } diff --git a/nms-patches/ItemBlock.patch b/nms-patches/ItemBlock.patch index 1bef5bfce6..e56765ef61 100644 --- a/nms-patches/ItemBlock.patch +++ b/nms-patches/ItemBlock.patch @@ -14,14 +14,14 @@ @@ -55,7 +60,7 @@ - SoundEffectType soundeffecttype = iblockdata1.r(); + SoundEffectType soundeffecttype = iblockdata1.getStepSound(); - world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); + // world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); - itemstack.subtract(1); - return EnumInteractionResult.SUCCESS; - } -@@ -89,6 +94,21 @@ + if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); + } +@@ -92,6 +97,21 @@ if (nbttagcompound != null) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag"); @@ -43,7 +43,7 @@ BlockStateList blockstatelist = iblockdata.getBlock().getStates(); Iterator iterator = nbttagcompound1.getKeys().iterator(); -@@ -103,11 +123,6 @@ +@@ -106,11 +126,6 @@ } } } @@ -55,20 +55,20 @@ return iblockdata1; } -@@ -120,8 +135,15 @@ +@@ -123,8 +138,15 @@ protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) { EntityHuman entityhuman = blockactioncontext.getEntity(); VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman); + // CraftBukkit start - store default return -+ boolean defaultReturn = (!this.T_() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); ++ boolean defaultReturn = (!this.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); + org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null; + + BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn); + blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event); -- return (!this.T_() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); +- return (!this.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); + return event.isBuildable(); + // CraftBukkit end } - protected boolean T_() { + protected boolean isCheckCollisions() { diff --git a/nms-patches/ItemBoat.patch b/nms-patches/ItemBoat.patch index 4c3a6c26b3..c8556d1bf2 100644 --- a/nms-patches/ItemBoat.patch +++ b/nms-patches/ItemBoat.patch @@ -1,21 +1,20 @@ --- a/net/minecraft/server/ItemBoat.java +++ b/net/minecraft/server/ItemBoat.java -@@ -41,6 +41,14 @@ +@@ -41,6 +41,13 @@ } - if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { + if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { + // CraftBukkit start - Boat placement -+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, enumhand); + + if (event.isCancelled()) { + return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); + } + // CraftBukkit end - EntityBoat entityboat = new EntityBoat(world, movingobjectposition.getPos().x, movingobjectposition.getPos().y, movingobjectposition.getPos().z); + EntityBoat entityboat = new EntityBoat(world, movingobjectpositionblock.getPos().x, movingobjectpositionblock.getPos().y, movingobjectpositionblock.getPos().z); entityboat.setType(this.b); -@@ -49,7 +57,15 @@ +@@ -49,7 +56,15 @@ return InteractionResultWrapper.fail(itemstack); } else { if (!world.isClientSide) { diff --git a/nms-patches/ItemBow.patch b/nms-patches/ItemBow.patch index 05df59f98b..b126b01ccb 100644 --- a/nms-patches/ItemBow.patch +++ b/nms-patches/ItemBow.patch @@ -1,23 +1,6 @@ --- a/net/minecraft/server/ItemBow.java +++ b/net/minecraft/server/ItemBow.java -@@ -6,12 +6,16 @@ - - public ItemBow(Item.Info item_info) { - super(item_info); -+ // CraftBukkit start - obfuscator went a little crazy -+ /* - this.a(new MinecraftKey("pull"), (itemstack, world, entityliving) -> { - return entityliving == null ? 0.0F : (entityliving.dD().getItem() != Items.BOW ? 0.0F : (float) (itemstack.k() - entityliving.dE()) / 20.0F); - }); - this.a(new MinecraftKey("pulling"), (itemstack, world, entityliving) -> { - return entityliving != null && entityliving.isHandRaised() && entityliving.dD() == itemstack ? 1.0F : 0.0F; - }); -+ */ -+ // CraftBukkit end - } - - @Override -@@ -56,6 +60,13 @@ +@@ -50,6 +50,13 @@ if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) { entityarrow.setOnFire(100); } @@ -31,7 +14,7 @@ itemstack.damage(1, entityhuman, (entityhuman1) -> { entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand()); -@@ -64,7 +75,16 @@ +@@ -58,7 +65,16 @@ entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; } @@ -48,4 +31,4 @@ + // CraftBukkit end } - world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.i.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.RANDOM.nextFloat() * 0.4F + 1.2F) + f * 0.5F); diff --git a/nms-patches/ItemBucket.patch b/nms-patches/ItemBucket.patch index a0975c9a0f..0469ba2093 100644 --- a/nms-patches/ItemBucket.patch +++ b/nms-patches/ItemBucket.patch @@ -20,7 +20,7 @@ if (iblockdata.getBlock() instanceof IFluidSource) { + // CraftBukkit start + FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); -+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.a()); ++ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.a()); + + if (event.isCancelled()) { + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) @@ -32,9 +32,9 @@ if (fluidtype != FluidTypes.EMPTY) { entityhuman.b(StatisticList.ITEM_USED.b(this)); - entityhuman.a(fluidtype.a(TagsFluid.LAVA) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F); -- ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.a()); -+ ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.a(), event.getItemStack()); // CraftBukkit + entityhuman.playSound(fluidtype.a((Tag) TagsFluid.LAVA) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F); +- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(fluidtype.a())); ++ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit if (!world.isClientSide) { CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.a())); @@ -42,40 +42,14 @@ iblockdata = world.getType(blockposition); BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : blockposition1; -- if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock)) { -+ if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit +- if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1)) { ++ if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1, movingobjectpositionblock1.getDirection(), blockposition, itemstack)) { // CraftBukkit this.a(world, itemstack, blockposition2); if (entityhuman instanceof EntityPlayer) { CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition2, itemstack); -@@ -76,16 +93,19 @@ - +@@ -77,6 +94,11 @@ public void a(World world, ItemStack itemstack, BlockPosition blockposition) {} -- private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item) { -+ // CraftBukkit - added ob.ItemStack result - TODO: Is this... the right way to handle this? -+ private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item, org.bukkit.inventory.ItemStack result) { - if (entityhuman.abilities.canInstantlyBuild) { - return itemstack; - } else { - itemstack.subtract(1); - if (itemstack.isEmpty()) { -- return new ItemStack(item); -+ // CraftBukkit start -+ return CraftItemStack.asNMSCopy(result); - } else { -- if (!entityhuman.inventory.pickup(new ItemStack(item))) { -- entityhuman.drop(new ItemStack(item), false); -+ if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(result))) { -+ entityhuman.drop(CraftItemStack.asNMSCopy(result), false); -+ // CraftBukkit end - } - - return itemstack; -@@ -93,7 +113,13 @@ - } - } - -+ // CraftBukkit start public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) { + return a(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null); + } @@ -85,23 +59,20 @@ if (!(this.fluidType instanceof FluidTypeFlowing)) { return false; } else { -@@ -102,8 +128,18 @@ +@@ -86,6 +108,16 @@ boolean flag = iblockdata.a(this.fluidType); + boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlace(world, blockposition, iblockdata, this.fluidType); - if (!iblockdata.isAir() && !flag && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, this.fluidType))) { -- return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null); -+ return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit - } else { -+ // CraftBukkit start -+ if (entityhuman != null) { -+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(world, entityhuman, blockposition, clicked, enumdirection, itemstack); -+ if (event.isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity -+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 -+ return false; -+ } ++ // CraftBukkit start ++ if (flag1 && entityhuman != null) { ++ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityhuman, blockposition, clicked, enumdirection, itemstack); ++ if (event.isCancelled()) { ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity ++ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 ++ return false; + } -+ // CraftBukkit end - if (world.worldProvider.isNether() && this.fluidType.a(TagsFluid.WATER)) { - int i = blockposition.getX(); - int j = blockposition.getY(); ++ } ++ // CraftBukkit end + if (!flag1) { + return movingobjectpositionblock != null && this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null); + } else if (world.getDimensionManager().isNether() && this.fluidType.a((Tag) TagsFluid.WATER)) { diff --git a/nms-patches/ItemCrossbow.patch b/nms-patches/ItemCrossbow.patch index 8dcb5107a7..4d6090a589 100644 --- a/nms-patches/ItemCrossbow.patch +++ b/nms-patches/ItemCrossbow.patch @@ -1,24 +1,6 @@ --- a/net/minecraft/server/ItemCrossbow.java +++ b/net/minecraft/server/ItemCrossbow.java -@@ -12,6 +12,8 @@ - - public ItemCrossbow(Item.Info item_info) { - super(item_info); -+ // CraftBukkit start - obfuscator went a little crazy -+ /* - this.a(new MinecraftKey("pull"), (itemstack, world, entityliving) -> { - return entityliving != null && itemstack.getItem() == this ? (d(itemstack) ? 0.0F : (float) (itemstack.k() - entityliving.dE()) / (float) e(itemstack)) : 0.0F; - }); -@@ -24,6 +26,8 @@ - this.a(new MinecraftKey("firework"), (itemstack, world, entityliving) -> { - return entityliving != null && d(itemstack) && a(itemstack, Items.FIREWORK_ROCKET) ? 1.0F : 0.0F; - }); -+ */ -+ // CraftBukkit end - } - - @Override -@@ -87,6 +91,11 @@ +@@ -75,6 +75,11 @@ itemstack1 = new ItemStack(Items.ARROW); itemstack2 = itemstack1.cloneItemStack(); } @@ -30,7 +12,7 @@ if (!a(entityliving, itemstack, itemstack1, k > 0, flag)) { return false; -@@ -210,11 +219,27 @@ +@@ -198,11 +203,27 @@ vector3fa.a(quaternion); ((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2); } diff --git a/nms-patches/ItemDye.patch b/nms-patches/ItemDye.patch index 8a51051561..cf5da62a51 100644 --- a/nms-patches/ItemDye.patch +++ b/nms-patches/ItemDye.patch @@ -9,22 +9,22 @@ public class ItemDye extends Item { private static final Map a = Maps.newEnumMap(EnumColor.class); -@@ -20,7 +22,17 @@ - EntitySheep entitysheep = (EntitySheep) entityliving; +@@ -21,7 +23,17 @@ if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.b) { -- entitysheep.setColor(this.b); -+ // CraftBukkit start -+ byte bColor = (byte) this.b.getColorIndex(); -+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor)); -+ entitysheep.world.getServer().getPluginManager().callEvent(event); + if (!entityhuman.world.isClientSide) { +- entitysheep.setColor(this.b); ++ // CraftBukkit start ++ byte bColor = (byte) this.b.getColorIndex(); ++ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor)); ++ entitysheep.world.getServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ return false; -+ } ++ if (event.isCancelled()) { ++ return EnumInteractionResult.PASS; ++ } + -+ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData())); -+ // CraftBukkit end - itemstack.subtract(1); - } ++ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData())); ++ // CraftBukkit end + itemstack.subtract(1); + } diff --git a/nms-patches/ItemEgg.patch b/nms-patches/ItemEgg.patch index 1d8ea9d8dc..f72b75a5e4 100644 --- a/nms-patches/ItemEgg.patch +++ b/nms-patches/ItemEgg.patch @@ -4,8 +4,8 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.i.nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.i.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down +- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); ++ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down if (!world.isClientSide) { EntityEgg entityegg = new EntityEgg(world, entityhuman); @@ -21,7 +21,7 @@ + } + // CraftBukkit end } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.i.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above ++ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above entityhuman.b(StatisticList.ITEM_USED.b(this)); if (!entityhuman.abilities.canInstantlyBuild) { diff --git a/nms-patches/ItemEndCrystal.patch b/nms-patches/ItemEndCrystal.patch index c3318df4df..7007204f4b 100644 --- a/nms-patches/ItemEndCrystal.patch +++ b/nms-patches/ItemEndCrystal.patch @@ -10,5 +10,5 @@ + } + // CraftBukkit end world.addEntity(entityendercrystal); - if (world.worldProvider instanceof WorldProviderTheEnd) { - EnderDragonBattle enderdragonbattle = ((WorldProviderTheEnd) world.worldProvider).o(); + EnderDragonBattle enderdragonbattle = ((WorldServer) world).getDragonBattle(); + diff --git a/nms-patches/ItemEnderPearl.patch b/nms-patches/ItemEnderPearl.patch index 530e419b64..7bac2c2e37 100644 --- a/nms-patches/ItemEnderPearl.patch +++ b/nms-patches/ItemEnderPearl.patch @@ -4,7 +4,7 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.i.nextFloat() * 0.4F + 0.8F)); +- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F)); - entityhuman.getCooldownTracker().setCooldown(this, 20); + // CraftBukkit start - change order if (!world.isClientSide) { @@ -21,7 +21,7 @@ + } } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.i.nextFloat() * 0.4F + 0.8F)); ++ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F)); + entityhuman.getCooldownTracker().setCooldown(this, 20); + // CraftBukkit end + diff --git a/nms-patches/ItemFireball.patch b/nms-patches/ItemFireball.patch index 2cafb967bd..9a5088ab91 100644 --- a/nms-patches/ItemFireball.patch +++ b/nms-patches/ItemFireball.patch @@ -1,24 +1,23 @@ --- a/net/minecraft/server/ItemFireball.java +++ b/net/minecraft/server/ItemFireball.java -@@ -15,6 +15,14 @@ +@@ -14,12 +14,28 @@ + boolean flag = false; - if (iblockdata.getBlock() == Blocks.CAMPFIRE) { - if (!(Boolean) iblockdata.get(BlockCampfire.b) && !(Boolean) iblockdata.get(BlockCampfire.d)) { -+ // CraftBukkit start - fire BlockIgniteEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { -+ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) { -+ itemactioncontext.getItemStack().subtract(1); -+ } -+ return EnumInteractionResult.PASS; + if (BlockCampfire.h(iblockdata)) { ++ // CraftBukkit start - fire BlockIgniteEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { ++ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) { ++ itemactioncontext.getItemStack().subtract(1); + } -+ // CraftBukkit end - this.a(world, blockposition); - world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.b, true)); - flag = true; -@@ -22,6 +30,14 @@ ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.a(world, blockposition); + world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.b, true)); + flag = true; } else { blockposition = blockposition.shift(itemactioncontext.getClickedFace()); - if (world.getType(blockposition).isAir()) { + if (BlockFireAbstract.a((GeneratorAccess) world, blockposition)) { + // CraftBukkit start - fire BlockIgniteEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { + if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) { @@ -28,5 +27,5 @@ + } + // CraftBukkit end this.a(world, blockposition); - world.setTypeUpdate(blockposition, ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition)); + world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition)); flag = true; diff --git a/nms-patches/ItemFishingRod.patch b/nms-patches/ItemFishingRod.patch index d590159894..99bf8f9f27 100644 --- a/nms-patches/ItemFishingRod.patch +++ b/nms-patches/ItemFishingRod.patch @@ -1,34 +1,19 @@ --- a/net/minecraft/server/ItemFishingRod.java +++ b/net/minecraft/server/ItemFishingRod.java -@@ -1,9 +1,13 @@ +@@ -1,5 +1,7 @@ package net.minecraft.server; +import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit + - public class ItemFishingRod extends Item { + public class ItemFishingRod extends Item implements ItemVanishable { public ItemFishingRod(Item.Info item_info) { - super(item_info); -+ // CraftBukkit start - obfuscator went a little crazy -+ /* - this.a(new MinecraftKey("cast"), (itemstack, world, entityliving) -> { - if (entityliving == null) { - return 0.0F; -@@ -18,6 +22,8 @@ - return (flag || flag1) && entityliving instanceof EntityHuman && ((EntityHuman) entityliving).hookedFish != null ? 1.0F : 0.0F; - } - }); -+ */ -+ // CraftBukkit end - } +@@ -21,12 +23,23 @@ - @Override -@@ -35,12 +41,23 @@ - - world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); + world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F)); } else { -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); +- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F)); ++ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F)); if (!world.isClientSide) { i = EnchantmentManager.c(itemstack); int j = EnchantmentManager.b(itemstack); @@ -43,7 +28,7 @@ + entityhuman.hookedFish = null; + return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); + } -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); ++ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F)); + world.addEntity(entityfishinghook); + // CraftBukkit end } diff --git a/nms-patches/ItemFlintAndSteel.patch b/nms-patches/ItemFlintAndSteel.patch index 73c644ba6f..639d4ce650 100644 --- a/nms-patches/ItemFlintAndSteel.patch +++ b/nms-patches/ItemFlintAndSteel.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/ItemFlintAndSteel.java +++ b/net/minecraft/server/ItemFlintAndSteel.java -@@ -29,6 +29,14 @@ +@@ -27,6 +27,14 @@ BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace()); - if (a(world.getType(blockposition1), (GeneratorAccess) world, blockposition1)) { + if (BlockFireAbstract.a((GeneratorAccess) world, blockposition1)) { + // CraftBukkit start - Store the clicked block + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { + itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> { @@ -12,6 +12,6 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.playSound(entityhuman, blockposition1, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.i.nextFloat() * 0.4F + 0.8F); - IBlockData iblockdata1 = ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition1); + world.playSound(entityhuman, blockposition1, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F); + IBlockData iblockdata1 = BlockFireAbstract.a((IBlockAccess) world, blockposition1); diff --git a/nms-patches/ItemMonsterEgg.patch b/nms-patches/ItemMonsterEgg.patch new file mode 100644 index 0000000000..1d6c210a63 --- /dev/null +++ b/nms-patches/ItemMonsterEgg.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/ItemMonsterEgg.java ++++ b/net/minecraft/server/ItemMonsterEgg.java +@@ -141,7 +141,7 @@ + return Optional.empty(); + } else { + ((EntityInsentient) object).setPositionRotation(vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.0F, 0.0F); +- world.addEntity((Entity) object); ++ world.addEntity((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit + if (itemstack.hasName()) { + ((EntityInsentient) object).setCustomName(itemstack.getName()); + } +@@ -150,7 +150,7 @@ + itemstack.subtract(1); + } + +- return Optional.of(object); ++ return Optional.of((EntityInsentient) object); // CraftBukkit - decompile error + } + } + } diff --git a/nms-patches/ItemPotion.patch b/nms-patches/ItemPotion.patch index 8969268aca..aba701ca9e 100644 --- a/nms-patches/ItemPotion.patch +++ b/nms-patches/ItemPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemPotion.java +++ b/net/minecraft/server/ItemPotion.java -@@ -27,7 +27,7 @@ +@@ -32,7 +32,7 @@ if (mobeffect.getMobEffect().isInstant()) { mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D); } else { diff --git a/nms-patches/ItemSnowball.patch b/nms-patches/ItemSnowball.patch index 01d836c7f5..f8e1d4a11d 100644 --- a/nms-patches/ItemSnowball.patch +++ b/nms-patches/ItemSnowball.patch @@ -4,9 +4,9 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.i.nextFloat() * 0.4F + 0.8F)); +- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F)); + // CraftBukkit - moved down -+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.i.nextFloat() * 0.4F + 0.8F)); ++ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F)); if (!world.isClientSide) { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); @@ -18,7 +18,7 @@ + itemstack.subtract(1); + } + -+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.i.nextFloat() * 0.4F + 0.8F)); ++ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F)); + } else if (entityhuman instanceof EntityPlayer) { + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } @@ -33,5 +33,5 @@ } + */ - return InteractionResultWrapper.success(itemstack); + return InteractionResultWrapper.a(itemstack, world.s_()); } diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch index dc8d08deab..4b5825947d 100644 --- a/nms-patches/ItemStack.patch +++ b/nms-patches/ItemStack.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/ItemStack.java +++ b/net/minecraft/server/ItemStack.java -@@ -16,6 +16,24 @@ +@@ -19,6 +19,24 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start -+import com.mojang.datafixers.Dynamic; ++import com.mojang.serialization.Dynamic; +import java.util.List; +import java.util.Map; + @@ -24,8 +24,17 @@ + public final class ItemStack { + public static final Codec a = RecordCodecBuilder.create((instance) -> { +@@ -32,7 +50,7 @@ + }); private static final Logger LOGGER = LogManager.getLogger(); -@@ -54,23 +72,42 @@ + public static final ItemStack b = new ItemStack((Item) null); +- public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((Object) (new DecimalFormat("#.##")), (decimalformat) -> { ++ public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((new DecimalFormat("#.##")), (decimalformat) -> { // CraftBukkit - decompile error + decimalformat.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT)); + }); + private static final ChatModifier e = ChatModifier.b.setColor(EnumChatFormat.DARK_PURPLE).setItalic(true); +@@ -67,23 +85,42 @@ this.checkEmpty(); } @@ -40,9 +49,9 @@ + } + private void checkEmpty() { -+ if (this.h && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit - this.h = false; - this.h = this.isEmpty(); ++ if (this.j && this == ItemStack.b) throw new AssertionError("TRAP"); // CraftBukkit + this.j = false; + this.j = this.isEmpty(); } - private ItemStack(NBTTagCompound nbttagcompound) { @@ -52,10 +61,10 @@ this.count = nbttagcompound.getByte("Count"); if (nbttagcompound.hasKeyOfType("tag", 10)) { - this.tag = nbttagcompound.getCompound("tag"); -- this.getItem().a(nbttagcompound); +- this.getItem().b(nbttagcompound); + // CraftBukkit start - make defensive copy as this data may be coming from the save thread + this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); -+ this.getItem().a(this.tag); ++ this.getItem().b(this.tag); + // CraftBukkit end } @@ -71,8 +80,8 @@ this.checkEmpty(); } -@@ -100,7 +137,7 @@ - return this.h ? Items.AIR : this.item; +@@ -113,7 +150,7 @@ + return this.j ? Items.AIR : this.item; } - public EnumInteractionResult placeItem(ItemActionContext itemactioncontext) { @@ -80,14 +89,14 @@ EntityHuman entityhuman = itemactioncontext.getEntity(); BlockPosition blockposition = itemactioncontext.getClickPosition(); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false); -@@ -108,12 +145,153 @@ - if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().t(), shapedetectorblock)) { +@@ -121,12 +158,153 @@ + if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().p(), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { + // CraftBukkit start - handle all block place event logic here + NBTTagCompound oldData = this.getTagClone(); + int oldCount = this.getCount(); -+ World world = itemactioncontext.getWorld(); ++ WorldServer world = (WorldServer) itemactioncontext.getWorld(); + + if (!(this.getItem() instanceof ItemBucket)) { // if not bucket + world.captureBlockStates = true; @@ -103,7 +112,7 @@ + this.setCount(oldCount); + this.setTagClone(oldData); + world.captureBlockStates = false; -+ if (enuminteractionresult == EnumInteractionResult.SUCCESS && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { ++ if (enuminteractionresult.a() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { + world.captureTreeGeneration = false; + Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); + TreeType treeType = BlockSapling.treeType; @@ -136,7 +145,7 @@ + } + world.captureTreeGeneration = false; - if (entityhuman != null && enuminteractionresult == EnumInteractionResult.SUCCESS) { + if (entityhuman != null && enuminteractionresult.a()) { - entityhuman.b(StatisticList.ITEM_USED.b(item)); + org.bukkit.event.block.BlockPlaceEvent placeEvent = null; + List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); @@ -235,7 +244,7 @@ return enuminteractionresult; } -@@ -194,6 +372,21 @@ +@@ -207,6 +385,21 @@ } i -= k; @@ -257,7 +266,7 @@ if (i <= 0) { return false; } -@@ -215,6 +408,11 @@ +@@ -228,6 +421,11 @@ if (this.isDamaged(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { consumer.accept(t0); Item item = this.getItem(); @@ -269,7 +278,7 @@ this.subtract(1); if (t0 instanceof EntityHuman) { -@@ -346,6 +544,17 @@ +@@ -359,6 +557,17 @@ return this.tag; } @@ -287,7 +296,7 @@ public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -498,6 +707,12 @@ +@@ -516,6 +725,12 @@ } public void setRepairCost(int i) { @@ -300,16 +309,7 @@ this.getOrCreateTag().setInt("RepairCost", i); } -@@ -520,7 +735,7 @@ - object = this.getItem().a(enumitemslot); - } - -- ((Multimap) object).values().forEach((attributemodifier1) -> { -+ ((Multimap) object).values().forEach((attributemodifier1) -> { // CraftBukkit - decompile error - attributemodifier1.a(false); - }); - return (Multimap) object; -@@ -543,6 +758,13 @@ +@@ -565,6 +780,13 @@ nbttaglist.add(nbttagcompound); } @@ -320,6 +320,6 @@ + } + // CraftBukkit end + - public IChatBaseComponent B() { - IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).addSibling(this.getName()); + public IChatBaseComponent C() { + IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).addSibling(this.getName()); diff --git a/nms-patches/ItemTrident.patch b/nms-patches/ItemTrident.patch index 312a20f611..0f71113722 100644 --- a/nms-patches/ItemTrident.patch +++ b/nms-patches/ItemTrident.patch @@ -1,20 +1,6 @@ --- a/net/minecraft/server/ItemTrident.java +++ b/net/minecraft/server/ItemTrident.java -@@ -6,9 +6,13 @@ - - public ItemTrident(Item.Info item_info) { - super(item_info); -+ // CraftBukkit start - obfuscator went a little crazy -+ /* - this.a(new MinecraftKey("throwing"), (itemstack, world, entityliving) -> { - return entityliving != null && entityliving.isHandRaised() && entityliving.dD() == itemstack ? 1.0F : 0.0F; - }); -+ */ -+ // CraftBukkit end - } - - @Override -@@ -37,9 +41,12 @@ +@@ -43,9 +43,12 @@ if (k <= 0 || entityhuman.isInWaterOrRain()) { if (!world.isClientSide) { @@ -27,7 +13,7 @@ if (k == 0) { EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); -@@ -48,16 +55,40 @@ +@@ -54,16 +57,40 @@ entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; } diff --git a/nms-patches/ItemWaterLily.patch b/nms-patches/ItemWaterLily.patch deleted file mode 100644 index 91004eca18..0000000000 --- a/nms-patches/ItemWaterLily.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/server/ItemWaterLily.java -+++ b/net/minecraft/server/ItemWaterLily.java -@@ -34,7 +34,15 @@ - Fluid fluid = world.getFluid(blockposition); - - if ((fluid.getType() == FluidTypes.WATER || material == Material.ICE) && world.isEmpty(blockposition1)) { -+ // CraftBukkit start - special case for handling block placement with water lilies -+ org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, blockposition1); - world.setTypeAndData(blockposition1, Blocks.LILY_PAD.getBlockData(), 11); -+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { -+ blockstate.update(true, false); -+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); -+ } -+ // CraftBukkit end - if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack); - } diff --git a/nms-patches/ItemWorldMap.patch b/nms-patches/ItemWorldMap.patch index 32ee2833a8..290a65e5fc 100644 --- a/nms-patches/ItemWorldMap.patch +++ b/nms-patches/ItemWorldMap.patch @@ -13,16 +13,16 @@ public ItemWorldMap(Item.Info item_info) { @@ -38,7 +43,7 @@ - public static int e(ItemStack itemstack) { + public static int d(ItemStack itemstack) { NBTTagCompound nbttagcompound = itemstack.getTag(); - return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : 0; + return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag } - private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, DimensionManager dimensionmanager) { + private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey resourcekey) { @@ -48,6 +53,11 @@ - worldmap.a(i, j, k, flag, flag1, dimensionmanager); + worldmap.a(i, j, k, flag, flag1, resourcekey); world.a(worldmap); itemstack.getOrCreateTag().setInt("map", l); + diff --git a/nms-patches/JsonList.patch b/nms-patches/JsonList.patch index 984eaa04f8..03e2c1e442 100644 --- a/nms-patches/JsonList.patch +++ b/nms-patches/JsonList.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/JsonList.java +++ b/net/minecraft/server/JsonList.java -@@ -85,7 +85,7 @@ +@@ -50,7 +50,7 @@ @Nullable public V get(K k0) { - this.h(); + this.g(); - return (JsonListEntry) this.d.get(this.a(k0)); + return (V) this.d.get(this.a(k0)); // CraftBukkit - fix decompile error } public void remove(K k0) { -@@ -107,6 +107,12 @@ +@@ -72,6 +72,12 @@ return (String[]) this.d.keySet().toArray(new String[this.d.size()]); } @@ -22,7 +22,7 @@ public boolean isEmpty() { return this.d.size() < 1; } -@@ -124,7 +130,7 @@ +@@ -89,7 +95,7 @@ Iterator iterator = this.d.values().iterator(); while (iterator.hasNext()) { @@ -31,7 +31,7 @@ if (v0.hasExpired()) { list.add(v0.getKey()); -@@ -134,7 +140,7 @@ +@@ -99,7 +105,7 @@ iterator = list.iterator(); while (iterator.hasNext()) { @@ -40,21 +40,21 @@ this.d.remove(this.a(k0)); } -@@ -142,7 +148,7 @@ - } +@@ -119,7 +125,7 @@ + JsonObject jsonobject = new JsonObject(); - protected JsonListEntry a(JsonObject jsonobject) { -- return new JsonListEntry<>((Object) null, jsonobject); -+ return new JsonListEntry<>((K) null, jsonobject); // CraftBukkit - decompile error - } + jsonlistentry.getClass(); +- return (JsonObject) SystemUtils.a((Object) jsonobject, jsonlistentry::a); ++ return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error + }).forEach(jsonarray::add); + BufferedWriter bufferedwriter = Files.newWriter(this.c, StandardCharsets.UTF_8); + Throwable throwable = null; +@@ -163,7 +169,7 @@ + JsonListEntry jsonlistentry = this.a(jsonobject); - public Collection e() { -@@ -179,7 +185,7 @@ - JsonListEntry jsonlistentry = (JsonListEntry) iterator.next(); - - if (jsonlistentry.getKey() != null) { -- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); -+ this.d.put(this.a((K) jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error - } + if (jsonlistentry.getKey() != null) { +- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); ++ this.d.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error } } + } catch (Throwable throwable1) { diff --git a/nms-patches/LoginListener.patch b/nms-patches/LoginListener.patch index 6cb0724920..ec7a494182 100644 --- a/nms-patches/LoginListener.patch +++ b/nms-patches/LoginListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LoginListener.java +++ b/net/minecraft/server/LoginListener.java -@@ -18,6 +18,12 @@ +@@ -17,6 +17,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,7 +13,7 @@ public class LoginListener implements PacketLoginInListener { private static final AtomicInteger b = new AtomicInteger(0); -@@ -32,6 +38,7 @@ +@@ -31,6 +37,7 @@ private final String j; private SecretKey loginKey; private EntityPlayer l; @@ -21,7 +21,7 @@ public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { this.g = LoginListener.EnumProtocolState.HELLO; -@@ -60,6 +67,20 @@ +@@ -59,6 +66,20 @@ } @@ -42,7 +42,7 @@ @Override public NetworkManager a() { return this.networkManager; -@@ -81,10 +102,12 @@ +@@ -80,10 +101,12 @@ this.i = this.a(this.i); } @@ -57,8 +57,8 @@ + // CraftBukkit end } else { this.g = LoginListener.EnumProtocolState.ACCEPTED; - if (this.server.aA() >= 0 && !this.networkManager.isLocal()) { -@@ -98,9 +121,9 @@ + if (this.server.av() >= 0 && !this.networkManager.isLocal()) { +@@ -97,9 +120,9 @@ if (entityplayer != null) { this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT; @@ -70,7 +70,7 @@ } } -@@ -148,6 +171,43 @@ +@@ -147,6 +170,43 @@ LoginListener.this.i = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); if (LoginListener.this.i != null) { @@ -114,8 +114,8 @@ LoginListener.LOGGER.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.isEmbeddedServer()) { -@@ -167,6 +227,11 @@ - LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down", new Object[0])); +@@ -166,6 +226,11 @@ + LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down")); LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable"); } + // CraftBukkit start - catch all exceptions diff --git a/nms-patches/LootContextParameters.patch b/nms-patches/LootContextParameters.patch index d2993800f8..d1a317952a 100644 --- a/nms-patches/LootContextParameters.patch +++ b/nms-patches/LootContextParameters.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LootContextParameters.java +++ b/net/minecraft/server/LootContextParameters.java -@@ -12,6 +12,7 @@ +@@ -13,6 +13,7 @@ public static final LootContextParameter BLOCK_ENTITY = a("block_entity"); public static final LootContextParameter TOOL = a("tool"); public static final LootContextParameter EXPLOSION_RADIUS = a("explosion_radius"); diff --git a/nms-patches/LootEnchantFunction.patch b/nms-patches/LootEnchantFunction.patch index 46134313dc..276b5a1056 100644 --- a/nms-patches/LootEnchantFunction.patch +++ b/nms-patches/LootEnchantFunction.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LootEnchantFunction.java +++ b/net/minecraft/server/LootEnchantFunction.java -@@ -32,8 +32,13 @@ +@@ -37,8 +37,13 @@ if (entity instanceof EntityLiving) { int i = EnchantmentManager.g((EntityLiving) entity); @@ -15,12 +15,12 @@ return itemstack; } -@@ -59,7 +64,7 @@ - } +@@ -62,7 +67,7 @@ + public b() {} public void a(JsonObject jsonobject, LootEnchantFunction lootenchantfunction, JsonSerializationContext jsonserializationcontext) { - super.a(jsonobject, (LootItemFunctionConditional) lootenchantfunction, jsonserializationcontext); + super.a(jsonobject, lootenchantfunction, jsonserializationcontext); // CraftBukkit - decompile error jsonobject.add("count", jsonserializationcontext.serialize(lootenchantfunction.a)); - if (lootenchantfunction.b()) { - jsonobject.add("limit", jsonserializationcontext.serialize(lootenchantfunction.c)); + if (lootenchantfunction.c()) { + jsonobject.add("limit", jsonserializationcontext.serialize(lootenchantfunction.b)); diff --git a/nms-patches/LootEntryAbstract.patch b/nms-patches/LootEntryAbstract.patch new file mode 100644 index 0000000000..7a55aee3f4 --- /dev/null +++ b/nms-patches/LootEntryAbstract.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/LootEntryAbstract.java ++++ b/net/minecraft/server/LootEntryAbstract.java +@@ -34,7 +34,16 @@ + + public Serializer() {} + +- public final void serializeType(JsonObject jsonobject, T t0, JsonSerializationContext jsonserializationcontext) {} ++ // CraftBukkit start ++ @Override ++ public final void a(JsonObject jsonobject, T t0, JsonSerializationContext jsonserializationcontext) { ++ if (!org.apache.commons.lang3.ArrayUtils.isEmpty(t0.d)) { ++ jsonobject.add("conditions", jsonserializationcontext.serialize(t0.d)); ++ } ++ ++ this.serializeType(jsonobject, t0, jsonserializationcontext); ++ } ++ // CraftBukkit end + + @Override + public final T a(JsonObject jsonobject, JsonDeserializationContext jsondeserializationcontext) { diff --git a/nms-patches/LootItemConditionRandomChanceWithLooting.patch b/nms-patches/LootItemConditionRandomChanceWithLooting.patch index b3c870a3e3..7283f018dd 100644 --- a/nms-patches/LootItemConditionRandomChanceWithLooting.patch +++ b/nms-patches/LootItemConditionRandomChanceWithLooting.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LootItemConditionRandomChanceWithLooting.java +++ b/net/minecraft/server/LootItemConditionRandomChanceWithLooting.java -@@ -28,6 +28,11 @@ +@@ -33,6 +33,11 @@ if (entity instanceof EntityLiving) { i = EnchantmentManager.g((EntityLiving) entity); } diff --git a/nms-patches/LootItemConditionSurvivesExplosion.patch b/nms-patches/LootItemConditionSurvivesExplosion.patch index 4d3d219b78..1da01d9f2f 100644 --- a/nms-patches/LootItemConditionSurvivesExplosion.patch +++ b/nms-patches/LootItemConditionSurvivesExplosion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LootItemConditionSurvivesExplosion.java +++ b/net/minecraft/server/LootItemConditionSurvivesExplosion.java -@@ -25,7 +25,8 @@ +@@ -30,7 +30,8 @@ Random random = loottableinfo.a(); float f = 1.0F / ofloat; diff --git a/nms-patches/LootTableRegistry.patch b/nms-patches/LootTableRegistry.patch index 416e31ffde..7c2d2bad4e 100644 --- a/nms-patches/LootTableRegistry.patch +++ b/nms-patches/LootTableRegistry.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/LootTableRegistry.java +++ b/net/minecraft/server/LootTableRegistry.java -@@ -17,6 +17,7 @@ +@@ -15,6 +15,7 @@ private static final Logger LOGGER = LogManager.getLogger(); - private static final Gson b = (new GsonBuilder()).registerTypeAdapter(LootValueBounds.class, new LootValueBounds.a()).registerTypeAdapter(LootValueBinomial.class, new LootValueBinomial.a()).registerTypeAdapter(LootValueConstant.class, new LootValueConstant.a()).registerTypeAdapter(LootIntegerLimit.class, new LootIntegerLimit.a()).registerTypeAdapter(LootSelector.class, new LootSelector.b()).registerTypeAdapter(LootTable.class, new LootTable.b()).registerTypeHierarchyAdapter(LootEntryAbstract.class, new LootEntries.a()).registerTypeHierarchyAdapter(LootItemFunction.class, new LootItemFunctions.a()).registerTypeHierarchyAdapter(LootItemCondition.class, new LootItemConditions.a()).registerTypeHierarchyAdapter(LootTableInfo.EntityTarget.class, new LootTableInfo.EntityTarget.a()).create(); + private static final Gson b = LootSerialization.c().create(); private Map c = ImmutableMap.of(); + public Map lootTableToKey = ImmutableMap.of(); // CraftBukkit private final LootPredicateManager d; public LootTableRegistry(LootPredicateManager lootpredicatemanager) { -@@ -52,7 +53,7 @@ +@@ -50,7 +51,7 @@ LootPredicateManager lootpredicatemanager = this.d; this.d.getClass(); @@ -17,7 +17,7 @@ immutablemap.getClass(); LootCollector lootcollector = new LootCollector(lootcontextparameterset, function, immutablemap::get); -@@ -64,6 +65,11 @@ +@@ -62,6 +63,11 @@ LootTableRegistry.LOGGER.warn("Found validation problem in " + s + ": " + s1); }); this.c = immutablemap; diff --git a/nms-patches/Main.patch b/nms-patches/Main.patch new file mode 100644 index 0000000000..6b139fc142 --- /dev/null +++ b/nms-patches/Main.patch @@ -0,0 +1,120 @@ +--- a/net/minecraft/server/Main.java ++++ b/net/minecraft/server/Main.java +@@ -28,7 +28,8 @@ + + public Main() {} + +- public static void main(String[] astring) { ++ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) ++ /* CraftBukkit start - Replace everything + OptionParser optionparser = new OptionParser(); + OptionSpec optionspec = optionparser.accepts("nogui"); + OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); +@@ -52,19 +53,21 @@ + optionparser.printHelpOn(System.err); + return; + } ++ */ // CraftBukkit end + ++ try { + CrashReport.h(); + DispenserRegistry.init(); + DispenserRegistry.c(); + SystemUtils.l(); + java.nio.file.Path java_nio_file_path = Paths.get("server.properties"); +- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(java_nio_file_path); ++ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support + + dedicatedserversettings.save(); + java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt"); + EULA eula = new EULA(java_nio_file_path1); + +- if (optionset.has(optionspec1)) { ++ if (optionset.has("initSettings")) { // CraftBukkit + Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath()); + return; + } +@@ -74,18 +77,19 @@ + return; + } + +- File file = new File((String) optionset.valueOf(optionspec9)); ++ File file = (File) optionset.valueOf("universe"); // CraftBukkit + YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); + MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); + GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); + UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.b.getName())); +- String s = (String) Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); ++ // CraftBukkit start ++ String s = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); + Convertable convertable = Convertable.a(file.toPath()); +- Convertable.ConversionSession convertable_conversionsession = convertable.c(s); ++ Convertable.ConversionSession convertable_conversionsession = convertable.c(s, WorldDimension.OVERWORLD); + + MinecraftServer.convertWorld(convertable_conversionsession); + DataPackConfiguration datapackconfiguration = convertable_conversionsession.e(); +- boolean flag = optionset.has(optionspec6); ++ boolean flag = optionset.has("safeMode"); + + if (flag) { + Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); +@@ -107,6 +111,7 @@ + + datapackresources.i(); + IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); ++ /* + RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), (IRegistryCustom) iregistrycustom_dimension); + Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1); + +@@ -134,21 +139,32 @@ + } + + convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object); ++ */ + final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.a((thread) -> { +- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); ++ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new); + ++ /* + dedicatedserver1.d((String) optionset.valueOf(optionspec8)); + dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11)); + dedicatedserver1.c(optionset.has(optionspec2)); + dedicatedserver1.b((String) optionset.valueOf(optionspec12)); +- boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui"); ++ */ ++ boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui"); + + if (flag1 && !GraphicsEnvironment.isHeadless()) { + dedicatedserver1.bb(); + } + ++ if (optionset.has("port")) { ++ int port = (Integer) optionset.valueOf("port"); ++ if (port > 0) { ++ dedicatedserver1.setPort(port); ++ } ++ } ++ + return dedicatedserver1; + }); ++ /* CraftBukkit start + Thread thread = new Thread("Server Shutdown Thread") { + public void run() { + dedicatedserver.safeShutdown(true); +@@ -157,6 +173,7 @@ + + thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); + Runtime.getRuntime().addShutdownHook(thread); ++ */ // CraftBukkit end + } catch (Exception exception1) { + Main.LOGGER.fatal("Failed to start the minecraft server", exception1); + } +@@ -164,7 +181,7 @@ + } + + public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet> immutableset) { +- Main.LOGGER.info("Forcing world upgrade!"); ++ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelName()); // CraftBukkit + WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, immutableset, flag); + IChatBaseComponent ichatbasecomponent = null; + diff --git a/nms-patches/MerchantRecipe.patch b/nms-patches/MerchantRecipe.patch index b0ca841a1e..cc3d1256e7 100644 --- a/nms-patches/MerchantRecipe.patch +++ b/nms-patches/MerchantRecipe.patch @@ -31,7 +31,7 @@ public ItemStack getBuyItem1() { int i = this.buyingItem1.getCount(); -+ if (i <= 0) return ItemStack.a; // CraftBukkit - SPIGOT-5476 ++ if (i <= 0) return ItemStack.b; // CraftBukkit - SPIGOT-5476 ItemStack itemstack = this.buyingItem1.cloneItemStack(); int j = Math.max(0, MathHelper.d((float) (i * this.demand) * this.priceMultiplier)); diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index e17228d977..eb7ee52289 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -1,43 +1,44 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -56,6 +56,13 @@ +@@ -9,6 +9,8 @@ + import com.mojang.authlib.GameProfileRepository; + import com.mojang.authlib.minecraft.MinecraftSessionService; + import com.mojang.datafixers.DataFixer; ++import com.mojang.serialization.DynamicOps; ++import com.mojang.serialization.Lifecycle; + import io.netty.buffer.ByteBuf; + import io.netty.buffer.ByteBufOutputStream; + import io.netty.buffer.Unpooled; +@@ -54,6 +56,14 @@ import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import jline.console.ConsoleReader; ++import joptsimple.OptionSet; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.Main; +import org.bukkit.event.server.ServerLoadEvent; +// CraftBukkit end - public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable { + public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements IMojangStatistics, ICommandListener, AutoCloseable { -@@ -75,7 +82,7 @@ +@@ -73,7 +83,7 @@ public final DataFixer dataConverterManager; private String serverIp; - private int serverPort = -1; -- public final Map worldServer = Maps.newIdentityHashMap(); -+ public final Map worldServer = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods + private int serverPort; +- protected final IRegistryCustom.Dimension f; ++ public final IRegistryCustom.Dimension f; + public final Map, WorldServer> worldServer; private PlayerList playerList; - private volatile boolean isRunning = true; - private boolean isStopped; -@@ -113,7 +120,7 @@ - private final GameProfileRepository gameProfileRepository; - private final UserCache userCache; - private long Z; -- public final Thread serverThread = (Thread) SystemUtils.a((Object) (new Thread(this, "Server thread")), (thread) -> { -+ public final Thread serverThread = (Thread) SystemUtils.a((new Thread(this, "Server thread")), (thread) -> { // CraftBukkit - decompile error - thread.setUncaughtExceptionHandler((thread1, throwable) -> { - MinecraftServer.LOGGER.error(throwable); - }); -@@ -145,7 +152,21 @@ - @Nullable - private String ax; + private volatile boolean isRunning; +@@ -124,6 +134,21 @@ + private final DefinedStructureManager ak; + protected SaveData saveData; -- public MinecraftServer(File file, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { + // CraftBukkit start ++ public DataPackConfiguration datapackconfiguration; + public org.bukkit.craftbukkit.CraftServer server; + public OptionSet options; + public org.bukkit.command.ConsoleCommandSender console; @@ -51,36 +52,42 @@ + private boolean forceTicks; + // CraftBukkit end + -+ public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { + public static S a(Function function) { + AtomicReference atomicreference = new AtomicReference(); + Thread thread = new Thread(() -> { +@@ -133,21 +158,21 @@ + thread.setUncaughtExceptionHandler((thread1, throwable) -> { + MinecraftServer.LOGGER.error(throwable); + }); +- S s0 = (MinecraftServer) function.apply(thread); ++ S s0 = function.apply(thread); // CraftBukkit - decompile error + + atomicreference.set(s0); + thread.start(); + return s0; + } + +- public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { ++ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { super("Server"); - this.ae = new ResourceManager(EnumResourcePackType.SERVER_DATA, this.serverThread); - this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new); -@@ -159,15 +180,15 @@ - this.customFunctionData = new CustomFunctionData(this); - this.circularTimer = new CircularTimer(); - this.proxy = proxy; -- this.commandDispatcher = commanddispatcher; -+ this.commandDispatcher = this.vanillaCommandDispatcher = commanddispatcher; // CraftBukkit - this.yggdrasilAuthenticationService = yggdrasilauthenticationservice; - this.minecraftSessionService = minecraftsessionservice; - this.gameProfileRepository = gameprofilerepository; - this.userCache = usercache; -- this.universe = file; -- this.serverConnection = new ServerConnection(this); -+ // this.universe = file; // CraftBukkit -+ this.serverConnection = new ServerConnection(this); // CraftBukkit - this.worldLoadListenerFactory = worldloadlistenerfactory; -- this.convertable = new Convertable(file.toPath(), file.toPath().resolve("../backups"), datafixer); -+ // this.convertable = new Convertable(file.toPath(), file.toPath().resolve("../backups"), datafixer); // CraftBukkit - moved to DedicatedServer.init - this.dataConverterManager = datafixer; - this.ae.a((IReloadListener) this.tagRegistry); - this.ae.a((IReloadListener) this.lootPredicateManager); -@@ -177,7 +198,32 @@ - this.ae.a((IReloadListener) this.advancementDataWorld); - this.executorService = SystemUtils.e(); - this.K = s; + this.m = new GameProfilerSwitcher(SystemUtils.a, this::ag); + this.methodProfiler = GameProfilerDisabled.a; + this.serverPing = new ServerPing(); + this.r = new Random(); + this.serverPort = -1; +- this.worldServer = Maps.newLinkedHashMap(); ++ this.worldServer = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods + this.isRunning = true; + this.h = new long[100]; + this.K = ""; +@@ -173,7 +198,34 @@ + this.ak = new DefinedStructureManager(datapackresources.h(), convertable_conversionsession, datafixer); + this.serverThread = thread; + this.executorService = SystemUtils.f(); + // CraftBukkit start + this.options = options; ++ this.datapackconfiguration = datapackconfiguration; ++ this.vanillaCommandDispatcher = datapackresources.commandDispatcher; // CraftBukkit + // Try to see if we're actually running in a terminal, disable jline if not + if (System.console() == null && System.getProperty("jline.terminal") == null) { + System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); @@ -108,63 +115,45 @@ private void initializeScoreboards(WorldPersistentData worldpersistentdata) { PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard"); -@@ -213,11 +259,11 @@ - } +@@ -186,7 +238,7 @@ - if (this.forceUpgrade) { -- MinecraftServer.LOGGER.info("Forcing world upgrade!"); -- WorldData worlddata = this.getConvertable().b(this.getWorld()); -+ MinecraftServer.LOGGER.info("Forcing world upgrade! {}", s); // CraftBukkit -+ WorldData worlddata = this.getConvertable().b(s); // CraftBukkit + public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) { + if (convertable_conversionsession.isConvertable()) { +- MinecraftServer.LOGGER.info("Converting map!"); ++ MinecraftServer.LOGGER.info("Converting map! {}", convertable_conversionsession.getLevelName()); // CraftBukkit + convertable_conversionsession.convert(new IProgressUpdate() { + private long a = SystemUtils.getMonotonicMillis(); - if (worlddata != null) { -- WorldUpgrader worldupgrader = new WorldUpgrader(this.getWorld(), this.getConvertable(), worlddata, this.eraseCache); -+ WorldUpgrader worldupgrader = new WorldUpgrader(s, this.getConvertable(), worlddata, this.eraseCache); // CraftBukkit - IChatBaseComponent ichatbasecomponent = null; +@@ -209,48 +261,185 @@ - while (!worldupgrader.b()) { -@@ -256,8 +302,9 @@ } - protected void a(String s, String s1, long i, WorldType worldtype, JsonElement jsonelement) { -- this.convertWorld(s); -+ // this.convertWorld(s); // CraftBukkit - moved down - this.b((IChatBaseComponent) (new ChatMessage("menu.loadingLevel", new Object[0]))); -+ /* CraftBukkit start - Remove ticktime arrays and worldsettings - WorldNBTStorage worldnbtstorage = this.getConvertable().a(s, this); - - this.a(this.getWorld(), worldnbtstorage); -@@ -283,27 +330,137 @@ - - worlddata.a(this.getServerModName(), this.q().isPresent()); - this.a(worldnbtstorage.getDirectory(), worlddata); +- protected void loadWorld() { +- this.loadResourcesZip(); +- this.saveData.a(this.getServerModName(), this.getModded().isPresent()); - WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); -+ */ ++ protected void loadWorld(String s) { + int worldCount = 3; - -- this.a(worldnbtstorage, worlddata, worldsettings, worldloadlistener); -- this.a(this.getDifficulty(), true); -- this.loadSpawn(worldloadlistener); -- } -+ for (int j = 0; j < worldCount; ++j) { -+ WorldServer world; -+ WorldData worlddata; -+ byte dimension = 0; + -+ if (j == 1) { ++ for (int worldId = 0; worldId < worldCount; ++worldId) { ++ WorldServer world; ++ WorldDataServer worlddata; ++ byte dimension = 0; ++ ResourceKey dimensionKey = WorldDimension.OVERWORLD; ++ ++ if (worldId == 1) { + if (getAllowNether()) { + dimension = -1; ++ dimensionKey = WorldDimension.THE_NETHER; + } else { + continue; + } + } - -- protected void a(WorldNBTStorage worldnbtstorage, WorldData worlddata, WorldSettings worldsettings, WorldLoadListener worldloadlistener) { -- if (this.isDemoMode()) { -- worlddata.a(MinecraftServer.c); -+ if (j == 2) { ++ ++ if (worldId == 2) { + if (server.getAllowEnd()) { + dimension = 1; ++ dimensionKey = WorldDimension.THE_END; + } else { + continue; + } @@ -172,27 +161,78 @@ + + String worldType = org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase(); + String name = (dimension == 0) ? s : s + "_" + worldType; -+ this.convertWorld(name); // Run conversion now ++ Convertable.ConversionSession worldSession; ++ if (dimension == 0) { ++ worldSession = this.convertable; ++ } else { ++ try { ++ worldSession = Convertable.a(server.getWorldContainer().toPath()).c(name, dimensionKey); ++ } catch (IOException ex) { ++ throw new RuntimeException(ex); ++ } ++ MinecraftServer.convertWorld(worldSession); // Run conversion now ++ } + + org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); -+ WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); -+ worldsettings.setGeneratorSettings(jsonelement); + -+ if (j == 0) { -+ WorldNBTStorage worldnbtstorage = new WorldNBTStorage(server.getWorldContainer(), s1, this, this.dataConverterManager); -+ worlddata = worldnbtstorage.getWorldData(); -+ if (worlddata == null) { -+ worlddata = new WorldData(worldsettings, s1); -+ } -+ worlddata.checkName(s1); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) -+ this.a(worldnbtstorage.getDirectory(), worlddata); -+ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); ++ IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); ++ ++ RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), (IRegistryCustom) iregistrycustom_dimension); ++ worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration); ++ if (worlddata == null) { ++ WorldSettings worldsettings; ++ GeneratorSettings generatorsettings; + + if (this.isDemoMode()) { -+ worlddata.a(MinecraftServer.c); -+ } -+ world = new WorldServer(this, this.executorService, worldnbtstorage, worlddata, DimensionManager.OVERWORLD, this.methodProfiler, worldloadlistener, org.bukkit.World.Environment.getEnvironment(dimension), gen); ++ worldsettings = MinecraftServer.c; ++ generatorsettings = GeneratorSettings.b; ++ } else { ++ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); + ++ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); ++ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.k() : dedicatedserverproperties.generatorSettings; ++ } ++ ++ worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); ++ } ++ worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) ++ if (options.has("forceUpgrade")) { ++ net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> { ++ return true; ++ }, worlddata.getGeneratorSettings().g()); ++ } ++ ++ IWorldDataServer iworlddataserver = worlddata; ++ GeneratorSettings generatorsettings = worlddata.getGeneratorSettings(); ++ boolean flag = generatorsettings.isDebugWorld(); ++ long i = generatorsettings.getSeed(); ++ long j = BiomeManager.a(i); ++ List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); ++ RegistryMaterials registrymaterials = generatorsettings.e(); ++ WorldDimension worlddimension = (WorldDimension) registrymaterials.a(dimensionKey); ++ DimensionManager dimensionmanager; ++ ChunkGenerator chunkgenerator; ++ ++ if (worlddimension == null) { ++ dimensionmanager = DimensionManager.a(); ++ chunkgenerator = GeneratorSettings.a((new Random()).nextLong()); ++ } else { ++ dimensionmanager = worlddimension.b(); ++ chunkgenerator = worlddimension.c(); ++ } ++ ++ ResourceKey typeKey = (ResourceKey) this.f.a().c(dimensionmanager).orElseThrow(() -> { ++ return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); ++ }); ++ ResourceKey worldKey = ResourceKey.a(IRegistry.ae, dimensionKey.a()); ++ ++ if (worldId == 0) { ++ this.saveData = worlddata; ++ this.saveData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init ++ ++ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); ++ ++ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, typeKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + WorldPersistentData worldpersistentdata = world.getWorldPersistentData(); + this.initializeScoreboards(worldpersistentdata); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); @@ -234,131 +274,162 @@ + } + } + -+ WorldNBTStorage worldnbtstorage = new WorldNBTStorage(server.getWorldContainer(), name, this, this.dataConverterManager); -+ // world =, b0 to dimension, s1 to name, added Environment and gen -+ worlddata = worldnbtstorage.getWorldData(); -+ if (worlddata == null) { -+ worlddata = new WorldData(worldsettings, name); -+ } -+ worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) + WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); -+ world = new SecondaryWorldServer(this.getWorldServer(DimensionManager.OVERWORLD), this, this.executorService, worldnbtstorage, DimensionManager.a(dimension), this.methodProfiler, worldloadlistener, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen); ++ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, typeKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + } + -+ this.initWorld(world, worlddata, worldsettings); ++ worlddata.a(this.getServerModName(), this.getModded().isPresent()); ++ this.initWorld(world, worlddata, saveData, worlddata.getGeneratorSettings()); + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld())); + -+ this.worldServer.put(world.getWorldProvider().getDimensionManager(), world); ++ this.worldServer.put(world.getDimensionKey(), world); + this.getPlayerList().setPlayerFileData(world); -+ + +- this.a(worldloadlistener); + if (worlddata.getCustomBossEvents() != null) { + this.getBossBattleCustomData().load(worlddata.getCustomBossEvents()); + } + } -+ this.a(this.getDifficulty(), true); + this.updateWorldSettings(); +- this.loadSpawn(worldloadlistener); + for (WorldServer worldserver : this.getWorlds()) { + this.loadSpawn(worldserver.getChunkProvider().playerChunkMap.worldLoadListener, worldserver); + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld())); - } - -- WorldServer worldserver = new WorldServer(this, this.executorService, worldnbtstorage, worlddata, DimensionManager.OVERWORLD, this.methodProfiler, worldloadlistener); ++ } ++ + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); + this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); + this.serverConnection.acceptConnections(); + // CraftBukkit end - -- this.worldServer.put(DimensionManager.OVERWORLD, worldserver); -- WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData(); -+ } - -- this.initializeScoreboards(worldpersistentdata); -- this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata); -- worldserver.getWorldBorder().b(worlddata); -- WorldServer worldserver1 = this.getWorldServer(DimensionManager.OVERWORLD); -+ // CraftBukkit start -+ public void initWorld(WorldServer worldserver1, WorldData worlddata, WorldSettings worldsettings) { -+ worldserver1.getWorldBorder().b(worlddata); + + } + + protected void updateWorldSettings() {} + +- protected void a(WorldLoadListener worldloadlistener) { +- IWorldDataServer iworlddataserver = this.saveData.G(); +- GeneratorSettings generatorsettings = this.saveData.getGeneratorSettings(); ++ // CraftBukkit start ++ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) { + boolean flag = generatorsettings.isDebugWorld(); +- long i = generatorsettings.getSeed(); +- long j = BiomeManager.a(i); +- List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); +- RegistryMaterials registrymaterials = generatorsettings.e(); +- WorldDimension worlddimension = (WorldDimension) registrymaterials.a(WorldDimension.OVERWORLD); +- DimensionManager dimensionmanager; +- Object object; +- +- if (worlddimension == null) { +- dimensionmanager = DimensionManager.a(); +- object = GeneratorSettings.a((new Random()).nextLong()); +- } else { +- dimensionmanager = worlddimension.b(); +- object = worlddimension.c(); + // CraftBukkit start -+ if (worldserver1.generator != null) { -+ worldserver1.getWorld().getPopulators().addAll(worldserver1.generator.getDefaultPopulators(worldserver1.getWorld())); -+ } -+ // CraftBukkit end - - if (!worlddata.u()) { - try { -@@ -327,23 +484,8 @@ - - worlddata.d(true); ++ if (worldserver.generator != null) { ++ worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld())); } - -- this.getPlayerList().setPlayerFileData(worldserver1); -- if (worlddata.getCustomBossEvents() != null) { -- this.getBossBattleCustomData().load(worlddata.getCustomBossEvents()); +- ResourceKey resourcekey = (ResourceKey) this.f.a().c((Object) dimensionmanager).orElseThrow(() -> { +- return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); +- }); +- WorldServer worldserver = new WorldServer(this, this.executorService, this.convertable, iworlddataserver, World.OVERWORLD, resourcekey, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); +- +- this.worldServer.put(World.OVERWORLD, worldserver); +- WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData(); +- +- this.initializeScoreboards(worldpersistentdata); +- this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata); + WorldBorder worldborder = worldserver.getWorldBorder(); + + worldborder.a(iworlddataserver.q()); +@@ -275,34 +464,8 @@ + + iworlddataserver.c(true); + } +- +- this.getPlayerList().setPlayerFileData(worldserver); +- if (this.saveData.getCustomBossEvents() != null) { +- this.getBossBattleCustomData().load(this.saveData.getCustomBossEvents()); - } - -- Iterator iterator = DimensionManager.a().iterator(); +- Iterator iterator = registrymaterials.c().iterator(); - - while (iterator.hasNext()) { -- DimensionManager dimensionmanager = (DimensionManager) iterator.next(); +- Entry, WorldDimension> entry = (Entry) iterator.next(); +- ResourceKey resourcekey1 = (ResourceKey) entry.getKey(); - -- if (dimensionmanager != DimensionManager.OVERWORLD) { -- this.worldServer.put(dimensionmanager, new SecondaryWorldServer(worldserver1, this, this.executorService, worldnbtstorage, dimensionmanager, this.methodProfiler, worldloadlistener)); +- if (resourcekey1 != WorldDimension.OVERWORLD) { +- ResourceKey resourcekey2 = ResourceKey.a(IRegistry.ae, resourcekey1.a()); +- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b(); +- ResourceKey resourcekey3 = (ResourceKey) this.f.a().c((Object) dimensionmanager1).orElseThrow(() -> { +- return new IllegalStateException("Unregistered dimension type: " + dimensionmanager1); +- }); +- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c(); +- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.saveData, iworlddataserver); +- WorldServer worldserver1 = new WorldServer(this, this.executorService, this.convertable, secondaryworlddata, resourcekey2, resourcekey3, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); +- +- worldborder.a((IWorldBorderListener) (new IWorldBorderListener.a(worldserver1.getWorldBorder()))); +- this.worldServer.put(resourcekey2, worldserver1); - } - } - } + // CraftBukkit end - private void a(WorldData worlddata) { - worlddata.f(false); -@@ -362,6 +504,23 @@ - protected void a(File file, WorldData worlddata) { - this.resourcePackRepository.a((ResourcePackSource) (new ResourcePackSourceVanilla())); - this.resourcePackFolder = new ResourcePackSourceFolder(new File(file, "datapacks")); -+ // CraftBukkit start -+ bukkitDataPackFolder = new File(new File(file, "datapacks"), "bukkit"); -+ if (!bukkitDataPackFolder.exists()) { -+ bukkitDataPackFolder.mkdirs(); -+ } -+ File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta"); -+ try { -+ com.google.common.io.Files.write("{\n" -+ + " \"pack\": {\n" -+ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": " + SharedConstants.getGameVersion().getPackVersion() + "\n" -+ + " }\n" -+ + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); -+ } catch (IOException ex) { -+ throw new RuntimeException("Could not initialize Bukkit datapack", ex); -+ } -+ // CraftBukkit end - this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder); - this.resourcePackRepository.a(); - List list = Lists.newArrayList(); -@@ -383,11 +542,18 @@ - this.bb(); + private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) { + ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator(); +@@ -317,6 +480,21 @@ + Random random = new Random(worldserver.getSeed()); + BlockPosition blockposition = worldchunkmanager.a(0, worldserver.getSeaLevel(), 0, 256, list, random); + ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); ++ // CraftBukkit start ++ if (worldserver.generator != null) { ++ Random rand = new Random(worldserver.getSeed()); ++ org.bukkit.Location spawn = worldserver.generator.getFixedSpawnLocation(worldserver.getWorld(), rand); ++ ++ if (spawn != null) { ++ if (spawn.getWorld() != worldserver.getWorld()) { ++ throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getName() + " to be in another world (" + spawn.getWorld().getName() + ")"); ++ } else { ++ iworlddataserver.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ())); ++ return; ++ } ++ } ++ } ++ // CraftBukkit end + + if (blockposition == null) { + MinecraftServer.LOGGER.warn("Unable to find spawn biome"); +@@ -363,7 +541,7 @@ + } + + if (flag) { +- WorldGenFeatureConfigured worldgenfeatureconfigured = WorldGenerator.BONUS_CHEST.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.k); ++ WorldGenFeatureConfigured worldgenfeatureconfigured = WorldGenerator.BONUS_CHEST.b(WorldGenFeatureConfiguration.k); // CraftBukkit - decompile error + + worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), chunkgenerator, worldserver.random, new BlockPosition(iworlddataserver.a(), iworlddataserver.b(), iworlddataserver.c())); + } +@@ -383,8 +561,15 @@ + iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } - public void loadSpawn(WorldLoadListener worldloadlistener) { +- WorldServer worldserver = this.D(); + // CraftBukkit start + public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) { + if (!worldserver.getWorld().getKeepSpawnInMemory()) { + return; + } + - this.b((IChatBaseComponent) (new ChatMessage("menu.generatingTerrain", new Object[0]))); -- WorldServer worldserver = this.getWorldServer(DimensionManager.OVERWORLD); -+ // WorldServer worldserver = this.getWorldServer(DimensionManager.OVERWORLD); ++ // WorldServer worldserver = this.D(); + this.forceTicks = true; + // CraftBukkit end -- MinecraftServer.LOGGER.info("Preparing start region for dimension " + DimensionManager.a(worldserver.worldProvider.getDimensionManager())); -+ MinecraftServer.LOGGER.info("Preparing start region for dimension '{}'/{}", worldserver.getWorldData().getName(), DimensionManager.a(worldserver.worldProvider.getDimensionManager().getType())); // CraftBukkit + MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a()); BlockPosition blockposition = worldserver.getSpawn(); - - worldloadlistener.a(new ChunkCoordIntPair(blockposition)); -@@ -398,17 +564,21 @@ +@@ -397,17 +582,21 @@ chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); while (chunkproviderserver.b() != 441) { @@ -372,24 +443,24 @@ - this.nextTick = SystemUtils.getMonotonicMillis() + 10L; - this.sleepForTick(); -- Iterator iterator = DimensionManager.a().iterator(); +- Iterator iterator = this.worldServer.values().iterator(); - - while (iterator.hasNext()) { -- DimensionManager dimensionmanager = (DimensionManager) iterator.next(); -- ForcedChunk forcedchunk = (ForcedChunk) this.getWorldServer(dimensionmanager).getWorldPersistentData().b(ForcedChunk::new, "chunks"); +- WorldServer worldserver1 = (WorldServer) iterator.next(); +- ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().b(ForcedChunk::new, "chunks"); + // CraftBukkit start + // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; + this.executeModerately(); -+ // Iterator iterator = DimensionManager.a().iterator(); ++ // Iterator iterator = this.worldServer.values().iterator(); + + if (true) { -+ DimensionManager dimensionmanager = worldserver.worldProvider.getDimensionManager(); ++ WorldServer worldserver1 = worldserver; + ForcedChunk forcedchunk = (ForcedChunk) worldserver.getWorldPersistentData().b(ForcedChunk::new, "chunks"); + // CraftBukkit end if (forcedchunk != null) { - WorldServer worldserver1 = this.getWorldServer(dimensionmanager); -@@ -423,10 +593,16 @@ + LongIterator longiterator = forcedchunk.a().iterator(); +@@ -421,11 +610,17 @@ } } @@ -401,31 +472,32 @@ + // CraftBukkit end worldloadlistener.b(); chunkproviderserver.getLightEngine().a(5); + this.ba(); + + // CraftBukkit start + this.forceTicks = false; + // CraftBukkit end } - protected void a(String s, WorldNBTStorage worldnbtstorage) { -@@ -473,12 +649,16 @@ - } + protected void loadResourcesZip() { +@@ -470,12 +665,16 @@ + worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2); } + // CraftBukkit start - moved to WorldServer.save + /* - WorldServer worldserver1 = this.getWorldServer(DimensionManager.OVERWORLD); - WorldData worlddata = worldserver1.getWorldData(); + WorldServer worldserver1 = this.D(); + IWorldDataServer iworlddataserver = this.saveData.G(); - worldserver1.getWorldBorder().save(worlddata); - worlddata.setCustomBossEvents(this.getBossBattleCustomData().save()); - worldserver1.getDataManager().saveWorldData(worlddata, this.getPlayerList().save()); + iworlddataserver.a(worldserver1.getWorldBorder().t()); + this.saveData.setCustomBossEvents(this.getBossBattleCustomData().save()); + this.convertable.a(this.f, this.saveData, this.getPlayerList().save()); + */ + // CraftBukkit end return flag3; } -@@ -487,8 +667,29 @@ +@@ -484,8 +683,29 @@ this.stop(); } @@ -455,7 +527,7 @@ if (this.getServerConnection() != null) { this.getServerConnection().b(); } -@@ -497,6 +698,7 @@ +@@ -494,6 +714,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.savePlayers(); this.playerList.shutdown(); @@ -463,7 +535,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -566,14 +768,16 @@ +@@ -571,14 +792,16 @@ while (this.isRunning) { long i = SystemUtils.getMonotonicMillis() - this.nextTick; @@ -479,9 +551,9 @@ + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.nextTick += 50L; - if (this.T) { - this.T = false; -@@ -620,6 +824,12 @@ + GameProfilerTick gameprofilertick = GameProfilerTick.a("Server"); + +@@ -624,6 +847,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -494,13 +566,13 @@ this.exit(); } -@@ -628,8 +838,15 @@ +@@ -632,8 +861,15 @@ } private boolean canSleepForTick() { -- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.ac ? this.ab : this.nextTick); +- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick); + // CraftBukkit start -+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.ac ? this.ab : this.nextTick); ++ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick); + } + + private void executeModerately() { @@ -511,7 +583,7 @@ protected void sleepForTick() { this.executeAll(); -@@ -735,7 +952,7 @@ +@@ -739,7 +975,7 @@ this.serverPing.b().a(agameprofile); } @@ -520,7 +592,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); this.methodProfiler.enter("save"); this.playerList.savePlayers(); -@@ -765,23 +982,40 @@ +@@ -769,22 +1005,39 @@ } protected void b(BooleanSupplier booleansupplier) { @@ -547,128 +619,20 @@ while (iterator.hasNext()) { WorldServer worldserver = (WorldServer) iterator.next(); -- if (worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) { -+ if (true || worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) { // CraftBukkit - this.methodProfiler.a(() -> { - return worldserver.getWorldData().getName() + " " + IRegistry.DIMENSION_TYPE.getKey(worldserver.worldProvider.getDimensionManager()); - }); -+ /* Drop global time updates - if (this.ticks % 20 == 0) { - this.methodProfiler.enter("timeSync"); - this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))), worldserver.worldProvider.getDimensionManager()); - this.methodProfiler.exit(); - } -+ // CraftBukkit end */ - - this.methodProfiler.enter("tick"); - -@@ -824,7 +1058,8 @@ - this.tickables.add(runnable); - } - -- public static void main(String[] astring) { -+ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) -+ /* CraftBukkit start - Replace everything - OptionParser optionparser = new OptionParser(); - OptionSpec optionspec = optionparser.accepts("nogui"); - OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -847,15 +1082,17 @@ - optionparser.printHelpOn(System.err); - return; + this.methodProfiler.a(() -> { + return worldserver + " " + worldserver.getDimensionKey().a(); + }); ++ /* Drop global time updates + if (this.ticks % 20 == 0) { + this.methodProfiler.enter("timeSync"); + this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))), worldserver.getDimensionKey()); + this.methodProfiler.exit(); } -+ */ // CraftBukkit end ++ // CraftBukkit end */ -+ try { - java.nio.file.Path java_nio_file_path = Paths.get("server.properties"); -- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(java_nio_file_path); -+ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support + this.methodProfiler.enter("tick"); - dedicatedserversettings.save(); - java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt"); - EULA eula = new EULA(java_nio_file_path1); - -- if (optionset.has(optionspec1)) { -+ if (optionset.has("initSettings")) { // CraftBukkit - MinecraftServer.LOGGER.info("Initialized '" + java_nio_file_path.toAbsolutePath().toString() + "' and '" + java_nio_file_path1.toAbsolutePath().toString() + "'"); - return; - } -@@ -868,14 +1105,16 @@ - CrashReport.h(); - DispenserRegistry.init(); - DispenserRegistry.c(); -- String s = (String) optionset.valueOf(optionspec8); -+ File s = (File) optionset.valueOf("universe"); // CraftBukkit - YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); - MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); - GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); - UserCache usercache = new UserCache(gameprofilerepository, new File(s, MinecraftServer.b.getName())); -- String s1 = (String) Optional.ofNullable(optionset.valueOf(optionspec9)).orElse(dedicatedserversettings.getProperties().levelName); -- final DedicatedServer dedicatedserver = new DedicatedServer(new File(s), dedicatedserversettings, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new, s1); -+ // CraftBukkit start -+ String s1 = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); -+ final DedicatedServer dedicatedserver = new DedicatedServer(optionset, dedicatedserversettings, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new, s1); - -+ /* - dedicatedserver.i((String) optionset.valueOf(optionspec7)); - dedicatedserver.setPort((Integer) optionset.valueOf(optionspec10)); - dedicatedserver.e(optionset.has(optionspec2)); -@@ -883,12 +1122,14 @@ - dedicatedserver.setForceUpgrade(optionset.has(optionspec4)); - dedicatedserver.setEraseCache(optionset.has(optionspec5)); - dedicatedserver.c((String) optionset.valueOf(optionspec11)); -- boolean flag = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui"); -+ */ -+ boolean flag = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui"); - - if (flag && !GraphicsEnvironment.isHeadless()) { - dedicatedserver.bc(); - } - -+ /* - dedicatedserver.startServerThread(); - Thread thread = new Thread("Server Shutdown Thread") { - public void run() { -@@ -898,6 +1139,29 @@ - - thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER)); - Runtime.getRuntime().addShutdownHook(thread); -+ */ -+ -+ if (optionset.has("port")) { -+ int port = (Integer) optionset.valueOf("port"); -+ if (port > 0) { -+ dedicatedserver.setPort(port); -+ } -+ } -+ -+ if (optionset.has("universe")) { -+ dedicatedserver.universe = (File) optionset.valueOf("universe"); -+ } -+ -+ if (optionset.has("forceUpgrade")) { -+ dedicatedserver.setForceUpgrade(true); -+ } -+ -+ if (optionset.has("eraseCache")) { -+ dedicatedserver.setEraseCache(true); -+ } -+ -+ dedicatedserver.serverThread.start(); -+ // CraftBukkit end - } catch (Exception exception) { - MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); - } -@@ -917,7 +1181,9 @@ - } - - public void startServerThread() { -+ /* CraftBukkit start - prevent abuse - this.serverThread.start(); -+ // CraftBukkit end */ - } - - public File d(String s) { -@@ -972,7 +1238,7 @@ +@@ -868,7 +1121,7 @@ } public String getServerModName() { @@ -677,29 +641,40 @@ } public CrashReport b(CrashReport crashreport) { -@@ -1013,7 +1279,7 @@ - public abstract Optional q(); +@@ -1217,11 +1470,11 @@ + + public CompletableFuture a(Collection collection) { + CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { +- Stream stream = collection.stream(); ++ Stream stream = collection.stream(); // CraftBukkit - decompile error + ResourcePackRepository resourcepackrepository = this.resourcePackRepository; + + this.resourcePackRepository.getClass(); +- return (ImmutableList) stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); ++ return stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error + }, this).thenCompose((immutablelist) -> { + return DataPackResources.a(immutablelist, this.j() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.h(), this.executorService, this); + }).thenAcceptAsync((datapackresources) -> { +@@ -1592,6 +1845,22 @@ - public boolean K() { -- return this.universe != null; -+ return true; // CraftBukkit } - @Override -@@ -1729,4 +1995,16 @@ - private void bb() { - Block.REGISTRY_ID.forEach(IBlockData::c); - } -+ + // CraftBukkit start + @Override + public boolean isMainThread() { + return super.isMainThread() || this.isStopped(); // CraftBukkit - MC-142590 + } + ++ public boolean isDebugging() { ++ return false; ++ } ++ + @Deprecated + public static MinecraftServer getServer() { + return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null; + } + // CraftBukkit end - } ++ + private void a(@Nullable GameProfilerTick gameprofilertick) { + if (this.O) { + this.O = false; diff --git a/nms-patches/MobEffectList.patch b/nms-patches/MobEffectList.patch index 3645f6b32d..52a8db6f3e 100644 --- a/nms-patches/MobEffectList.patch +++ b/nms-patches/MobEffectList.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/MobEffectList.java +++ b/net/minecraft/server/MobEffectList.java @@ -7,6 +7,11 @@ - import java.util.Map.Entry; + import java.util.UUID; import javax.annotation.Nullable; +// CraftBukkit start @@ -11,7 +11,7 @@ + public class MobEffectList { - private final Map a = Maps.newHashMap(); + private final Map a = Maps.newHashMap(); @@ -21,7 +26,7 @@ } @@ -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.cR()) && (this != MobEffects.HARM || !entityliving.cR())) { - if (this == MobEffects.HARM && !entityliving.cR() || this == MobEffects.HEAL && entityliving.cR()) { + } else if ((this != MobEffects.HEAL || entityliving.di()) && (this != MobEffects.HARM || !entityliving.di())) { + if (this == MobEffects.HARM && !entityliving.di() || this == MobEffects.HEAL && entityliving.di()) { entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); } } else { diff --git a/nms-patches/MobSpawnerPatrol.patch b/nms-patches/MobSpawnerPatrol.patch index b6dd3fe970..7f65850365 100644 --- a/nms-patches/MobSpawnerPatrol.patch +++ b/nms-patches/MobSpawnerPatrol.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MobSpawnerPatrol.java +++ b/net/minecraft/server/MobSpawnerPatrol.java -@@ -101,7 +101,7 @@ +@@ -102,7 +102,7 @@ entitymonsterpatrolling.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entitymonsterpatrolling.prepare(world, world.getDamageScaler(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null, (NBTTagCompound) null); diff --git a/nms-patches/MobSpawnerPhantom.patch b/nms-patches/MobSpawnerPhantom.patch index 194164ecef..a554bae1a8 100644 --- a/nms-patches/MobSpawnerPhantom.patch +++ b/nms-patches/MobSpawnerPhantom.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MobSpawnerPhantom.java +++ b/net/minecraft/server/MobSpawnerPhantom.java -@@ -56,7 +56,7 @@ +@@ -57,7 +57,7 @@ entityphantom.setPositionRotation(blockposition1, 0.0F, 0.0F); groupdataentity = entityphantom.prepare(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); diff --git a/nms-patches/MobSpawnerTrader.patch b/nms-patches/MobSpawnerTrader.patch index ea2082bcd1..575e45215f 100644 --- a/nms-patches/MobSpawnerTrader.patch +++ b/nms-patches/MobSpawnerTrader.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/server/MobSpawnerTrader.java +++ b/net/minecraft/server/MobSpawnerTrader.java -@@ -78,7 +78,7 @@ +@@ -83,7 +83,7 @@ return false; } -- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawnCreature(this.b, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false); -+ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawnCreature(this.b, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false); ++ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition2, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { -@@ -101,7 +101,7 @@ - BlockPosition blockposition = this.a(new BlockPosition(entityvillagertrader), i); +@@ -106,7 +106,7 @@ + BlockPosition blockposition = this.a(entityvillagertrader.world, entityvillagertrader.getChunkCoordinates(), i); if (blockposition != null) { -- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(this.b, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false); -+ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(this.b, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(entityvillagertrader.world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false); ++ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(entityvillagertrader.world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityllamatrader != null) { entityllamatrader.setLeashHolder(entityvillagertrader, true); diff --git a/nms-patches/NameReferencingFileConverter.patch b/nms-patches/NameReferencingFileConverter.patch index 72826c8b5b..4778daf1bb 100644 --- a/nms-patches/NameReferencingFileConverter.patch +++ b/nms-patches/NameReferencingFileConverter.patch @@ -1,54 +1,42 @@ --- a/net/minecraft/server/NameReferencingFileConverter.java +++ b/net/minecraft/server/NameReferencingFileConverter.java -@@ -81,8 +81,9 @@ - if (gameprofilebanlist.c().exists()) { +@@ -80,7 +80,7 @@ try { gameprofilebanlist.load(); -- } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.c().getName(), filenotfoundexception); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace -+ } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.c().getName()); + } catch (IOException ioexception) { +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName()); // CraftBukkit - don't print stacktrace } } -@@ -139,8 +140,9 @@ - if (ipbanlist.c().exists()) { +@@ -138,7 +138,7 @@ try { ipbanlist.load(); -- } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.c().getName(), filenotfoundexception); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace -+ } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.c().getName()); + } catch (IOException ioexception) { +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName()); // CraftBukkit - don't print stacktrace } } -@@ -180,8 +182,9 @@ - if (oplist.c().exists()) { +@@ -179,7 +179,7 @@ try { oplist.load(); -- } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.c().getName(), filenotfoundexception); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace -+ } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.c().getName()); + } catch (IOException ioexception) { +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName()); // CraftBukkit - don't print stacktrace } } -@@ -224,8 +227,9 @@ - if (whitelist.c().exists()) { +@@ -223,7 +223,7 @@ try { whitelist.load(); -- } catch (FileNotFoundException filenotfoundexception) { -- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.c().getName(), filenotfoundexception); -+ // CraftBukkit start - FileNotFoundException -> IOException, don't print stacktrace -+ } catch (IOException filenotfoundexception) { -+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.c().getName()); + } catch (IOException ioexception) { +- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName(), ioexception); ++ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName()); // CraftBukkit - don't print stacktrace } } -@@ -343,6 +347,30 @@ +@@ -346,6 +346,30 @@ File file5 = new File(file, s2 + ".dat"); File file6 = new File(file4, s3 + ".dat"); @@ -79,12 +67,3 @@ NameReferencingFileConverter.b(file4); if (!file5.renameTo(file6)) { throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2); -@@ -464,7 +492,7 @@ - - private static File getPlayersFolder(MinecraftServer minecraftserver) { - String s = minecraftserver.getWorld(); -- File file = new File(s); -+ File file = new File(MinecraftServer.getServer().server.getWorldContainer(), s); // CraftBukkit - Respect container setting - - return new File(file, "players"); - } diff --git a/nms-patches/NetworkManager.patch b/nms-patches/NetworkManager.patch index dab0a63327..ce04c3cf06 100644 --- a/nms-patches/NetworkManager.patch +++ b/nms-patches/NetworkManager.patch @@ -9,7 +9,7 @@ } public void setPacketListener(PacketListener packetlistener) { -@@ -234,7 +234,7 @@ +@@ -233,7 +233,7 @@ public void close(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch index d6e6bcc1ca..4c1bd0f0a4 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 -@@ -23,6 +23,8 @@ +@@ -26,6 +26,8 @@ import java.util.UUID; import javax.annotation.Nullable; @@ -9,7 +9,7 @@ public class PacketDataSerializer extends ByteBuf { private final ByteBuf a; -@@ -130,7 +132,7 @@ +@@ -154,7 +156,7 @@ } public > T a(Class oclass) { @@ -18,7 +18,7 @@ } public PacketDataSerializer a(Enum oenum) { -@@ -207,7 +209,7 @@ +@@ -231,7 +233,7 @@ } else { try { NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); @@ -27,7 +27,7 @@ throw new EncoderException(ioexception); } } -@@ -234,7 +236,7 @@ +@@ -258,7 +260,7 @@ } public PacketDataSerializer a(ItemStack itemstack) { @@ -36,7 +36,7 @@ this.writeBoolean(false); } else { this.writeBoolean(true); -@@ -263,6 +265,11 @@ +@@ -287,6 +289,11 @@ ItemStack itemstack = new ItemStack(Item.getById(i), b0); itemstack.setTag(this.l()); diff --git a/nms-patches/PacketPlayOutWorldBorder.patch b/nms-patches/PacketPlayOutWorldBorder.patch index f9c9ef82d6..f55857a473 100644 --- a/nms-patches/PacketPlayOutWorldBorder.patch +++ b/nms-patches/PacketPlayOutWorldBorder.patch @@ -7,8 +7,8 @@ - this.c = worldborder.getCenterX(); - this.d = worldborder.getCenterZ(); + // CraftBukkit start - multiply out nether border -+ this.c = worldborder.getCenterX() * (worldborder.world.worldProvider instanceof WorldProviderHell ? 8 : 1); -+ this.d = worldborder.getCenterZ() * (worldborder.world.worldProvider instanceof WorldProviderHell ? 8 : 1); ++ this.c = worldborder.getCenterX() * (worldborder.world.getDimensionManager().h() ? 8 : 1); ++ this.d = worldborder.getCenterZ() * (worldborder.world.getDimensionManager().h() ? 8 : 1); + // CraftBukkit end this.f = worldborder.getSize(); this.e = worldborder.k(); diff --git a/nms-patches/PacketStatusListener.patch b/nms-patches/PacketStatusListener.patch index 1717fdefe9..3d1a3a9e5f 100644 --- a/nms-patches/PacketStatusListener.patch +++ b/nms-patches/PacketStatusListener.patch @@ -16,7 +16,7 @@ + public class PacketStatusListener implements PacketStatusInListener { - private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled", new Object[0]); + private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled"); @@ -26,8 +37,96 @@ this.networkManager.close(PacketStatusListener.a); } else { diff --git a/nms-patches/PathfinderGoalBreed.patch b/nms-patches/PathfinderGoalBreed.patch deleted file mode 100644 index 87874dc763..0000000000 --- a/nms-patches/PathfinderGoalBreed.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- a/net/minecraft/server/PathfinderGoalBreed.java -+++ b/net/minecraft/server/PathfinderGoalBreed.java -@@ -82,11 +82,24 @@ - EntityAgeable entityageable = this.animal.createChild(this.partner); - - if (entityageable != null) { -+ // CraftBukkit start - set persistence for tame animals -+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) { -+ entityageable.persistent = true; -+ } -+ // CraftBukkit end - EntityPlayer entityplayer = this.animal.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, entityplayer, this.animal.breedItem, experience); -+ if (entityBreedEvent.isCancelled()) { -+ return; -+ } -+ experience = entityBreedEvent.getExperience(); -+ // CraftBukkit end - - if (entityplayer != null) { - entityplayer.a(StatisticList.ANIMALS_BRED); -@@ -99,10 +112,14 @@ - this.partner.resetLove(); - entityageable.setAgeRaw(-24000); - entityageable.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F); -- this.b.addEntity(entityageable); -+ this.b.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - this.b.broadcastEntityEffect(this.animal, (byte) 18); - if (this.b.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { -- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), this.animal.getRandom().nextInt(7) + 1)); -+ // CraftBukkit start - use event experience -+ if (experience > 0) { -+ this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), experience)); -+ } -+ // CraftBukkit end - } - - } diff --git a/nms-patches/PathfinderGoalEatTile.patch b/nms-patches/PathfinderGoalEatTile.patch index d1d01cd4b2..d6d75318ad 100644 --- a/nms-patches/PathfinderGoalEatTile.patch +++ b/nms-patches/PathfinderGoalEatTile.patch @@ -12,7 +12,7 @@ private static final Predicate a = BlockStatePredicate.a(Blocks.GRASS); @@ -55,7 +59,8 @@ - BlockPosition blockposition = new BlockPosition(this.b); + BlockPosition blockposition = this.b.getChunkCoordinates(); if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) { - if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { @@ -24,7 +24,7 @@ @@ -64,7 +69,8 @@ BlockPosition blockposition1 = blockposition.down(); - if (this.c.getType(blockposition1).getBlock() == Blocks.GRASS_BLOCK) { + if (this.c.getType(blockposition1).a(Blocks.GRASS_BLOCK)) { - if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) { + // CraftBukkit + if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) { diff --git a/nms-patches/PathfinderGoalFollowOwner.patch b/nms-patches/PathfinderGoalFollowOwner.patch index 7de5e50013..5c640a379b 100644 --- a/nms-patches/PathfinderGoalFollowOwner.patch +++ b/nms-patches/PathfinderGoalFollowOwner.patch @@ -16,10 +16,10 @@ } else if (!this.a(new BlockPosition(i, j, k))) { return false; } else { -- this.a.setPositionRotation((double) ((float) i + 0.5F), (double) j, (double) ((float) k + 0.5F), this.a.yaw, this.a.pitch); +- this.a.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch); + // CraftBukkit start + CraftEntity entity = this.a.getBukkitEntity(); -+ Location to = new Location(entity.getWorld(), (double) ((float) i + 0.5F), (double) j, (double) ((float) k + 0.5F), this.a.yaw, this.a.pitch); ++ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch); + EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to); + this.a.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { diff --git a/nms-patches/PathfinderGoalHorseTrap.patch b/nms-patches/PathfinderGoalHorseTrap.patch index 628d80ac16..ad62e15112 100644 --- a/nms-patches/PathfinderGoalHorseTrap.patch +++ b/nms-patches/PathfinderGoalHorseTrap.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/PathfinderGoalHorseTrap.java +++ b/net/minecraft/server/PathfinderGoalHorseTrap.java -@@ -20,16 +20,17 @@ - this.a.r(false); - this.a.setTamed(true); - this.a.setAgeRaw(0); -- ((WorldServer) this.a.world).strikeLightning(new EntityLightning(this.a.world, this.a.locX(), this.a.locY(), this.a.locZ(), true)); -+ ((WorldServer) this.a.world).strikeLightning(new EntityLightning(this.a.world, this.a.locX(), this.a.locY(), this.a.locZ(), true), org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit +@@ -24,16 +24,17 @@ + + entitylightning.teleportAndSync(this.a.locX(), this.a.locY(), this.a.locZ()); + entitylightning.setEffect(true); +- this.a.world.addEntity(entitylightning); ++ ((WorldServer) this.a.world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a); - entityskeleton.startRiding(this.a); @@ -21,7 +21,7 @@ entityhorseabstract.h(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); } -@@ -44,7 +45,7 @@ +@@ -48,7 +49,7 @@ entityhorseskeleton.setPersistent(); entityhorseskeleton.setTamed(true); entityhorseskeleton.setAgeRaw(0); @@ -30,7 +30,7 @@ return entityhorseskeleton; } -@@ -61,7 +62,7 @@ +@@ -65,7 +66,7 @@ entityskeleton.setSlot(EnumItemSlot.MAINHAND, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getItemInMainHand(), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); entityskeleton.setSlot(EnumItemSlot.HEAD, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getEquipment(EnumItemSlot.HEAD), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); diff --git a/nms-patches/PathfinderGoalHurtByTarget.patch b/nms-patches/PathfinderGoalHurtByTarget.patch index 35f5060720..e96c26d7de 100644 --- a/nms-patches/PathfinderGoalHurtByTarget.patch +++ b/nms-patches/PathfinderGoalHurtByTarget.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/PathfinderGoalHurtByTarget.java +++ b/net/minecraft/server/PathfinderGoalHurtByTarget.java -@@ -49,7 +49,7 @@ +@@ -53,7 +53,7 @@ @Override public void c() { - 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.c = this.e.cI(); + this.c = this.e.cZ(); this.h = 300; -@@ -95,6 +95,6 @@ +@@ -100,6 +100,6 @@ } protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { diff --git a/nms-patches/PathfinderGoalNearestAttackableTarget.patch b/nms-patches/PathfinderGoalNearestAttackableTarget.patch index 60b369519d..2ef0b8eee7 100644 --- a/nms-patches/PathfinderGoalNearestAttackableTarget.patch +++ b/nms-patches/PathfinderGoalNearestAttackableTarget.patch @@ -8,4 +8,4 @@ + this.e.setGoalTarget(this.c, c instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason super.c(); } - } + diff --git a/nms-patches/PathfinderGoalPanic.patch b/nms-patches/PathfinderGoalPanic.patch index 1df6e52fe1..3f8e380e7d 100644 --- a/nms-patches/PathfinderGoalPanic.patch +++ b/nms-patches/PathfinderGoalPanic.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalPanic.java +++ b/net/minecraft/server/PathfinderGoalPanic.java -@@ -57,6 +57,12 @@ +@@ -68,6 +68,12 @@ @Override public boolean b() { diff --git a/nms-patches/PathfinderGoalSit.patch b/nms-patches/PathfinderGoalSit.patch index 4105f1d26e..d372bc16f7 100644 --- a/nms-patches/PathfinderGoalSit.patch +++ b/nms-patches/PathfinderGoalSit.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/PathfinderGoalSit.java +++ b/net/minecraft/server/PathfinderGoalSit.java -@@ -20,7 +20,7 @@ +@@ -19,7 +19,7 @@ @Override public boolean a() { if (!this.entity.isTamed()) { - return false; -+ return this.willSit && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.entity.az()) { ++ return this.entity.isWillSit() && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals + } else if (this.entity.aD()) { return false; - } else if (!this.entity.onGround) { + } else if (!this.entity.isOnGround()) { diff --git a/nms-patches/PathfinderGoalTame.patch b/nms-patches/PathfinderGoalTame.patch index 0b2e3018d1..e7d57703b4 100644 --- a/nms-patches/PathfinderGoalTame.patch +++ b/nms-patches/PathfinderGoalTame.patch @@ -7,6 +7,6 @@ - if (j > 0 && this.entity.getRandom().nextInt(j) < i) { + // CraftBukkit - fire EntityTameEvent + if (j > 0 && this.entity.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.entity.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { - this.entity.h((EntityHuman) entity); + this.entity.i((EntityHuman) entity); return; } diff --git a/nms-patches/PathfinderGoalTarget.patch b/nms-patches/PathfinderGoalTarget.patch index 397bb0da35..eb920b76ce 100644 --- a/nms-patches/PathfinderGoalTarget.patch +++ b/nms-patches/PathfinderGoalTarget.patch @@ -17,7 +17,7 @@ return true; } } -@@ -82,7 +83,7 @@ +@@ -80,7 +81,7 @@ @Override public void d() { diff --git a/nms-patches/PlayerChunk.patch b/nms-patches/PlayerChunk.patch index fd52f02827..d427e1d8d8 100644 --- a/nms-patches/PlayerChunk.patch +++ b/nms-patches/PlayerChunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerChunk.java +++ b/net/minecraft/server/PlayerChunk.java -@@ -43,7 +43,7 @@ +@@ -42,7 +42,7 @@ this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; @@ -9,7 +9,7 @@ this.dirtyBlocks = new short[64]; this.location = chunkcoordintpair; this.lightEngine = lightengine; -@@ -55,6 +55,15 @@ +@@ -54,6 +54,15 @@ this.a(i); } @@ -25,7 +25,7 @@ public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) { CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c()); -@@ -80,9 +89,9 @@ +@@ -79,9 +88,9 @@ @Nullable public Chunk getChunk() { CompletableFuture> completablefuture = this.a(); @@ -37,7 +37,7 @@ } @Nullable -@@ -223,7 +232,7 @@ +@@ -210,7 +219,7 @@ CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(i); if (completablefuture != null) { @@ -46,7 +46,7 @@ if (either == null || either.left().isPresent()) { return completablefuture; -@@ -278,6 +287,30 @@ +@@ -265,6 +274,30 @@ boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET; PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel); @@ -77,7 +77,7 @@ CompletableFuture completablefuture; if (flag) { -@@ -309,7 +342,7 @@ +@@ -296,7 +329,7 @@ if (flag2 && !flag3) { completablefuture = this.fullChunkFuture; this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; @@ -86,9 +86,9 @@ playerchunkmap.getClass(); return either1.ifLeft(playerchunkmap::a); })); -@@ -347,6 +380,26 @@ +@@ -334,6 +367,26 @@ - this.w.a(this.location, this::k, this.ticketLevel, this::d); + this.v.a(this.location, this::k, this.ticketLevel, this::d); this.oldTicketLevel = this.ticketLevel; + // CraftBukkit start + // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins. diff --git a/nms-patches/PlayerChunkMap.patch b/nms-patches/PlayerChunkMap.patch index 0b3fced791..fa4d1733a3 100644 --- a/nms-patches/PlayerChunkMap.patch +++ b/nms-patches/PlayerChunkMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerChunkMap.java +++ b/net/minecraft/server/PlayerChunkMap.java -@@ -43,6 +43,7 @@ +@@ -44,6 +44,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,8 +8,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { -@@ -73,6 +74,31 @@ - private final Queue z; +@@ -75,6 +76,31 @@ + private final Queue A; private int viewDistance; + // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() @@ -37,10 +37,10 @@ + }; + // CraftBukkit end + - public PlayerChunkMap(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier supplier, int i) { - super(new File(worldserver.getWorldProvider().getDimensionManager().a(file), "region"), datafixer); + public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier supplier, int i, boolean flag) { + super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag); this.visibleChunks = this.updatingChunks.clone(); -@@ -192,9 +218,12 @@ +@@ -195,9 +221,12 @@ return completablefuture1.thenApply((list1) -> { List list2 = Lists.newArrayList(); @@ -55,7 +55,7 @@ final Either either = (Either) iterator.next(); Optional optional = either.left(); -@@ -297,7 +326,7 @@ +@@ -300,7 +329,7 @@ PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName()); } else { this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> { @@ -64,7 +64,7 @@ if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { this.saveChunk(ichunkaccess); -@@ -308,7 +337,6 @@ +@@ -311,7 +340,6 @@ } } @@ -72,7 +72,7 @@ protected void unloadChunks(BooleanSupplier booleansupplier) { GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); -@@ -347,7 +375,7 @@ +@@ -350,7 +378,7 @@ private void a(long i, PlayerChunk playerchunk) { CompletableFuture completablefuture = playerchunk.getChunkSave(); @@ -81,16 +81,7 @@ CompletableFuture completablefuture1 = playerchunk.getChunkSave(); if (completablefuture1 != completablefuture) { -@@ -500,7 +528,7 @@ - return CompletableFuture.completedFuture(Either.right(playerchunk_failure)); - }); - }, (runnable) -> { -- this.mailboxWorldGen.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); -+ this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error - }); - } - -@@ -558,8 +586,15 @@ +@@ -572,8 +600,15 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -107,43 +98,7 @@ if (list == null) { list = Lists.newArrayList(new Entity[]{entity}); } else { -@@ -581,7 +616,7 @@ - long i = playerchunk.i().pair(); - - playerchunk.getClass(); -- mailbox.a((Object) ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); -+ mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::getTicketLevel)); // CraftBukkit - decompile error - }); - } - -@@ -598,7 +633,7 @@ - return Either.left(chunk); - }); - }, (runnable) -> { -- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); -+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error - }); - - completablefuture1.thenAcceptAsync((either) -> { -@@ -612,7 +647,7 @@ - return Either.left(chunk); - }); - }, (runnable) -> { -- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); -+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error - }); - return completablefuture1; - } -@@ -626,7 +661,7 @@ - return chunk; - }); - }, (runnable) -> { -- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); -+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error - }); - } - -@@ -751,7 +786,8 @@ +@@ -784,7 +819,8 @@ return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); }); @@ -153,7 +108,7 @@ return Stream.of(chunk.getEntitySlices()).mapToInt(EntitySlice::size).sum(); }).orElse(0), optional1.map((chunk) -> { return chunk.getTileEntities().size(); -@@ -762,7 +798,7 @@ +@@ -795,7 +831,7 @@ private static String a(CompletableFuture> completablefuture) { try { @@ -162,16 +117,16 @@ return either != null ? (String) either.map((chunk) -> { return "done"; -@@ -780,7 +816,7 @@ +@@ -813,7 +849,7 @@ private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException { NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); -- return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.l, nbttagcompound); -+ return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit +- return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound); ++ return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit } boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) { -@@ -1114,7 +1150,7 @@ +@@ -1145,7 +1181,7 @@ public final Set trackedPlayers = Sets.newHashSet(); public EntityTracker(Entity entity, int i, int j, boolean flag) { @@ -180,7 +135,7 @@ this.tracker = entity; this.trackingDistance = i; this.e = SectionPosition.a(entity); -@@ -1167,7 +1203,7 @@ +@@ -1198,7 +1234,7 @@ public void updatePlayer(EntityPlayer entityplayer) { if (entityplayer != this.tracker) { @@ -189,7 +144,7 @@ int i = Math.min(this.b(), (PlayerChunkMap.this.viewDistance - 1) * 16); boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.tracker.a(entityplayer); -@@ -1183,6 +1219,17 @@ +@@ -1214,6 +1250,17 @@ } } diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 3ca314c5f8..86744016d4 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -102,7 +102,7 @@ - if (i - this.lastKeepAlive >= 15000L) { + if (i - this.lastKeepAlive >= 25000L) { // CraftBukkit if (this.awaitingKeepAlive) { - this.disconnect(new ChatMessage("disconnect.timeout", new Object[0])); + this.disconnect(new ChatMessage("disconnect.timeout")); } else { @@ -121,15 +192,21 @@ } @@ -123,7 +123,7 @@ if (this.player.F() > 0L && this.minecraftServer.getIdleTimeout() > 0 && SystemUtils.getMonotonicMillis() - this.player.F() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854 - this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0])); + this.disconnect(new ChatMessage("multiplayer.disconnect.idling")); } @@ -153,16 +230,46 @@ @@ -282,8 +282,8 @@ + this.player.getWorldServer().getChunkProvider().movePlayer(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.b(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -@@ -255,7 +447,7 @@ + this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && this.a(entity); +@@ -259,7 +451,7 @@ @Override public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) { PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer()); @@ -292,7 +292,7 @@ this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); this.o = this.teleportPos.x; this.p = this.teleportPos.y; -@@ -265,6 +457,7 @@ +@@ -269,6 +461,7 @@ } this.teleportPos = null; @@ -300,7 +300,7 @@ } } -@@ -273,7 +466,7 @@ +@@ -277,7 +470,7 @@ public void a(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureMainThread(packetplayinrecipedisplayed, this, this.player.getWorldServer()); if (packetplayinrecipedisplayed.b() == PacketPlayInRecipeDisplayed.Status.SHOWN) { @@ -309,7 +309,7 @@ RecipeBookServer recipebookserver = this.player.B(); optional.ifPresent(recipebookserver::e); -@@ -307,6 +500,12 @@ +@@ -311,6 +504,12 @@ @Override public void a(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); @@ -322,17 +322,15 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.c()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -316,7 +515,8 @@ +@@ -320,6 +519,7 @@ ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { -- this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); -+ if (((Suggestions) suggestions).isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [] from showing for plugins with nothing more to offer -+ this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestions)); // CraftBukkit - decompile error ++ if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [] from showing for plugins with nothing more to offer + this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); }); } - -@@ -526,6 +726,7 @@ +@@ -548,6 +748,7 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -340,7 +338,7 @@ containermerchant.d(i); containermerchant.g(i); -@@ -536,6 +737,14 @@ +@@ -558,6 +759,14 @@ @Override public void a(PacketPlayInBEdit packetplayinbedit) { PlayerConnectionUtils.ensureMainThread(packetplayinbedit, this, this.player.getWorldServer()); @@ -355,7 +353,7 @@ ItemStack itemstack = packetplayinbedit.b(); if (!itemstack.isEmpty()) { -@@ -564,9 +773,11 @@ +@@ -586,9 +795,11 @@ } itemstack2.a("pages", (NBTBase) nbttaglist); @@ -368,16 +366,16 @@ } } -@@ -608,7 +819,7 @@ +@@ -630,7 +841,7 @@ } else { - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); + WorldServer worldserver = this.player.getWorldServer(); - if (!this.player.viewingCredits) { + if (!this.player.viewingCredits && !this.player.isFrozen()) { // CraftBukkit if (this.e == 0) { this.syncPosition(); } -@@ -618,13 +829,21 @@ +@@ -640,13 +851,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -400,7 +398,7 @@ double d0 = this.player.locX(); double d1 = this.player.locY(); double d2 = this.player.locZ(); -@@ -649,15 +868,33 @@ +@@ -671,15 +890,33 @@ ++this.receivedMovePackets; int i = this.receivedMovePackets - this.processedMovePackets; @@ -436,80 +434,80 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9); this.a(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.yaw, this.player.pitch); return; -@@ -707,7 +944,71 @@ - } - } - -- this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && !worldserver.b(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -+ // CraftBukkit start - fire PlayerMoveEvent -+ // Rest to old location first -+ this.player.setLocation(prevX, prevY, prevZ, prevYaw, prevPitch); +@@ -719,7 +956,71 @@ + if (!this.player.noclip && !this.player.isSleeping() && (flag1 && worldserver.getCubes(this.player, axisalignedbb) || this.a((IWorldReader) worldserver, axisalignedbb))) { + this.a(d0, d1, d2, f, f1); + } else { +- this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && this.a((Entity) this.player); ++ // CraftBukkit start - fire PlayerMoveEvent ++ // Rest to old location first ++ this.player.setLocation(prevX, prevY, prevZ, prevYaw, prevPitch); + -+ Player player = this.getPlayer(); -+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. -+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. ++ Player player = this.getPlayer(); ++ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. ++ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + -+ // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (packetplayinflying.hasPos) { -+ to.setX(packetplayinflying.x); -+ to.setY(packetplayinflying.y); -+ to.setZ(packetplayinflying.z); -+ } ++ // If the packet contains movement information then we update the To location with the correct XYZ. ++ if (packetplayinflying.hasPos) { ++ to.setX(packetplayinflying.x); ++ to.setY(packetplayinflying.y); ++ to.setZ(packetplayinflying.z); ++ } + -+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packetplayinflying.hasLook) { -+ to.setYaw(packetplayinflying.yaw); -+ to.setPitch(packetplayinflying.pitch); -+ } ++ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. ++ if (packetplayinflying.hasLook) { ++ to.setYaw(packetplayinflying.yaw); ++ to.setPitch(packetplayinflying.pitch); ++ } + -+ // Prevent 40 event-calls for less than a single pixel of movement >.> -+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); -+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); ++ // Prevent 40 event-calls for less than a single pixel of movement >.> ++ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); ++ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + -+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isFrozen()) { -+ this.lastPosX = to.getX(); -+ this.lastPosY = to.getY(); -+ this.lastPosZ = to.getZ(); -+ this.lastYaw = to.getYaw(); -+ this.lastPitch = to.getPitch(); ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isFrozen()) { ++ this.lastPosX = to.getX(); ++ this.lastPosY = to.getY(); ++ this.lastPosZ = to.getZ(); ++ this.lastYaw = to.getYaw(); ++ this.lastPitch = to.getPitch(); + -+ // Skip the first time we do this -+ if (from.getX() != Double.MAX_VALUE) { -+ Location oldTo = to.clone(); -+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); -+ this.server.getPluginManager().callEvent(event); ++ // Skip the first time we do this ++ if (from.getX() != Double.MAX_VALUE) { ++ Location oldTo = to.clone(); ++ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); ++ this.server.getPluginManager().callEvent(event); + -+ // If the event is cancelled we move the player back to their old location. -+ if (event.isCancelled()) { -+ teleport(from); -+ return; -+ } ++ // If the event is cancelled we move the player back to their old location. ++ if (event.isCancelled()) { ++ teleport(from); ++ return; ++ } + -+ // If a Plugin has changed the To destination then we teleport the Player -+ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. -+ // We only do this if the Event was not cancelled. -+ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { -+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); -+ return; -+ } ++ // If a Plugin has changed the To destination then we teleport the Player ++ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. ++ // We only do this if the Event was not cancelled. ++ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { ++ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); ++ return; ++ } + -+ // Check to see if the Players Location has some how changed during the call of the event. -+ // This can happen due to a plugin teleporting the player instead of using .setTo() -+ if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) { -+ this.justTeleported = false; -+ return; ++ // Check to see if the Players Location has some how changed during the call of the event. ++ // This can happen due to a plugin teleporting the player instead of using .setTo() ++ if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) { ++ this.justTeleported = false; ++ return; ++ } + } + } -+ } -+ this.player.setLocation(d4, d5, d6, f, f1); // Copied from above ++ this.player.setLocation(d4, d5, d6, f, f1); // Copied from above + -+ // MC-135989, SPIGOT-5564: isRiptiding -+ this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && !worldserver.b(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)) && !this.player.isRiptiding(); -+ // CraftBukkit end - this.player.onGround = packetplayinflying.b(); - this.player.getWorldServer().getChunkProvider().movePlayer(this.player); - this.player.a(this.player.locY() - d3, packetplayinflying.b()); -@@ -726,10 +1027,66 @@ ++ // MC-135989, SPIGOT-5564: isRiptiding ++ this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && this.a((Entity) this.player) && !this.player.isRiptiding(); ++ // CraftBukkit end + this.player.getWorldServer().getChunkProvider().movePlayer(this.player); + this.player.a(this.player.locY() - d3, packetplayinflying.b()); + this.player.c(packetplayinflying.b()); +@@ -751,10 +1052,66 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -577,7 +575,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; -@@ -741,6 +1098,14 @@ +@@ -766,6 +1123,14 @@ this.teleportAwait = 0; } @@ -592,7 +590,7 @@ this.A = this.e; this.player.setLocation(d0, d1, d2, f, f1); this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait)); -@@ -749,6 +1114,7 @@ +@@ -774,6 +1139,7 @@ @Override public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); @@ -600,7 +598,7 @@ BlockPosition blockposition = packetplayinblockdig.b(); this.player.resetIdleTimer(); -@@ -759,13 +1125,45 @@ +@@ -784,14 +1150,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); @@ -625,6 +623,7 @@ + this.player.a(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); + } + // CraftBukkit end + this.player.clearActiveItem(); } return; @@ -645,44 +644,43 @@ + } + } + // CraftBukkit end - this.player.n(false); + this.player.dropItem(false); } -@@ -792,6 +1190,7 @@ +@@ -828,6 +1226,7 @@ @Override public void a(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); + WorldServer worldserver = this.player.getWorldServer(); EnumHand enumhand = packetplayinuseitem.b(); ItemStack itemstack = this.player.b(enumhand); -@@ -805,6 +1204,14 @@ +@@ -838,6 +1237,14 @@ + this.player.resetIdleTimer(); + if (blockposition.getY() < this.minecraftServer.getMaxBuildHeight()) { + if (this.teleportPos == null && this.player.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) { ++ // CraftBukkit start - Check if we can actually do something over this large a distance ++ Location eyeLoc = this.getPlayer().getEyeLocation(); ++ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); ++ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { ++ return; ++ } ++ this.player.clearActiveItem(); // SPIGOT-4706 ++ // CraftBukkit end + EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); - this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO)); - } else if (this.teleportPos == null && this.player.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) { -+ // CraftBukkit start - Check if we can actually do something over this large a distance -+ Location eyeLoc = this.getPlayer().getEyeLocation(); -+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); -+ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) { -+ return; -+ } -+ this.player.clearActiveItem(); // SPIGOT-4706 -+ // CraftBukkit end - EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); - - if (enuminteractionresult.b()) { -@@ -819,13 +1226,53 @@ + if (enumdirection == EnumDirection.UP && !enuminteractionresult.a() && blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && a(this.player, itemstack)) { +@@ -861,12 +1268,51 @@ @Override public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); + WorldServer worldserver = this.player.getWorldServer(); EnumHand enumhand = packetplayinblockplace.b(); ItemStack itemstack = this.player.b(enumhand); this.player.resetIdleTimer(); if (!itemstack.isEmpty()) { -- this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); + // CraftBukkit start + // Raytrace to look for 'rogue armswings' + float f1 = this.player.pitch; @@ -719,14 +717,12 @@ + + if (cancelled) { + this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 -+ } else { -+ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); ++ return; + } -+ // CraftBukkit end - } - } + EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); -@@ -840,7 +1287,7 @@ + if (enuminteractionresult.b()) { +@@ -887,7 +1333,7 @@ Entity entity = packetplayinspectate.a(worldserver); if (entity != null) { @@ -735,7 +731,7 @@ return; } } -@@ -849,7 +1296,12 @@ +@@ -896,7 +1342,12 @@ } @Override @@ -749,7 +745,7 @@ @Override public void a(PacketPlayInBoatMove packetplayinboatmove) { -@@ -864,11 +1316,26 @@ +@@ -911,11 +1362,26 @@ @Override public void a(IChatBaseComponent ichatbasecomponent) { @@ -764,10 +760,10 @@ + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* this.minecraftServer.invalidatePingSample(); - this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW)); + this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.b); + */ + - this.player.n(); + this.player.p(); - this.minecraftServer.getPlayerList().disconnect(this.player); + String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); + if ((quitMessage != null) && (quitMessage.length() > 0)) { @@ -777,7 +773,7 @@ if (this.isExemptPlayer()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(false); -@@ -894,6 +1361,15 @@ +@@ -941,6 +1407,15 @@ } } @@ -793,7 +789,7 @@ try { this.networkManager.sendPacket(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -910,18 +1386,38 @@ +@@ -957,7 +1432,16 @@ @Override public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); @@ -807,7 +803,10 @@ + return; + } + // CraftBukkit end - this.player.inventory.itemInHandIndex = packetplayinhelditemslot.b(); + if (this.player.inventory.itemInHandIndex != packetplayinhelditemslot.b() && this.player.getRaisedHand() == EnumHand.MAIN_HAND) { + this.player.clearActiveItem(); + } +@@ -966,13 +1450,24 @@ this.player.resetIdleTimer(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString()); @@ -831,20 +830,20 @@ + } + // CraftBukkit end + if (this.player.dead || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales - this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED))); + this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).a(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.b)); } else { this.player.resetIdleTimer(); -@@ -931,41 +1427,257 @@ +@@ -980,41 +1475,254 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { -- this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters", new Object[0])); +- this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters")); + // CraftBukkit start - threadsafety + if (!isSync) { + Waitable waitable = new Waitable() { + @Override + protected Object evaluate() { -+ PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters", new Object[0])); ++ PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters")); + return null; + } + }; @@ -859,7 +858,7 @@ + throw new RuntimeException(e); + } + } else { -+ this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters", new Object[0])); ++ this.disconnect(new ChatMessage("multiplayer.disconnect.illegal_characters")); + } + // CraftBukkit end return; @@ -887,22 +886,19 @@ + } + }); + } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check -+ ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); -+ -+ chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -+ this.sendPacket(new PacketPlayOutChat(chatmessage)); ++ this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).a(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.b)); + } else if (true) { + this.chat(s, true); + // CraftBukkit end - the below is for reference. :) } else { ChatMessage chatmessage = new ChatMessage("chat.type.text", new Object[]{this.player.getScoreboardDisplayName(), s}); - this.minecraftServer.getPlayerList().sendMessage(chatmessage, false); + this.minecraftServer.getPlayerList().sendMessage(chatmessage, ChatMessageType.CHAT, this.player.getUniqueID()); } - this.chatThrottle += 20; - if (this.chatThrottle > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { -- this.disconnect(new ChatMessage("disconnect.spam", new Object[0])); +- this.disconnect(new ChatMessage("disconnect.spam")); + // CraftBukkit start - replaced with thread safe throttle + // this.chatThrottle += 20; + if (chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { @@ -910,7 +906,7 @@ + Waitable waitable = new Waitable() { + @Override + protected Object evaluate() { -+ PlayerConnection.this.disconnect(new ChatMessage("disconnect.spam", new Object[0])); ++ PlayerConnection.this.disconnect(new ChatMessage("disconnect.spam")); + return null; + } + }; @@ -925,7 +921,7 @@ + throw new RuntimeException(e); + } + } else { -+ this.disconnect(new ChatMessage("disconnect.spam", new Object[0])); ++ this.disconnect(new ChatMessage("disconnect.spam")); + } + // CraftBukkit end } @@ -1067,7 +1063,7 @@ + + if (event.isCancelled()) return; + // CraftBukkit end - this.player.a(packetplayinarmanimation.b()); + this.player.swingHand(packetplayinarmanimation.b()); } @Override @@ -1099,17 +1095,17 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -1023,6 +1735,7 @@ +@@ -1072,6 +1780,7 @@ @Override public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); + WorldServer worldserver = this.player.getWorldServer(); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -1038,9 +1751,52 @@ - if (this.player.h(entity) < d0) { - EnumHand enumhand; +@@ -1084,18 +1793,72 @@ + EnumHand enumhand = packetplayinuseentity.c(); + Optional optional = Optional.empty(); + ItemStack itemInHand = this.player.b(packetplayinuseentity.c() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.c()); // CraftBukkit + @@ -1150,20 +1146,14 @@ + } + if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { - enumhand = packetplayinuseentity.c(); - this.player.a(entity, enumhand); + optional = Optional.of(this.player.a(entity, enumhand)); + // CraftBukkit start + if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + this.player.updateInventory(this.player.activeContainer); + } + // CraftBukkit end } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { - enumhand = packetplayinuseentity.c(); - EnumInteractionResult enuminteractionresult = entity.a((EntityHuman) this.player, packetplayinuseentity.d(), enumhand); -@@ -1048,14 +1804,25 @@ - if (enuminteractionresult.b()) { - this.player.a(enumhand, true); - } + optional = Optional.of(entity.a((EntityHuman) this.player, packetplayinuseentity.d(), enumhand)); + // CraftBukkit start + if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + this.player.updateInventory(this.player.activeContainer); @@ -1172,8 +1162,8 @@ } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) { - if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) { + if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || (entity == this.player && !player.isSpectator())) { // CraftBukkit - this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked", new Object[0])); - this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " tried to attack an invalid entity"); + this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked")); + PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", this.player.getDisplayName().getString()); return; } @@ -1185,9 +1175,9 @@ + } + // CraftBukkit end } - } - } -@@ -1095,15 +1862,21 @@ + + if (optional.isPresent() && ((EnumInteractionResult) optional.get()).a()) { +@@ -1142,15 +1905,21 @@ @Override public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); @@ -1195,7 +1185,7 @@ + if (this.player.isFrozen()) return; // CraftBukkit + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit + - this.player.m(); + this.player.o(); } @Override @@ -1211,7 +1201,7 @@ NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { -@@ -1112,8 +1885,274 @@ +@@ -1159,8 +1928,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { @@ -1228,7 +1218,7 @@ + ClickType click = ClickType.UNKNOWN; + InventoryAction action = InventoryAction.UNKNOWN; + -+ ItemStack itemstack = ItemStack.a; ++ ItemStack itemstack = ItemStack.b; + + switch (packetplayinwindowclick.g()) { + case PICKUP: @@ -1413,14 +1403,14 @@ + } + } + } - ++ + event.setCancelled(cancelled); + Container oldContainer = this.player.activeContainer; // SPIGOT-1224 + server.getPluginManager().callEvent(event); + if (this.player.activeContainer != oldContainer) { + return; + } -+ + + switch (event.getResult()) { + case ALLOW: + case DEFAULT: @@ -1487,7 +1477,7 @@ if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); this.player.e = true; -@@ -1153,6 +2192,7 @@ +@@ -1200,6 +2235,7 @@ @Override public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); @@ -1495,7 +1485,7 @@ this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { this.player.activeContainer.a((EntityHuman) this.player, packetplayinenchantitem.c()); -@@ -1185,6 +2225,43 @@ +@@ -1232,6 +2268,43 @@ boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1530,7 +1520,7 @@ + // Reset the slot + if (packetplayinsetcreativeslot.b() >= 0) { + this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.b(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem())); -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, ItemStack.a)); ++ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, ItemStack.b)); + } + return; + } @@ -1539,7 +1529,7 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -1206,6 +2283,7 @@ +@@ -1253,6 +2326,7 @@ @Override public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); @@ -1547,18 +1537,18 @@ int i = this.player.activeContainer.windowId; if (i == packetplayintransaction.b() && this.k.getOrDefault(i, (short) (packetplayintransaction.c() + 1)) == packetplayintransaction.c() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -1217,6 +2295,7 @@ +@@ -1264,6 +2338,7 @@ @Override public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); - WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); + WorldServer worldserver = this.player.getWorldServer(); BlockPosition blockposition = packetplayinupdatesign.b(); -@@ -1233,14 +2312,30 @@ +@@ -1280,14 +2355,30 @@ if (!tileentitysign.d() || tileentitysign.f() != this.player) { - this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign"); + PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getDisplayName().getString()); + this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit return; } @@ -1573,8 +1563,8 @@ + String[] lines = new String[4]; + for (int i = 0; i < astring.length; ++i) { -- tileentitysign.a(i, new ChatComponentText(EnumChatFormat.b(astring[i]))); -+ lines[i] = EnumChatFormat.b(new ChatComponentText(EnumChatFormat.b(astring[i])).getString()); +- tileentitysign.a(i, new ChatComponentText(EnumChatFormat.a(astring[i]))); ++ lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a(astring[i])).getString()); } + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); + this.server.getPluginManager().callEvent(event); @@ -1587,7 +1577,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -1250,6 +2345,7 @@ +@@ -1297,6 +2388,7 @@ @Override public void a(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1595,7 +1585,7 @@ if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) { int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive); -@@ -1264,7 +2360,17 @@ +@@ -1311,7 +2403,17 @@ @Override public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); @@ -1614,7 +1604,7 @@ } @Override -@@ -1273,8 +2379,50 @@ +@@ -1320,8 +2422,50 @@ this.player.a(packetplayinsettings); } diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch index 5c3fb8f9bc..7b0c2090fe 100644 --- a/nms-patches/PlayerInteractManager.patch +++ b/nms-patches/PlayerInteractManager.patch @@ -16,7 +16,7 @@ public class PlayerInteractManager { -@@ -31,7 +40,7 @@ +@@ -38,7 +47,7 @@ this.gamemode = enumgamemode; enumgamemode.a(this.player.abilities); this.player.updateAbilities(); @@ -25,7 +25,7 @@ this.world.everyoneSleeping(); } -@@ -56,7 +65,7 @@ +@@ -67,7 +76,7 @@ } public void a() { @@ -33,8 +33,8 @@ + this.currentTick = MinecraftServer.currentTick; // CraftBukkit; IBlockData iblockdata; - if (this.i) { -@@ -112,9 +121,31 @@ + if (this.j) { +@@ -123,9 +132,31 @@ if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { if (!this.world.a((EntityHuman) this.player, blockposition)) { @@ -65,14 +65,8 @@ + // CraftBukkit end if (this.isCreative()) { - if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) { -@@ -131,16 +162,50 @@ - return; - } - -- this.world.douseFire((EntityHuman) null, blockposition, enumdirection); -+ // this.world.douseFire((EntityHuman) null, blockposition, enumdirection); // CraftBukkit - Moved down - this.lastDigTick = this.currentTick; + this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy"); +@@ -141,11 +172,43 @@ float f = 1.0F; iblockdata = this.world.getType(blockposition); @@ -92,8 +86,6 @@ + } else if (!iblockdata.isAir()) { iblockdata.attack(this.world, blockposition, this.player); f = iblockdata.getDamage(this.player, this.player.world, blockposition); -+ // Allow fire punching to be blocked -+ this.world.douseFire((EntityHuman) null, blockposition, enumdirection); } + if (event.useItemInHand() == Event.Result.DENY) { @@ -119,16 +111,16 @@ if (!iblockdata.isAir() && f >= 1.0F) { this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine"); } else { -@@ -184,7 +249,7 @@ +@@ -189,7 +252,7 @@ } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { - this.e = false; - if (!Objects.equals(this.g, blockposition)) { -- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: " + this.g + " " + blockposition); -+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: " + this.g + " " + blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled - this.world.a(this.player.getId(), this.g, -1); - this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.g, this.world.getType(this.g), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying")); + this.f = false; + if (!Objects.equals(this.h, blockposition)) { +- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: " + this.h + " " + blockposition); ++ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: " + this.h + " " + blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled + this.world.a(this.player.getId(), this.h, -1); + this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, this.world.getType(this.h), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying")); } -@@ -200,17 +265,73 @@ +@@ -205,17 +268,73 @@ if (this.breakBlock(blockposition)) { this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s)); } else { @@ -170,10 +162,10 @@ + if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) { + event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, itemstack)); + } -+ -+ this.world.getServer().getPluginManager().callEvent(event); - if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { ++ this.world.getServer().getPluginManager().callEvent(event); ++ + if (event.isCancelled()) { + if (isSwordNoBreak) { + return false; @@ -204,7 +196,7 @@ TileEntity tileentity = this.world.getTileEntity(blockposition); Block block = iblockdata.getBlock(); -@@ -220,6 +341,10 @@ +@@ -225,6 +344,10 @@ } else if (this.player.a((World) this.world, blockposition, this.gamemode)) { return false; } else { @@ -215,7 +207,7 @@ block.a((World) this.world, blockposition, iblockdata, (EntityHuman) this.player); boolean flag = this.world.a(blockposition, false); -@@ -228,19 +353,32 @@ +@@ -233,19 +356,32 @@ } if (this.isCreative()) { @@ -251,14 +243,14 @@ } } } -@@ -282,12 +420,40 @@ +@@ -287,12 +423,40 @@ } } + // CraftBukkit start - whole method + public boolean interactResult = false; + public boolean firedInteract = false; - public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { + public EnumInteractionResult a(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); IBlockData iblockdata = world.getType(blockposition); + EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS; @@ -269,11 +261,11 @@ + cancelledBlock = !(itileinventory instanceof ITileInventory); + } + -+ if (entityhuman.getCooldownTracker().hasCooldown(itemstack.getItem())) { ++ if (entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) { + cancelledBlock = true; + } + -+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand); ++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand); + firedInteract = true; + interactResult = event.useItemInHand() == Event.Result.DENY; + @@ -281,45 +273,51 @@ + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + if (iblockdata.getBlock() instanceof BlockDoor) { + boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); ++ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); + } else if (iblockdata.getBlock() instanceof BlockCake) { -+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake ++ entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake + } -+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-2867 ++ entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867 + enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; + } else if (this.gamemode == EnumGamemode.SPECTATOR) { + ITileInventory itileinventory = iblockdata.b(world, blockposition); if (itileinventory != null) { - entityhuman.openContainer(itileinventory); -@@ -300,29 +466,29 @@ - boolean flag1 = entityhuman.dT() && flag; + entityplayer.openContainer(itileinventory); +@@ -306,7 +470,7 @@ + ItemStack itemstack1 = itemstack.cloneItemStack(); if (!flag1) { -- EnumInteractionResult enuminteractionresult = iblockdata.interact(world, entityhuman, enumhand, movingobjectpositionblock); -+ enuminteractionresult = iblockdata.interact(world, entityhuman, enumhand, movingobjectpositionblock); +- EnumInteractionResult enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock); ++ enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock); if (enuminteractionresult.a()) { - return enuminteractionresult; + CriterionTriggers.M.a(entityplayer, blockposition, itemstack1); +@@ -314,17 +478,17 @@ } } -- if (!itemstack.isEmpty() && !entityhuman.getCooldownTracker().hasCooldown(itemstack.getItem())) { +- if (!itemstack.isEmpty() && !entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) { + if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 - ItemActionContext itemactioncontext = new ItemActionContext(entityhuman, enumhand, movingobjectpositionblock); + ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock); + EnumInteractionResult enuminteractionresult1; if (this.isCreative()) { int i = itemstack.getCount(); -- EnumInteractionResult enuminteractionresult1 = itemstack.placeItem(itemactioncontext); -+ enuminteractionresult = itemstack.placeItem(itemactioncontext, enumhand); +- enuminteractionresult1 = itemstack.placeItem(itemactioncontext); ++ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand); itemstack.setCount(i); -- return enuminteractionresult1; -+ return enuminteractionresult; } else { -- return itemstack.placeItem(itemactioncontext); -+ return itemstack.placeItem(itemactioncontext, enumhand); +- enuminteractionresult1 = itemstack.placeItem(itemactioncontext); ++ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand); } + + if (enuminteractionresult1.a()) { +@@ -332,10 +496,10 @@ + } + + return enuminteractionresult1; - } else { - return EnumInteractionResult.PASS; } diff --git a/nms-patches/PlayerInventory.patch b/nms-patches/PlayerInventory.patch index 5793968207..11b455074b 100644 --- a/nms-patches/PlayerInventory.patch +++ b/nms-patches/PlayerInventory.patch @@ -67,8 +67,8 @@ + // CraftBukkit end + public PlayerInventory(EntityHuman entityhuman) { - this.items = NonNullList.a(36, ItemStack.a); - this.armor = NonNullList.a(4, ItemStack.a); + this.items = NonNullList.a(36, ItemStack.b); + this.armor = NonNullList.a(4, ItemStack.b); @@ -41,6 +96,28 @@ return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1); } @@ -98,10 +98,10 @@ public int getFirstEmptySlotIndex() { for (int i = 0; i < this.items.size(); ++i) { if (((ItemStack) this.items.get(i)).isEmpty()) { -@@ -513,8 +590,9 @@ +@@ -480,8 +557,9 @@ ItemStack itemstack = (ItemStack) this.armor.get(i); - if (itemstack.getItem() instanceof ItemArmor) { + if ((!damagesource.isFire() || !itemstack.getItem().u()) && itemstack.getItem() instanceof ItemArmor) { + int finalI = i; // CraftBukkit - decompile error itemstack.damage((int) f, this.player, (entityhuman) -> { - entityhuman.broadcastItemBreak(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, i)); @@ -109,13 +109,13 @@ }); } } -@@ -550,6 +628,11 @@ +@@ -517,6 +595,11 @@ } public ItemStack getCarried() { + // CraftBukkit start + if (this.carried.isEmpty()) { -+ this.setCarried(ItemStack.a); ++ this.setCarried(ItemStack.b); + } + // CraftBukkit end return this.carried; diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch index 44e2f2667d..05331af865 100644 --- a/nms-patches/PlayerList.patch +++ b/nms-patches/PlayerList.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerList.java +++ b/net/minecraft/server/PlayerList.java -@@ -19,6 +19,27 @@ +@@ -21,6 +21,27 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -28,7 +28,7 @@ public abstract class PlayerList { public static final File b = new File("banned-players.json"); -@@ -28,14 +49,16 @@ +@@ -30,14 +51,16 @@ private static final Logger LOGGER = LogManager.getLogger(); private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; @@ -45,17 +45,17 @@ + // private final Map o; + // private final Map p; + // CraftBukkit end - public IPlayerFileData playerFileData; + public final WorldNBTStorage playerFileData; private boolean hasWhitelist; - protected final int maxPlayers; -@@ -44,13 +67,23 @@ - private boolean u; - private int v; + private final IRegistryCustom.Dimension s; +@@ -47,13 +70,23 @@ + private boolean v; + private int w; + // CraftBukkit start + private CraftServer cserver; + - public PlayerList(MinecraftServer minecraftserver, int i) { + public PlayerList(MinecraftServer minecraftserver, IRegistryCustom.Dimension iregistrycustom_dimension, WorldNBTStorage worldnbtstorage, int i) { + this.cserver = minecraftserver.server = new CraftServer((DedicatedServer) minecraftserver, this); + minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance(); + minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server)); @@ -72,12 +72,12 @@ + // this.p = Maps.newHashMap(); + // CraftBukkit end this.server = minecraftserver; + this.s = iregistrycustom_dimension; this.maxPlayers = i; - this.getProfileBans().a(true); -@@ -66,6 +99,12 @@ +@@ -69,6 +102,12 @@ usercache.a(gameprofile); NBTTagCompound nbttagcompound = this.a(entityplayer); - WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); + ResourceKey resourcekey; + // CraftBukkit start - Better rename detection + if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) { + NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit"); @@ -85,30 +85,27 @@ + } + // CraftBukkit end - entityplayer.spawnIn(worldserver); - entityplayer.playerInteractManager.a((WorldServer) entityplayer.world); -@@ -75,7 +114,8 @@ + if (nbttagcompound != null) { + DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("Dimension"))); +@@ -99,7 +138,8 @@ s1 = networkmanager.getSocketAddress().toString(); } - PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); + // CraftBukkit - Moved message to after join + // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); - WorldData worlddata = worldserver.getWorldData(); + WorldData worlddata = worldserver1.getWorldData(); - this.a(entityplayer, (EntityPlayer) null, worldserver); -@@ -84,7 +124,9 @@ - boolean flag = gamerules.getBoolean(GameRules.DO_IMMEDIATE_RESPAWN); + this.a(entityplayer, (EntityPlayer) null, worldserver1); +@@ -109,6 +149,7 @@ boolean flag1 = gamerules.getBoolean(GameRules.REDUCED_DEBUG_INFO); -- playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), WorldData.c(worlddata.getSeed()), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager(), this.getMaxPlayers(), worlddata.getType(), this.viewDistance, flag1, !flag)); -+ // CraftBukkit - getType() -+ playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), WorldData.c(worlddata.getSeed()), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getType(), this.getMaxPlayers(), worlddata.getType(), this.viewDistance, flag1, !flag)); + playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.E(), this.s, worldserver1.getTypeKey(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); -@@ -103,19 +145,61 @@ +@@ -127,19 +168,61 @@ } else { chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s}); } @@ -116,7 +113,7 @@ + chatmessage.a(EnumChatFormat.YELLOW); + String joinMessage = CraftChatMessage.fromComponent(chatmessage); -- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW)); +- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.b); playerconnection.a(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.yaw, entityplayer.pitch); this.players.add(entityplayer); this.j.put(entityplayer.getUniqueID(), entityplayer); @@ -135,7 +132,7 @@ + + if (joinMessage != null && joinMessage.length() > 0) { + for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { -+ server.getPlayerList().sendAll(new PacketPlayOutChat(line)); ++ server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b)); + } + } + // CraftBukkit end @@ -163,47 +160,46 @@ + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn + + // CraftBukkit start - Only add if the player wasn't moved in the event -+ if (entityplayer.world == worldserver && !worldserver.getPlayers().contains(entityplayer)) { -+ worldserver.addPlayerJoin(entityplayer); ++ if (entityplayer.world == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) { ++ worldserver1.addPlayerJoin(entityplayer); + this.server.getBossBattleCustomData().a(entityplayer); } -- worldserver.addPlayerJoin(entityplayer); +- worldserver1.addPlayerJoin(entityplayer); - this.server.getBossBattleCustomData().a(entityplayer); -+ worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it ++ worldserver1 = entityplayer.getWorldServer(); // CraftBukkit - Update in case join event changed it + // CraftBukkit end - this.a(entityplayer, worldserver); + this.a(entityplayer, worldserver1); if (!this.server.getResourcePack().isEmpty()) { entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash()); -@@ -131,8 +215,11 @@ +@@ -155,8 +238,11 @@ if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); -- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver, (entity1) -> { -- return !worldserver.addEntitySerialized(entity1) ? null : entity1; +- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver1, (entity1) -> { +- return !worldserver1.addEntitySerialized(entity1) ? null : entity1; + // CraftBukkit start -+ WorldServer finalWorldServer = worldserver; ++ WorldServer finalWorldServer = worldserver1; + Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> { + return !finalWorldServer.addEntitySerialized(entity1) ? null : entity1; + // CraftBukkit end }); if (entity != null) { -@@ -168,6 +255,8 @@ +@@ -199,6 +285,8 @@ } entityplayer.syncInventory(); + // CraftBukkit - Moved from above, added world -+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.world.worldData.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); ++ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.worldDataServer.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); } public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -200,31 +289,32 @@ +@@ -231,30 +319,31 @@ } public void setPlayerFileData(WorldServer worldserver) { + if (playerFileData != null) return; // CraftBukkit - this.playerFileData = worldserver.getDataManager(); worldserver.getWorldBorder().a(new IWorldBorderListener() { @Override public void a(WorldBorder worldborder, double d0) { @@ -236,7 +232,7 @@ } @Override -@@ -252,14 +342,15 @@ +@@ -282,14 +371,15 @@ } protected void savePlayerFile(EntityPlayer entityplayer) { @@ -246,15 +242,15 @@ + ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit if (serverstatisticmanager != null) { - serverstatisticmanager.a(); + serverstatisticmanager.save(); } - AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(entityplayer.getUniqueID()); + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit if (advancementdataplayer != null) { - advancementdataplayer.c(); -@@ -267,10 +358,21 @@ + advancementdataplayer.b(); +@@ -297,10 +387,21 @@ } @@ -277,7 +273,7 @@ this.savePlayerFile(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -301,18 +403,66 @@ +@@ -332,18 +433,66 @@ if (entityplayer1 == entityplayer) { this.j.remove(uuid); @@ -287,11 +283,10 @@ + // this.o.remove(uuid); + // this.p.remove(uuid); + // CraftBukkit end - } - -- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); ++ } ++ + // CraftBukkit start -+ // this.sendAll(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); ++ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer); + for (int i = 0; i < players.size(); i++) { + EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i); @@ -301,11 +296,12 @@ + } else { + entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); + } -+ } + } + // This removes the scoreboard (and player reference) for the specific player in the manager + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + // CraftBukkit end -+ + +- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + return playerQuitEvent.getQuitMessage(); // CraftBukkit } @@ -342,7 +338,7 @@ + // depending on the outcome. + SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress(); + -+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(DimensionManager.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(DimensionManager.OVERWORLD))); ++ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(World.OVERWORLD))); + Player player = entity.getBukkitEntity(); + PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress()); + @@ -350,7 +346,7 @@ GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile); chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()}); -@@ -320,10 +470,12 @@ +@@ -351,10 +500,12 @@ chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.g.format(gameprofilebanentry.getExpires())})); } @@ -358,15 +354,15 @@ + // return chatmessage; + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); } else if (!this.isWhitelisted(gameprofile)) { -- return new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]); +- return new ChatMessage("multiplayer.disconnect.not_whitelisted"); - } else if (this.l.isBanned(socketaddress)) { -+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]); ++ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); + event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage)); + } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) { IpBanEntry ipbanentry = this.l.get(socketaddress); chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()}); -@@ -331,13 +483,25 @@ +@@ -362,13 +513,25 @@ chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.g.format(ipbanentry.getExpires())})); } @@ -374,18 +370,18 @@ + // return chatmessage; + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); } else { -- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null; -+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null; +- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; ++ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; + if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full"); + } -+ } + } + + cserver.getPluginManager().callEvent(event); + if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { + loginlistener.disconnect(event.getKickMessage()); + return null; - } ++ } + return entity; } @@ -395,35 +391,34 @@ UUID uuid = EntityHuman.a(gameprofile); List list = Lists.newArrayList(); -@@ -372,14 +536,24 @@ +@@ -404,13 +567,23 @@ } - return new EntityPlayer(this.server, this.server.getWorldServer(DimensionManager.OVERWORLD), gameprofile, (PlayerInteractManager) object); + return new EntityPlayer(this.server, worldserver, gameprofile, (PlayerInteractManager) object); + */ + return player; + // CraftBukkit end } + // CraftBukkit start - public EntityPlayer moveToWorld(EntityPlayer entityplayer, DimensionManager dimensionmanager, boolean flag) { -+ return this.moveToWorld(entityplayer, dimensionmanager, flag, null, true); + public EntityPlayer moveToWorld(EntityPlayer entityplayer, boolean flag) { ++ return this.moveToWorld(entityplayer, this.server.getWorldServer(entityplayer.getSpawnDimension()), flag, null, true); + } + -+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, DimensionManager dimensionmanager, boolean flag, Location location, boolean avoidSuffocation) { ++ public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) { + entityplayer.stopRiding(); // CraftBukkit this.players.remove(entityplayer); entityplayer.getWorldServer().removePlayer(entityplayer); - BlockPosition blockposition = entityplayer.getBed(); - boolean flag1 = entityplayer.isRespawnForced(); - + BlockPosition blockposition = entityplayer.getSpawn(); + boolean flag1 = entityplayer.isSpawnForced(); + /* CraftBukkit start - entityplayer.dimension = dimensionmanager; - Object object; + WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension()); + Optional optional; -@@ -390,6 +564,11 @@ +@@ -430,6 +603,11 @@ } - EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object); + EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile(), (PlayerInteractManager) object); + // */ + EntityPlayer entityplayer1 = entityplayer; + org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld(); @@ -432,47 +427,52 @@ entityplayer1.playerConnection = entityplayer.playerConnection; entityplayer1.copyFrom(entityplayer, flag); -@@ -403,42 +582,100 @@ +@@ -443,41 +621,103 @@ entityplayer1.addScoreboardTag(s); } -- WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); -+ // WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); // CraftBukkit - handled later +- this.a(entityplayer1, entityplayer, worldserver1); ++ // this.a(entityplayer1, entityplayer, worldserver1); // CraftBukkit - removed + boolean flag2 = false; -- this.a(entityplayer1, entityplayer, worldserver); -- if (blockposition != null) { -- Optional optional = EntityHuman.getBed(this.server.getWorldServer(entityplayer.dimension), blockposition, flag1); -+ // this.a(entityplayer1, entityplayer, worldserver); // CraftBukkit - removed - -- if (optional.isPresent()) { -- Vec3D vec3d = (Vec3D) optional.get(); +- if (optional.isPresent()) { +- Vec3D vec3d = (Vec3D) optional.get(); + // CraftBukkit start - fire PlayerRespawnEvent + if (location == null) { + boolean isBedSpawn = false; -+ CraftWorld cworld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld); -+ if (cworld != null && blockposition != null) { -+ Optional optional = EntityHuman.getBed(cworld.getHandle(), blockposition, flag1); ++ WorldServer worldserver1 = this.server.getWorldServer(entityplayer.getSpawnDimension()); ++ if (worldserver1 != null) { ++ Optional optional; ++ ++ if (blockposition != null) { ++ optional = EntityHuman.getBed(worldserver1, blockposition, flag1, flag); ++ } else { ++ optional = Optional.empty(); ++ } -- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, 0.0F, 0.0F); -- entityplayer1.setRespawnPosition(blockposition, flag1, false); -- } else { -- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F)); +- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, 0.0F, 0.0F); +- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, flag1, false); +- flag2 = !flag && worldserver1.getType(blockposition).getBlock() instanceof BlockRespawnAnchor; +- } else if (blockposition != null) { +- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); + if (optional.isPresent()) { + Vec3D vec3d = (Vec3D) optional.get(); + + isBedSpawn = true; -+ location = new Location(cworld, vec3d.x, vec3d.y, vec3d.z); -+ } else { -+ entityplayer1.setRespawnPosition(null, true, false); -+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F)); ++ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z); ++ ++ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, flag1, false); ++ flag2 = !flag && worldserver1.getType(blockposition).getBlock() instanceof BlockRespawnAnchor; ++ } else if (blockposition != null) { ++ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); + } + } + + if (location == null) { -+ cworld = (CraftWorld) this.server.server.getWorlds().get(0); -+ blockposition = entityplayer1.getSpawnPoint(cworld.getHandle()); -+ location = new Location(cworld, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F)); - } ++ worldserver1 = this.server.getWorldServer(World.OVERWORLD); ++ blockposition = entityplayer1.getSpawnPoint(worldserver1); ++ location = new Location(worldserver1.getWorld(), (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); @@ -481,51 +481,48 @@ + location = respawnEvent.getRespawnLocation(); + if (!flag) entityplayer.reset(); // SPIGOT-4785 + } else { -+ location.setWorld(server.getWorldServer(dimensionmanager).getWorld()); ++ location.setWorld(worldserver.getWorld()); } -+ WorldServer worldserver = ((CraftWorld) location.getWorld()).getHandle(); ++ WorldServer worldserver1 = ((CraftWorld) location.getWorld()).getHandle(); + entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + // CraftBukkit end -- while (!worldserver.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { -+ while (avoidSuffocation && !worldserver.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { +- while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { ++ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ()); } + // CraftBukkit start -+ // Force the client to refresh their chunk cache -+ if (fromWorld.getEnvironment() == worldserver.getWorld().getEnvironment()) { -+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager().getDimensionID() >= 0 ? DimensionManager.NETHER : DimensionManager.OVERWORLD, WorldData.c(worldserver.getWorldData().getSeed()), worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode())); -+ } ++ WorldData worlddata = worldserver1.getWorldData(); ++ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getTypeKey(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag)); ++ entityplayer1.spawnIn(worldserver1); ++ entityplayer1.dead = false; ++ entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch)); ++ entityplayer1.setSneaking(false); - WorldData worlddata = entityplayer1.world.getWorldData(); -+ WorldData worlddata = worldserver.getWorldData(); - -- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.dimension, WorldData.c(worlddata.getSeed()), worlddata.getType(), entityplayer1.playerInteractManager.getGameMode())); -+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager().getType(), WorldData.c(worldserver.getWorldData().getSeed()), worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); -+ entityplayer1.spawnIn(worldserver); -+ entityplayer1.dead = false; -+ entityplayer1.playerConnection.teleport(new Location(worldserver.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch)); -+ entityplayer1.setSneaking(false); - BlockPosition blockposition1 = worldserver.getSpawn(); - +- +- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.world.getTypeKey(), entityplayer1.world.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag)); - entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); + // entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition1)); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn())); entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); - this.a(entityplayer1, worldserver); + this.a(entityplayer1, worldserver1); this.d(entityplayer1); -- worldserver.addPlayerRespawn(entityplayer1); +- worldserver1.addPlayerRespawn(entityplayer1); - this.players.add(entityplayer1); - this.j.put(entityplayer1.getUniqueID(), entityplayer1); - entityplayer1.syncInventory(); + if (!entityplayer.playerConnection.isDisconnected()) { -+ worldserver.addPlayerRespawn(entityplayer1); ++ worldserver1.addPlayerRespawn(entityplayer1); + this.players.add(entityplayer1); + this.j.put(entityplayer1.getUniqueID(), entityplayer1); + } + // entityplayer1.syncInventory(); entityplayer1.setHealth(entityplayer1.getHealth()); + if (flag2) { + entityplayer1.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F)); + } + // Added from changeDimension + updateClient(entityplayer); // Update health, etc... + entityplayer.updateAbilities(); @@ -542,7 +539,7 @@ + PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld); + server.server.getPluginManager().callEvent(event); + } -+ + + // Save player file again if they were disconnected + if (entityplayer.playerConnection.isDisconnected()) { + this.savePlayerFile(entityplayer); @@ -551,10 +548,10 @@ return entityplayer1; } -@@ -451,7 +688,18 @@ +@@ -490,7 +730,18 @@ public void tick() { - if (++this.v > 600) { + if (++this.w > 600) { - this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players)); + // CraftBukkit start + for (int i = 0; i < this.players.size(); ++i) { @@ -568,10 +565,10 @@ + }))); + } + // CraftBukkit end - this.v = 0; + this.w = 0; } -@@ -464,6 +712,25 @@ +@@ -503,6 +754,25 @@ } @@ -594,10 +591,10 @@ + } + // CraftBukkit end + - public void a(Packet packet, DimensionManager dimensionmanager) { + public void a(Packet packet, ResourceKey resourcekey) { for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); -@@ -564,6 +831,7 @@ +@@ -603,6 +873,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -605,7 +602,7 @@ this.server.getCommandDispatcher().a(entityplayer); } -@@ -596,6 +864,12 @@ +@@ -635,6 +906,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -615,29 +612,27 @@ + } + // CraftBukkit end + - if (entityplayer != entityhuman && entityplayer.dimension == dimensionmanager) { + if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) { double d4 = d0 - entityplayer.locX(); double d5 = d1 - entityplayer.locY(); -@@ -635,7 +909,7 @@ +@@ -674,23 +951,34 @@ public void reloadWhitelist() {} public void a(EntityPlayer entityplayer, WorldServer worldserver) { -- WorldBorder worldborder = this.server.getWorldServer(DimensionManager.OVERWORLD).getWorldBorder(); +- WorldBorder worldborder = this.server.D().getWorldBorder(); + WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); -@@ -643,17 +917,28 @@ - - entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition)); + entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn())); if (worldserver.isRaining()) { -- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); -- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.d(1.0F))); -- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.b(1.0F))); +- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F)); +- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F))); +- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F))); + // CraftBukkit start - handle player weather -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.d(1.0F))); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.b(1.0F))); ++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F)); ++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F))); ++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F))); + entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false); + entityplayer.updateWeather(-worldserver.rainLevel, worldserver.rainLevel, -worldserver.thunderLevel, worldserver.thunderLevel); + // CraftBukkit end @@ -655,45 +650,43 @@ + int i = entityplayer.world.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23; + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); + float immediateRespawn = entityplayer.world.getGameRules().getBoolean(GameRules.DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(11, immediateRespawn)); ++ entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.l, immediateRespawn)); + // CraftBukkit end } public int getPlayerCount() { -@@ -710,33 +995,52 @@ +@@ -747,27 +1035,50 @@ } public void shutdown() { - for (int i = 0; i < this.players.size(); ++i) { -- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown", new Object[0])); +- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown")); + // CraftBukkit start - disconnect safely + for (EntityPlayer player : this.players) { + player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message } + // CraftBukkit end - - } ++ ++ } + // CraftBukkit start + public void sendMessage(IChatBaseComponent[] iChatBaseComponents) { + for (IChatBaseComponent component : iChatBaseComponents) { -+ sendMessage(component, true); ++ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.b); + } -+ } -+ // CraftBukkit end -+ - public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { - this.server.sendMessage(ichatbasecomponent); - ChatMessageType chatmessagetype = flag ? ChatMessageType.SYSTEM : ChatMessageType.CHAT; - -- 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), chatmessagetype)); -+ // CraftBukkit end } ++ // CraftBukkit end - public void sendMessage(IChatBaseComponent ichatbasecomponent) { - this.sendMessage(ichatbasecomponent, true); + public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) { + this.server.sendMessage(ichatbasecomponent, uuid); +- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, chatmessagetype, uuid)); ++ // CraftBukkit start - we run this through our processor first so we can get web links etc ++ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), chatmessagetype, uuid)); ++ // CraftBukkit end ++ } ++ ++ public void sendMessage(IChatBaseComponent ichatbasecomponent) { ++ this.sendMessage(ichatbasecomponent, ChatMessageType.SYSTEM, SystemUtils.b); } - public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) { @@ -706,12 +699,12 @@ + } + + public ServerStatisticManager getStatisticManager(UUID uuid, String displayName) { -+ EntityPlayer entityHuman = this.a(uuid); -+ ServerStatisticManager serverstatisticmanager = entityHuman == null ? null : (ServerStatisticManager) entityHuman.getStatisticManager(); ++ EntityPlayer entityhuman = this.getPlayer(uuid); ++ ServerStatisticManager serverstatisticmanager = entityhuman == null ? null : (ServerStatisticManager) entityhuman.getStatisticManager(); + // CraftBukkit end if (serverstatisticmanager == null) { - File file = new File(this.server.getWorldServer(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "stats"); + File file = this.server.a(SavedFile.STATS).toFile(); File file1 = new File(file, uuid + ".json"); if (!file1.exists()) { @@ -720,7 +713,7 @@ if (file2.exists() && file2.isFile()) { file2.renameTo(file1); -@@ -744,7 +1048,7 @@ +@@ -775,7 +1086,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -729,7 +722,7 @@ } return serverstatisticmanager; -@@ -752,14 +1056,14 @@ +@@ -783,14 +1094,14 @@ public AdvancementDataPlayer f(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUniqueID(); @@ -737,16 +730,16 @@ + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit if (advancementdataplayer == null) { - File file = new File(this.server.getWorldServer(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "advancements"); + File file = this.server.a(SavedFile.ADVANCEMENTS).toFile(); File file1 = new File(file, uuid + ".json"); - advancementdataplayer = new AdvancementDataPlayer(this.server, file1, entityplayer); + advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer); - this.p.put(uuid, advancementdataplayer); + // this.p.put(uuid, advancementdataplayer); // CraftBukkit } advancementdataplayer.a(entityplayer); -@@ -795,13 +1099,20 @@ +@@ -826,13 +1137,20 @@ } public void reload() { @@ -757,11 +750,11 @@ while (iterator.hasNext()) { AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) iterator.next(); - advancementdataplayer.b(); + advancementdataplayer.a(this.server.getAdvancementData()); + }*/ + + for (EntityPlayer player : players) { -+ player.getAdvancementData().b(); ++ player.getAdvancementData().a(this.server.getAdvancementData()); + player.getAdvancementData().b(player); // CraftBukkit - trigger immediate flush of advancements } + // CraftBukkit end diff --git a/nms-patches/PortalTravelAgent.patch b/nms-patches/PortalTravelAgent.patch index 6d1e7d0ba1..f01b2029e9 100644 --- a/nms-patches/PortalTravelAgent.patch +++ b/nms-patches/PortalTravelAgent.patch @@ -5,14 +5,14 @@ public boolean findAndTeleport(Entity entity, float f) { + // CraftBukkit start -+ return findAndTeleport(entity, new BlockPosition(entity), f, 128, false) != null; ++ return findAndTeleport(entity, entity.getChunkCoordinates(), f, 128, false) != null; + } + + public ShapeDetector.Shape findAndTeleport(Entity entity, BlockPosition findPosition, float f, int searchRadius, boolean searchOnly) { + // CraftBukkit end Vec3D vec3d = entity.getPortalOffset(); EnumDirection enumdirection = entity.getPortalDirection(); -- ShapeDetector.Shape shapedetector_shape = this.a(new BlockPosition(entity), entity.getMot(), enumdirection, vec3d.x, vec3d.y, entity instanceof EntityHuman); +- ShapeDetector.Shape shapedetector_shape = this.a(entity.getChunkCoordinates(), entity.getMot(), enumdirection, vec3d.x, vec3d.y, entity instanceof EntityHuman); + ShapeDetector.Shape shapedetector_shape = this.findPortal(findPosition, entity.getMot(), enumdirection, vec3d.x, vec3d.y, entity instanceof EntityHuman, searchRadius); // CraftBukkit - add location and searchRadius + if (searchOnly) return shapedetector_shape; // CraftBukkit - optional teleporting @@ -41,16 +41,16 @@ + @Nullable + public ShapeDetector.Shape findPortal(BlockPosition blockposition, Vec3D vec3d, EnumDirection enumdirection, double d0, double d1, boolean flag, int searchRadius) { + // CraftBukkit end - VillagePlace villageplace = this.world.B(); + VillagePlace villageplace = this.world.x(); villageplace.a(this.world, blockposition, 128); List list = (List) villageplace.b((villageplacetype) -> { - return villageplacetype == VillagePlaceType.u; + return villageplacetype == VillagePlaceType.v; - }, blockposition, 128, VillagePlace.Occupancy.ANY).collect(Collectors.toList()); - Optional optional = list.stream().min(Comparator.comparingDouble((villageplacerecord) -> { + }, blockposition, searchRadius, VillagePlace.Occupancy.ANY).collect(Collectors.toList()); // CraftBukkit - searchRadius + Optional optional = list.stream().min(Comparator.comparingDouble((villageplacerecord) -> { // CraftBukkit - decompile error - return villageplacerecord.f().m(blockposition); + return villageplacerecord.f().j(blockposition); }).thenComparingInt((villageplacerecord) -> { return villageplacerecord.f().getY(); @@ -56,15 +70,23 @@ @@ -63,7 +63,7 @@ public boolean createPortal(Entity entity) { + // CraftBukkit start - providable position and creation radius -+ return createPortal(entity, new BlockPosition(entity), 16); ++ return createPortal(entity, entity.getChunkCoordinates(), 16); + } + + public boolean createPortal(Entity entity, BlockPosition createPosition, int createRadius) { diff --git a/nms-patches/Raid.patch b/nms-patches/Raid.patch index 95a762db12..b5f4d8d2cd 100644 --- a/nms-patches/Raid.patch +++ b/nms-patches/Raid.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Raid.java +++ b/net/minecraft/server/Raid.java -@@ -114,6 +114,12 @@ +@@ -111,6 +111,12 @@ return this.status == Raid.Status.LOSS; } @@ -13,7 +13,7 @@ public World getWorld() { return this.world; } -@@ -189,6 +195,7 @@ +@@ -186,6 +192,7 @@ this.active = this.world.isLoaded(this.center); if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { @@ -21,7 +21,7 @@ this.stop(); return; } -@@ -208,13 +215,16 @@ +@@ -205,13 +212,16 @@ if (!this.world.b_(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.Status.LOSS; @@ -38,7 +38,7 @@ this.stop(); return; } -@@ -288,6 +298,7 @@ +@@ -285,6 +295,7 @@ } if (j > 3) { @@ -46,7 +46,7 @@ this.stop(); break; } -@@ -300,6 +311,7 @@ +@@ -297,6 +308,7 @@ this.status = Raid.Status.VICTORY; Iterator iterator = this.heroes.iterator(); @@ -54,7 +54,7 @@ while (iterator.hasNext()) { UUID uuid = (UUID) iterator.next(); Entity entity = this.world.getEntity(uuid); -@@ -313,9 +325,11 @@ +@@ -310,9 +322,11 @@ entityplayer.a(StatisticList.RAID_WIN); CriterionTriggers.H.a(entityplayer); @@ -66,7 +66,7 @@ } } -@@ -323,6 +337,7 @@ +@@ -320,6 +334,7 @@ } else if (this.a()) { ++this.x; if (this.x >= 600) { @@ -74,7 +74,7 @@ this.stop(); return; } -@@ -457,6 +472,10 @@ +@@ -454,6 +469,10 @@ Raid.Wave[] araid_wave = Raid.Wave.f; int j = araid_wave.length; @@ -85,7 +85,7 @@ for (int k = 0; k < j; ++k) { Raid.Wave raid_wave = araid_wave[k]; int l = this.a(raid_wave, i, flag1) + this.a(raid_wave, this.random, i, difficultydamagescaler, flag1); -@@ -469,9 +488,11 @@ +@@ -466,9 +485,11 @@ entityraider.setPatrolLeader(true); this.a(i, entityraider); flag = true; @@ -97,7 +97,7 @@ if (raid_wave.g == EntityTypes.RAVAGER) { EntityRaider entityraider1 = null; -@@ -490,6 +511,7 @@ +@@ -487,6 +508,7 @@ this.a(i, entityraider1, blockposition, false); entityraider1.setPositionRotation(blockposition, 0.0F, 0.0F); entityraider1.startRiding(entityraider); @@ -105,7 +105,7 @@ } } } -@@ -499,6 +521,7 @@ +@@ -496,6 +518,7 @@ ++this.groupsSpawned; this.updateProgress(); this.H(); @@ -113,16 +113,16 @@ } public void a(int i, EntityRaider entityraider, @Nullable BlockPosition blockposition, boolean flag) { -@@ -514,7 +537,7 @@ +@@ -511,7 +534,7 @@ entityraider.prepare(this.world, this.world.getDamageScaler(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); entityraider.a(i, false); - entityraider.onGround = true; + entityraider.c(true); - this.world.addEntity(entityraider); + this.world.addEntity(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit } } -@@ -760,6 +783,12 @@ +@@ -756,6 +779,12 @@ this.heroes.add(entity.getUniqueID()); } diff --git a/nms-patches/RecipeBookServer.patch b/nms-patches/RecipeBookServer.patch index 148f70a7bd..2f34c04557 100644 --- a/nms-patches/RecipeBookServer.patch +++ b/nms-patches/RecipeBookServer.patch @@ -8,7 +8,7 @@ public class RecipeBookServer extends RecipeBook { -@@ -28,7 +29,7 @@ +@@ -25,7 +26,7 @@ IRecipe irecipe = (IRecipe) iterator.next(); MinecraftKey minecraftkey = irecipe.getKey(); @@ -17,7 +17,7 @@ this.a(minecraftkey); this.d(minecraftkey); list.add(minecraftkey); -@@ -62,6 +63,7 @@ +@@ -59,6 +60,7 @@ } private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List list) { diff --git a/nms-patches/RecipeItemStack.patch b/nms-patches/RecipeItemStack.patch index 24a1ac7a1b..c1857a0f9b 100644 --- a/nms-patches/RecipeItemStack.patch +++ b/nms-patches/RecipeItemStack.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/server/RecipeItemStack.java +++ b/net/minecraft/server/RecipeItemStack.java -@@ -28,6 +28,7 @@ - private final RecipeItemStack.Provider[] c; +@@ -25,6 +25,7 @@ + private final RecipeItemStack.Provider[] b; public ItemStack[] choices; - private IntList e; + private IntList d; + public boolean exact; // CraftBukkit public RecipeItemStack(Stream stream) { - this.c = (RecipeItemStack.Provider[]) stream.filter(RecipeItemStack.b).toArray((i) -> { -@@ -59,6 +60,15 @@ - for (int j = 0; j < i; ++j) { - ItemStack itemstack1 = aitemstack[j]; + this.b = (RecipeItemStack.Provider[]) stream.toArray((i) -> { +@@ -57,6 +58,15 @@ + for (int j = 0; j < i; ++j) { + ItemStack itemstack1 = aitemstack[j]; -+ // CraftBukkit start -+ if (exact) { -+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.equals(itemstack, itemstack1)) { -+ return true; -+ } ++ // CraftBukkit start ++ if (exact) { ++ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.equals(itemstack, itemstack1)) { ++ return true; ++ } + -+ continue; -+ } -+ // CraftBukkit end - if (itemstack1.getItem() == itemstack.getItem()) { - return true; - } ++ continue; ++ } ++ // CraftBukkit end + if (itemstack1.getItem() == itemstack.getItem()) { + return true; + } diff --git a/nms-patches/RegionFileCache.patch b/nms-patches/RegionFileCache.patch index d756206f5b..e00529c99e 100644 --- a/nms-patches/RegionFileCache.patch +++ b/nms-patches/RegionFileCache.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/RegionFileCache.java +++ b/net/minecraft/server/RegionFileCache.java -@@ -18,7 +18,7 @@ - this.b = file; +@@ -20,7 +20,7 @@ + this.c = flag; } - private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair) throws IOException { @@ -9,15 +9,15 @@ long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i); -@@ -34,6 +34,7 @@ +@@ -36,6 +36,7 @@ } File file = new File(this.b, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca"); + if (existingOnly && !file.exists()) return null; // CraftBukkit - RegionFile regionfile1 = new RegionFile(file, this.b); + RegionFile regionfile1 = new RegionFile(file, this.b, this.c); this.cache.putAndMoveToFirst(i, regionfile1); -@@ -43,7 +44,12 @@ +@@ -45,7 +46,12 @@ @Nullable public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException { @@ -31,7 +31,7 @@ DataInputStream datainputstream = regionfile.a(chunkcoordintpair); Throwable throwable = null; -@@ -78,7 +84,7 @@ +@@ -80,7 +86,7 @@ } protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { diff --git a/nms-patches/RegionLimitedWorldAccess.patch b/nms-patches/RegionLimitedWorldAccess.patch index bd7a8c2210..37bf242ae9 100644 --- a/nms-patches/RegionLimitedWorldAccess.patch +++ b/nms-patches/RegionLimitedWorldAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/RegionLimitedWorldAccess.java -@@ -239,6 +239,13 @@ +@@ -233,6 +233,13 @@ @Override public boolean addEntity(Entity entity) { diff --git a/nms-patches/RemoteControlCommandListener.patch b/nms-patches/RemoteControlCommandListener.patch index 931fcb89ab..d5188f568f 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 -@@ -23,6 +23,17 @@ - return new CommandListenerWrapper(this, new Vec3D(worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Recon", new ChatComponentText("Rcon"), this.server, (Entity) null); +@@ -26,6 +26,17 @@ + return new CommandListenerWrapper(this, Vec3D.b((BaseBlockPosition) worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Rcon", RemoteControlCommandListener.b, this.server, (Entity) null); } + // CraftBukkit start - Send a String @@ -16,5 +16,5 @@ + // CraftBukkit end + @Override - public void sendMessage(IChatBaseComponent ichatbasecomponent) { + public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) { this.buffer.append(ichatbasecomponent.getString()); diff --git a/nms-patches/SecondaryWorldServer.patch b/nms-patches/SecondaryWorldServer.patch deleted file mode 100644 index 980773d9c9..0000000000 --- a/nms-patches/SecondaryWorldServer.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/server/SecondaryWorldServer.java -+++ b/net/minecraft/server/SecondaryWorldServer.java -@@ -4,11 +4,13 @@ - - public class SecondaryWorldServer extends WorldServer { - -- public SecondaryWorldServer(WorldServer worldserver, MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener) { -- super(minecraftserver, executor, worldnbtstorage, new SecondaryWorldData(worldserver.getWorldData()), dimensionmanager, gameprofilerfiller, worldloadlistener); -- worldserver.getWorldBorder().a((IWorldBorderListener) (new IWorldBorderListener.a(this.getWorldBorder()))); -+ // CraftBukkit start - Add WorldData, Environment and ChunkGenerator arguments -+ public SecondaryWorldServer(WorldServer worldserver, MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, WorldData worldData, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { -+ super(minecraftserver, executor, worldnbtstorage, worldData, dimensionmanager, gameprofilerfiller, worldloadlistener, env, gen); -+ // worldserver.getWorldBorder().a((IWorldBorderListener) (new IWorldBorderListener.a(this.getWorldBorder()))); -+ // CraftBukkit end - } - -- @Override -- protected void a() {} -+ // @Override // CraftBukkit -+ // protected void a() {} // CraftBukkit - } diff --git a/nms-patches/ServerConnection.patch b/nms-patches/ServerConnection.patch index 3a1503c725..906024952a 100644 --- a/nms-patches/ServerConnection.patch +++ b/nms-patches/ServerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ServerConnection.java +++ b/net/minecraft/server/ServerConnection.java -@@ -77,10 +77,20 @@ +@@ -76,10 +76,20 @@ channel.pipeline().addLast("packet_handler", networkmanager); networkmanager.setPacketListener(new HandshakeListener(ServerConnection.this.e, networkmanager)); } diff --git a/nms-patches/ServerGUI.patch b/nms-patches/ServerGUI.patch index ea0b0fdb44..26d6d72fef 100644 --- a/nms-patches/ServerGUI.patch +++ b/nms-patches/ServerGUI.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ServerGUI.java +++ b/net/minecraft/server/ServerGUI.java -@@ -159,6 +159,7 @@ +@@ -158,6 +158,7 @@ this.e.forEach(Runnable::run); } @@ -8,7 +8,7 @@ public void a(JTextArea jtextarea, JScrollPane jscrollpane, String s) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(() -> { -@@ -174,7 +175,7 @@ +@@ -173,7 +174,7 @@ } try { diff --git a/nms-patches/ShapedRecipes.patch b/nms-patches/ShapedRecipes.patch index d19f28678d..a70f52a907 100644 --- a/nms-patches/ShapedRecipes.patch +++ b/nms-patches/ShapedRecipes.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/server/ShapedRecipes.java @@ -12,6 +12,15 @@ import java.util.Map; - import java.util.Set; import java.util.Map.Entry; + import java.util.Set; +// CraftBukkit start +import java.util.ArrayList; +import java.util.List; diff --git a/nms-patches/SpawnerCreature.patch b/nms-patches/SpawnerCreature.patch index 73ac93311e..565978aa97 100644 --- a/nms-patches/SpawnerCreature.patch +++ b/nms-patches/SpawnerCreature.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/SpawnerCreature.java +++ b/net/minecraft/server/SpawnerCreature.java -@@ -7,6 +7,10 @@ +@@ -13,6 +13,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -11,28 +11,99 @@ public final class SpawnerCreature { private static final Logger LOGGER = LogManager.getLogger(); -@@ -88,9 +92,12 @@ - entityinsentient.setPositionRotation((double) f, (double) k, (double) f1, worldserver.random.nextFloat() * 360.0F, 0.0F); - if ((d0 <= 16384.0D || !entityinsentient.isTypeNotPersistent(d0)) && entityinsentient.a((GeneratorAccess) worldserver, EnumMobSpawn.NATURAL) && entityinsentient.a((IWorldReader) worldserver)) { - groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(new BlockPosition(entityinsentient)), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); -- ++i; -- ++i2; -- worldserver.addEntity(entityinsentient); -+ // CraftBukkit start -+ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) { -+ ++i; -+ ++i2; -+ } -+ // CraftBukkit end - if (i >= entityinsentient.getMaxSpawnGroup()) { - return; - } -@@ -216,7 +223,7 @@ +@@ -34,7 +38,8 @@ + if (entity instanceof EntityInsentient) { + EntityInsentient entityinsentient = (EntityInsentient) entity; + +- if (entityinsentient.isPersistent() || entityinsentient.isSpecialPersistence()) { ++ // CraftBukkit - Split out persistent check, don't apply it to special persistent mobs ++ if (entityinsentient.isTypeNotPersistent(0) && entityinsentient.isPersistent()) { + continue; + } + } +@@ -70,10 +75,44 @@ + EnumCreatureType[] aenumcreaturetype = SpawnerCreature.c; + int i = aenumcreaturetype.length; + ++ // CraftBukkit start - Other mob type spawn tick rate ++ WorldData worlddata = worldserver.getWorldData(); ++ boolean spawnAnimalThisTick = worldserver.ticksPerAnimalSpawns != 0L && worlddata.getTime() % worldserver.ticksPerAnimalSpawns == 0L; ++ boolean spawnMonsterThisTick = worldserver.ticksPerMonsterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerMonsterSpawns == 0L; ++ boolean spawnWaterThisTick = worldserver.ticksPerWaterSpawns != 0L && worlddata.getTime() % worldserver.ticksPerWaterSpawns == 0L; ++ boolean spawnAmbientThisTick = worldserver.ticksPerAmbientSpawns != 0L && worlddata.getTime() % worldserver.ticksPerAmbientSpawns == 0L; ++ // CraftBukkit end ++ + for (int j = 0; j < i; ++j) { + EnumCreatureType enumcreaturetype = aenumcreaturetype[j]; ++ // CraftBukkit start - Use per-world spawn limits ++ boolean spawnThisTick = true; ++ int limit = enumcreaturetype.c(); ++ switch (enumcreaturetype) { ++ case MONSTER: ++ spawnThisTick = spawnMonsterThisTick; ++ limit = worldserver.getWorld().getMonsterSpawnLimit(); ++ break; ++ case CREATURE: ++ spawnThisTick = spawnAnimalThisTick; ++ limit = worldserver.getWorld().getAnimalSpawnLimit(); ++ break; ++ case WATER_CREATURE: ++ spawnThisTick = spawnWaterThisTick; ++ limit = worldserver.getWorld().getWaterAnimalSpawnLimit(); ++ break; ++ case AMBIENT: ++ spawnThisTick = spawnAmbientThisTick; ++ limit = worldserver.getWorld().getAmbientSpawnLimit(); ++ break; ++ } + +- if ((flag || !enumcreaturetype.d()) && (flag1 || enumcreaturetype.d()) && (flag2 || !enumcreaturetype.e()) && spawnercreature_d.a(enumcreaturetype)) { ++ if (!spawnThisTick || limit == 0) { ++ continue; ++ } ++ ++ if ((flag || !enumcreaturetype.d()) && (flag1 || enumcreaturetype.d()) && (flag2 || !enumcreaturetype.e()) && spawnercreature_d.a(enumcreaturetype, limit)) { ++ // CraftBukkit end + a(enumcreaturetype, worldserver, chunk, (entitytypes, blockposition, ichunkaccess) -> { + return spawnercreature_d.a(entitytypes, blockposition, ichunkaccess); + }, (entityinsentient, ichunkaccess) -> { +@@ -148,10 +187,13 @@ + entityinsentient.setPositionRotation(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F); + if (a(worldserver, entityinsentient, d2)) { + groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); +- ++j; +- ++k1; +- worldserver.addEntity(entityinsentient); +- spawnercreature_a.run(entityinsentient, ichunkaccess); ++ // CraftBukkit start ++ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) { ++ ++j; ++ ++k1; ++ spawnercreature_a.run(entityinsentient, ichunkaccess); ++ } ++ // CraftBukkit end + if (j >= entityinsentient.getMaxSpawnGroup()) { + return; + } +@@ -333,7 +375,7 @@ if (entityinsentient.a(generatoraccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) generatoraccess)) { - groupdataentity = entityinsentient.prepare(generatoraccess, generatoraccess.getDamageScaler(new BlockPosition(entityinsentient)), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); + groupdataentity = entityinsentient.prepare(generatoraccess, generatoraccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); - generatoraccess.addEntity(entityinsentient); + generatoraccess.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit flag = true; } } +@@ -458,8 +500,10 @@ + return this.d; + } + +- private boolean a(EnumCreatureType enumcreaturetype) { +- int i = enumcreaturetype.c() * this.a / SpawnerCreature.b; ++ // CraftBukkit start ++ private boolean a(EnumCreatureType enumcreaturetype, int limit) { ++ int i = limit * this.a / SpawnerCreature.b; ++ // CraftBukkit end + + return this.b.getInt(enumcreaturetype) < i; + } diff --git a/nms-patches/StatisticManager.patch b/nms-patches/StatisticManager.patch index 1d6c4129a0..3666efb645 100644 --- a/nms-patches/StatisticManager.patch +++ b/nms-patches/StatisticManager.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/StatisticManager.java +++ b/net/minecraft/server/StatisticManager.java -@@ -13,6 +13,12 @@ - } - +@@ -15,6 +15,12 @@ public void b(EntityHuman entityhuman, Statistic statistic, int i) { + int j = (int) Math.min((long) this.getStatisticValue(statistic) + (long) i, 2147483647L); + + // CraftBukkit start - fire Statistic events -+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), i); ++ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), j); + if (cancellable != null && cancellable.isCancelled()) { + return; + } + // CraftBukkit end - this.setStatistic(entityhuman, statistic, this.getStatisticValue(statistic) + i); + this.setStatistic(entityhuman, statistic, j); } diff --git a/nms-patches/StructureGenerator.patch b/nms-patches/StructureGenerator.patch deleted file mode 100644 index 445c0a88fe..0000000000 --- a/nms-patches/StructureGenerator.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/StructureGenerator.java -+++ b/net/minecraft/server/StructureGenerator.java -@@ -149,7 +149,7 @@ - - while (longiterator.hasNext()) { - long k = longiterator.nextLong(); -- IChunkAccess ichunkaccess1 = generatoraccess.getChunkAt(ChunkCoordIntPair.getX(k), ChunkCoordIntPair.getZ(k), ChunkStatus.STRUCTURE_STARTS); -+ IChunkAccess ichunkaccess1 = generatoraccess.getChunkAt(ChunkCoordIntPair.getX(k), ChunkCoordIntPair.getZ(k), ChunkStatus.STRUCTURE_STARTS, false); // CraftBukkit - don't load chunks - StructureStart structurestart = ichunkaccess1.a(this.b()); - - if (structurestart != null) { diff --git a/nms-patches/TagRegistry.patch b/nms-patches/TagRegistry.patch index 68a959f8ce..78aedf0828 100644 --- a/nms-patches/TagRegistry.patch +++ b/nms-patches/TagRegistry.patch @@ -1,24 +1,15 @@ --- a/net/minecraft/server/TagRegistry.java +++ b/net/minecraft/server/TagRegistry.java -@@ -58,7 +58,7 @@ - CompletableFuture>> completablefuture1 = this.itemTags.a(iresourcemanager, executor); - CompletableFuture>> completablefuture2 = this.fluidTags.a(iresourcemanager, executor); - CompletableFuture>>> completablefuture3 = this.entityTags.a(iresourcemanager, executor); -- CompletableFuture completablefuture4 = completablefuture.thenCombine(completablefuture1, Pair::of).thenCombine(completablefuture2.thenCombine(completablefuture3, Pair::of), (pair, pair1) -> { -+ CompletableFuture completablefuture4 = completablefuture.thenCombine(completablefuture1, Pair::of).thenCombine(completablefuture2.thenCombine(completablefuture3, Pair::of), (pair, pair1) -> { // CraftBukkit - decompile error - return new TagRegistry.a((Map) pair.getFirst(), (Map) pair.getSecond(), (Map) pair1.getFirst(), (Map) pair1.getSecond()); - }); - -@@ -72,6 +72,12 @@ - TagsItem.a((Tags) this.itemTags); - TagsFluid.a((Tags) this.fluidTags); - TagsEntity.a((Tags) this.entityTags); +@@ -68,6 +68,12 @@ + this.itemTags.a((Map) completablefuture1.join()); + this.fluidTags.a((Map) completablefuture2.join()); + this.entityTags.a((Map) completablefuture3.join()); + // CraftBukkit start + this.blockTags.version++; + this.itemTags.version++; + this.fluidTags.version++; + this.entityTags.version++; + // CraftBukkit end - }, executor1); - } + TagsInstance.a(this.blockTags, this.itemTags, this.fluidTags, this.entityTags); + Multimap multimap = HashMultimap.create(); diff --git a/nms-patches/TagsServer.patch b/nms-patches/TagsServer.patch index 41e40d4826..36747db4f8 100644 --- a/nms-patches/TagsServer.patch +++ b/nms-patches/TagsServer.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/TagsServer.java +++ b/net/minecraft/server/TagsServer.java -@@ -8,6 +8,7 @@ +@@ -10,6 +10,7 @@ public class TagsServer extends Tags { private final IRegistry a; + public int version; // CraftBukkit public TagsServer(IRegistry iregistry, String s, String s1) { - super(iregistry::getOptional, s, false, s1); -@@ -28,7 +29,7 @@ - Iterator iterator1 = ((Tag) entry.getValue()).a().iterator(); + super(iregistry::getOptional, s, s1); +@@ -30,7 +31,7 @@ + Iterator iterator1 = ((Tag) entry.getValue()).getTagged().iterator(); while (iterator1.hasNext()) { - T t0 = iterator1.next(); diff --git a/nms-patches/TickListServer.patch b/nms-patches/TickListServer.patch index ab993d7a94..782c66465b 100644 --- a/nms-patches/TickListServer.patch +++ b/nms-patches/TickListServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TickListServer.java +++ b/net/minecraft/server/TickListServer.java -@@ -39,11 +39,17 @@ +@@ -36,11 +36,17 @@ public void b() { int i = this.nextTickList.size(); @@ -19,8 +19,8 @@ + // CraftBukkit end } - ChunkProviderServer chunkproviderserver = this.f.getChunkProvider(); -@@ -82,7 +88,7 @@ + ChunkProviderServer chunkproviderserver = this.e.getChunkProvider(); +@@ -79,7 +85,7 @@ throw new ReportedException(crashreport); } } else { diff --git a/nms-patches/TileEntity.patch b/nms-patches/TileEntity.patch index 664bdd1915..e2fc6b9a65 100644 --- a/nms-patches/TileEntity.patch +++ b/nms-patches/TileEntity.patch @@ -21,7 +21,7 @@ @Nullable @@ -38,6 +47,14 @@ - public void load(NBTTagCompound nbttagcompound) { + public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) { this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")); + // CraftBukkit start - read container + this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY); diff --git a/nms-patches/TileEntityBeacon.patch b/nms-patches/TileEntityBeacon.patch index 470958a8cb..3e775e2ec7 100644 --- a/nms-patches/TileEntityBeacon.patch +++ b/nms-patches/TileEntityBeacon.patch @@ -30,8 +30,8 @@ public TileEntityBeacon() { super(TileEntityTypes.BEACON); -@@ -194,39 +210,78 @@ - super.ab_(); +@@ -192,39 +208,78 @@ + super.an_(); } - private void applyEffects() { @@ -119,10 +119,10 @@ public void a(SoundEffect soundeffect) { this.world.playSound((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); } -@@ -256,8 +311,11 @@ +@@ -254,8 +309,11 @@ @Override - public void load(NBTTagCompound nbttagcompound) { - super.load(nbttagcompound); + public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) { + super.load(iblockdata, nbttagcompound); - this.primaryEffect = b(nbttagcompound.getInt("Primary")); - this.secondaryEffect = b(nbttagcompound.getInt("Secondary")); + // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598) diff --git a/nms-patches/TileEntityBeehive.patch b/nms-patches/TileEntityBeehive.patch index 33337814ea..7e6170b5ea 100644 --- a/nms-patches/TileEntityBeehive.patch +++ b/nms-patches/TileEntityBeehive.patch @@ -17,13 +17,20 @@ } public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -@@ -77,11 +78,17 @@ +@@ -66,7 +67,7 @@ + if (entityhuman.getPositionVector().distanceSquared(entity.getPositionVector()) <= 16.0D) { + if (!this.isSedated()) { +- entitybee.setGoalTarget(entityhuman); ++ entitybee.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit + } else { + entitybee.setCannotEnterHiveTicks(400); + } +@@ -78,10 +79,16 @@ } -- private List a(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check -+ private List a(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { // PAIL rename releaseBees + private List releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { ++ // CraftBukkit start - This allows us to bypass the night/rain/emergency check + return releaseBees(iblockdata, tileentitybeehive_releasestatus, false); + } + @@ -31,8 +38,8 @@ List list = Lists.newArrayList(); this.bees.removeIf((tileentitybeehive_hivebee) -> { -- return this.a(iblockdata, tileentitybeehive_hivebee.entityData, list, tileentitybeehive_releasestatus); -+ return this.releaseBee(iblockdata, tileentitybeehive_hivebee.entityData, list, tileentitybeehive_releasestatus, force); +- return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus); ++ return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, force); + // CraftBukkit end }); return list; @@ -58,27 +65,23 @@ entity.stopRiding(); entity.ejectPassengers(); NBTTagCompound nbttagcompound = new NBTTagCompound(); -@@ -132,10 +151,16 @@ - } +@@ -133,7 +152,13 @@ } -- private boolean a(IBlockData iblockdata, NBTTagCompound nbttagcompound, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { -+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check -+ private boolean a(IBlockData iblockdata, NBTTagCompound nbttagcompound, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { // PAIL rename releaseBee -+ return releaseBee(iblockdata, nbttagcompound, list, tileentitybeehive_releasestatus, false); + private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) { +- if ((this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { ++ // CraftBukkit start - This allows us to bypass the night/rain/emergency check ++ return releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, false); + } + -+ private boolean releaseBee(IBlockData iblockdata, NBTTagCompound nbttagcompound, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) { - BlockPosition blockposition = this.getPosition(); - -- if ((this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { ++ private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) { + if (!force && (this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) { + // CraftBukkit end return false; } else { - nbttagcompound.remove("Passengers"); -@@ -163,6 +188,7 @@ - if (!entity.getEntityType().a(TagsEntity.BEEHIVE_INHABITORS)) { + BlockPosition blockposition = this.getPosition(); +@@ -157,6 +182,7 @@ + if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) { return false; } else { + if (!this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below @@ -86,16 +89,16 @@ EntityBee entitybee = (EntityBee) entity; @@ -196,7 +222,7 @@ - BlockPosition blockposition2 = this.getPosition(); + } - this.world.playSound((EntityHuman) null, (double) blockposition2.getX(), (double) blockposition2.getY(), (double) blockposition2.getZ(), SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F); + this.world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F); - return this.world.addEntity(entity); + return true; // return this.world.addEntity(entity); // CraftBukkit - moved up } } else { return false; -@@ -223,6 +249,11 @@ - if (this.a(iblockdata, nbttagcompound, (List) null, tileentitybeehive_releasestatus)) { +@@ -235,6 +261,11 @@ + if (this.releaseBee(iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus)) { iterator.remove(); } + // CraftBukkit start @@ -103,11 +106,11 @@ + tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable + } + // CraftBukkit end - } else { - tileentitybeehive_hivebee.ticksInHive++; } -@@ -266,6 +297,11 @@ - this.flowerPos = GameProfileSerializer.c(nbttagcompound.getCompound("FlowerPos")); + } + +@@ -276,6 +307,11 @@ + this.flowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos")); } + // CraftBukkit start @@ -118,7 +121,7 @@ } @Override -@@ -275,6 +311,7 @@ +@@ -285,6 +321,7 @@ if (this.x()) { nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.flowerPos)); } diff --git a/nms-patches/TileEntityCampfire.patch b/nms-patches/TileEntityCampfire.patch index 145e8e378f..6d4544a9df 100644 --- a/nms-patches/TileEntityCampfire.patch +++ b/nms-patches/TileEntityCampfire.patch @@ -31,5 +31,5 @@ + itemstack1 = CraftItemStack.asNMSCopy(result); + // CraftBukkit end InventoryUtils.dropItem(this.world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); - this.items.set(i, ItemStack.a); + this.items.set(i, ItemStack.b); this.k(); diff --git a/nms-patches/TileEntityChest.patch b/nms-patches/TileEntityChest.patch index d2e11f98b0..987839a055 100644 --- a/nms-patches/TileEntityChest.patch +++ b/nms-patches/TileEntityChest.patch @@ -47,7 +47,7 @@ + protected TileEntityChest(TileEntityTypes tileentitytypes) { super(tileentitytypes); - this.items = NonNullList.a(27, ItemStack.a); + this.items = NonNullList.a(27, ItemStack.b); @@ -155,8 +189,20 @@ if (this.viewingCount < 0) { this.viewingCount = 0; diff --git a/nms-patches/TileEntityConduit.patch b/nms-patches/TileEntityConduit.patch index 0a0c297258..a8f6df069b 100644 --- a/nms-patches/TileEntityConduit.patch +++ b/nms-patches/TileEntityConduit.patch @@ -14,7 +14,7 @@ @@ -158,7 +162,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (this.position.a((BaseBlockPosition) (new BlockPosition(entityhuman)), (double) j) && entityhuman.isInWaterOrRain()) { + if (this.position.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (double) j) && entityhuman.isInWaterOrRain()) { - entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true)); + entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit } diff --git a/nms-patches/TileEntityDispenser.patch b/nms-patches/TileEntityDispenser.patch index 9b7964dceb..50809c3acf 100644 --- a/nms-patches/TileEntityDispenser.patch +++ b/nms-patches/TileEntityDispenser.patch @@ -48,4 +48,4 @@ + protected TileEntityDispenser(TileEntityTypes tileentitytypes) { super(tileentitytypes); - this.items = NonNullList.a(9, ItemStack.a); + this.items = NonNullList.a(9, ItemStack.b); diff --git a/nms-patches/TileEntityEndGateway.patch b/nms-patches/TileEntityEndGateway.patch index 41115416cd..cc1cb695ec 100644 --- a/nms-patches/TileEntityEndGateway.patch +++ b/nms-patches/TileEntityEndGateway.patch @@ -13,13 +13,13 @@ public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable { -@@ -120,6 +126,26 @@ - if (this.exitPortal != null) { - BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.k(); +@@ -138,6 +144,26 @@ + entity1 = entity.getRootVehicle(); + } + // CraftBukkit start - Fire PlayerTeleportEvent -+ if (entity instanceof EntityPlayer) { -+ org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity.getBukkitEntity(); ++ if (entity1 instanceof EntityPlayer) { ++ org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity(); + org.bukkit.Location location = new Location(world.getWorld(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D); + location.setPitch(player.getLocation().getPitch()); + location.setYaw(player.getLocation().getYaw()); @@ -31,30 +31,30 @@ + } + + ((EntityPlayer) entity).playerConnection.teleport(teleEvent.getTo()); -+ this.f(); // CraftBukkit - call at end of method ++ this.h(); // CraftBukkit - call at end of method + return; + + } + // CraftBukkit end + - entity.enderTeleportAndLoad((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D); + entity1.enderTeleportAndLoad((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); } -@@ -155,7 +181,7 @@ +@@ -173,7 +199,7 @@ if (this.exitPortal == null) { this.exitPortal = new BlockPosition(vec3d1.x + 0.5D, 75.0D, vec3d1.z + 0.5D); TileEntityEndGateway.LOGGER.debug("Failed to find suitable block, settling on {}", this.exitPortal); -- WorldGenerator.END_ISLAND.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.e).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal); -+ WorldGenerator.END_ISLAND.b(WorldGenFeatureConfiguration.e).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal); // CraftBukkit - decompile error +- WorldGenerator.END_ISLAND.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.k).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal); ++ WorldGenerator.END_ISLAND.b(WorldGenFeatureConfiguration.k).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal); // CraftBukkit - decompile error } else { TileEntityEndGateway.LOGGER.debug("Found block at {}", this.exitPortal); } -@@ -223,7 +249,7 @@ +@@ -241,7 +267,7 @@ } private void a(WorldServer worldserver, BlockPosition blockposition) { -- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); -+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error +- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); ++ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error } public void a(BlockPosition blockposition, boolean flag) { diff --git a/nms-patches/TileEntityFurnace.patch b/nms-patches/TileEntityFurnace.patch index 87facb8617..d275e5be8c 100644 --- a/nms-patches/TileEntityFurnace.patch +++ b/nms-patches/TileEntityFurnace.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/TileEntityFurnace.java +++ b/net/minecraft/server/TileEntityFurnace.java -@@ -7,6 +7,16 @@ +@@ -9,6 +9,16 @@ + import java.util.List; import java.util.Map; - import java.util.Map.Entry; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlock; @@ -17,7 +17,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable { -@@ -135,6 +145,36 @@ +@@ -137,6 +147,36 @@ return map; } @@ -51,10 +51,10 @@ + } + // CraftBukkit end + - private static void a(Map map, Tag tag, int i) { - Iterator iterator = tag.a().iterator(); - -@@ -211,12 +251,23 @@ + private static boolean b(Item item) { + return TagsItem.NON_FLAMMABLE_WOOD.isTagged(item); + } +@@ -223,12 +263,23 @@ this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal); } } else { @@ -81,7 +81,7 @@ flag1 = true; if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); -@@ -278,11 +329,38 @@ +@@ -290,11 +341,38 @@ ItemStack itemstack1 = irecipe.getResult(); ItemStack itemstack2 = (ItemStack) this.items.get(2); @@ -120,54 +120,67 @@ if (!this.world.isClientSide) { this.a(irecipe); -@@ -307,7 +385,7 @@ +@@ -319,7 +397,7 @@ } protected int getRecipeCookingTime() { -- return (Integer) this.world.getCraftingManager().craft(this.c, this, this.world).map(RecipeCooking::e).orElse(200); -+ return (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes) this.c, this, this.world).map(RecipeCooking::e).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail +- return (Integer) this.world.getCraftingManager().craft(this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200); ++ return (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes) this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail } public static boolean isFuel(ItemStack itemstack) { -@@ -434,7 +512,7 @@ +@@ -446,14 +524,20 @@ @Override public void b(EntityHuman entityhuman) {} - public void d(EntityHuman entityhuman) { +- List> list = this.a(entityhuman.world, entityhuman.getPositionVector()); + public void d(EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit - List> list = Lists.newArrayList(); - Iterator iterator = this.n.entrySet().iterator(); ++ List> list = this.a(entityhuman.world, entityhuman.getPositionVector(), entityhuman, itemstack, amount); // CraftBukkit -@@ -443,7 +521,7 @@ - - entityhuman.world.getCraftingManager().a((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { - list.add(irecipe); -- a(entityhuman, (Integer) entry.getValue(), ((RecipeCooking) irecipe).b()); -+ a(entityhuman, (Integer) entry.getValue(), ((RecipeCooking) irecipe).b(), itemstack, amount); // CraftBukkit - }); - } - -@@ -451,7 +529,7 @@ + entityhuman.discoverRecipes(list); this.n.clear(); } -- private static void a(EntityHuman entityhuman, int i, float f) { -+ private void a(EntityHuman entityhuman, int i, float f, ItemStack itemstack, int amount) { // CraftBukkit - int j; + public List> a(World world, Vec3D vec3d) { ++ // CraftBukkit start ++ return this.a(world, vec3d, null, null, 0); ++ } ++ ++ public List> a(World world, Vec3D vec3d, EntityHuman entityhuman, ItemStack itemstack, int amount) { ++ // CraftBukkit end + List> list = Lists.newArrayList(); + ObjectIterator objectiterator = this.n.object2IntEntrySet().iterator(); - if (f == 0.0F) { -@@ -465,6 +543,14 @@ - i = j; +@@ -462,14 +546,14 @@ + + world.getCraftingManager().a((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { + list.add(irecipe); +- a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience()); ++ a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), entityhuman, itemstack, amount); // CraftBukkit + }); + } + + return list; + } + +- private static void a(World world, Vec3D vec3d, int i, float f) { ++ private void a(World world, Vec3D vec3d, int i, float f, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit + int j = MathHelper.d((float) i * f); + float f1 = MathHelper.h((float) i * f); + +@@ -477,6 +561,14 @@ + ++j; } + // CraftBukkit start - fire FurnaceExtractEvent + if (amount != 0) { -+ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(world, position), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, i); ++ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(world, position), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, j); + world.getServer().getPluginManager().callEvent(event); -+ i = event.getExpToDrop(); ++ j = event.getExpToDrop(); + } + // CraftBukkit end + - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; + while (j > 0) { + int k = EntityExperienceOrb.getOrbValue(j); + diff --git a/nms-patches/TileEntityHopper.patch b/nms-patches/TileEntityHopper.patch index 3dc647cb11..95d74de83a 100644 --- a/nms-patches/TileEntityHopper.patch +++ b/nms-patches/TileEntityHopper.patch @@ -51,7 +51,7 @@ + public TileEntityHopper() { super(TileEntityTypes.HOPPER); - this.items = NonNullList.a(5, ItemStack.a); + this.items = NonNullList.a(5, ItemStack.b); @@ -138,7 +177,28 @@ for (int i = 0; i < this.getSize(); ++i) { if (!this.getItem(i).isEmpty()) { diff --git a/nms-patches/TileEntityLectern.patch b/nms-patches/TileEntityLectern.patch index a067727b00..81e58e9cd4 100644 --- a/nms-patches/TileEntityLectern.patch +++ b/nms-patches/TileEntityLectern.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntityLectern.java +++ b/net/minecraft/server/TileEntityLectern.java -@@ -1,10 +1,63 @@ +@@ -1,10 +1,64 @@ package net.minecraft.server; import javax.annotation.Nullable; @@ -8,6 +8,7 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; ++import java.util.UUID; +import org.bukkit.Location; +import org.bukkit.block.Lectern; +import org.bukkit.craftbukkit.block.CraftBlock; @@ -66,7 +67,7 @@ @Override public int getSize() { return 1; -@@ -49,11 +102,20 @@ +@@ -49,11 +103,20 @@ } @Override @@ -89,7 +90,7 @@ } @Override -@@ -135,7 +197,7 @@ +@@ -135,7 +198,7 @@ if (j != this.page) { this.page = j; this.update(); @@ -98,13 +99,13 @@ } } -@@ -158,6 +220,32 @@ +@@ -158,6 +221,32 @@ return itemstack; } + // CraftBukkit start + @Override -+ public void sendMessage(IChatBaseComponent ichatbasecomponent) { ++ public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) { + } + + @Override @@ -131,9 +132,9 @@ private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) { String s; Object object; -@@ -172,7 +260,8 @@ +@@ -172,7 +261,8 @@ - Vec3D vec3d = new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D); + Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.position); - return new CommandListenerWrapper(ICommandListener.DUMMY, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman); + // CraftBukkit - this @@ -141,7 +142,7 @@ } @Override -@@ -211,7 +300,7 @@ +@@ -211,7 +301,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { diff --git a/nms-patches/TileEntityShulkerBox.patch b/nms-patches/TileEntityShulkerBox.patch index ab6a6b7ba3..81300bdd47 100644 --- a/nms-patches/TileEntityShulkerBox.patch +++ b/nms-patches/TileEntityShulkerBox.patch @@ -47,4 +47,4 @@ + public TileEntityShulkerBox(@Nullable EnumColor enumcolor) { super(TileEntityTypes.SHULKER_BOX); - this.contents = NonNullList.a(27, ItemStack.a); + this.contents = NonNullList.a(27, ItemStack.b); diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch index 0572f8e8fa..98d3e253cf 100644 --- a/nms-patches/TileEntitySign.patch +++ b/nms-patches/TileEntitySign.patch @@ -1,15 +1,18 @@ --- a/net/minecraft/server/TileEntitySign.java +++ b/net/minecraft/server/TileEntitySign.java -@@ -3,7 +3,7 @@ +@@ -1,9 +1,10 @@ + package net.minecraft.server; + import com.mojang.brigadier.exceptions.CommandSyntaxException; ++import java.util.UUID; import javax.annotation.Nullable; -public class TileEntitySign extends TileEntity { +public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements - public final IChatBaseComponent[] lines = new IChatBaseComponent[]{new ChatComponentText(""), new ChatComponentText(""), new ChatComponentText(""), new ChatComponentText("")}; - public boolean isEditable = true; -@@ -26,6 +26,12 @@ + public final IChatBaseComponent[] lines; + public boolean isEditable; +@@ -29,6 +30,12 @@ nbttagcompound.setString("Text" + (i + 1), s); } @@ -19,11 +22,11 @@ + } + // CraftBukkit end + - nbttagcompound.setString("Color", this.color.b()); + nbttagcompound.setString("Color", this.color.c()); return nbttagcompound; } -@@ -36,18 +42,38 @@ - super.load(nbttagcompound); +@@ -39,18 +46,38 @@ + super.load(iblockdata, nbttagcompound); this.color = EnumColor.a(nbttagcompound.getString("Color"), EnumColor.BLACK); + // CraftBukkit start - Add an option to convert signs correctly @@ -34,17 +37,17 @@ + for (int i = 0; i < 4; ++i) { String s = nbttagcompound.getString("Text" + (i + 1)); -- IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s); +- IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s); + if (s != null && s.length() > 2048) { + s = "\"\""; + } + + try { -+ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s); ++ IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s); - if (this.world instanceof WorldServer) { - try { -- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null, 0); +- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0); - } catch (CommandSyntaxException commandsyntaxexception) { + if (oldSign) { + lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0]; @@ -54,27 +57,27 @@ + + if (this.world instanceof WorldServer) { + try { -+ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null, 0); ++ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0); + } catch (CommandSyntaxException commandsyntaxexception) { -+ this.lines[i] = ichatbasecomponent; ++ this.lines[i] = ichatmutablecomponent; + } + } else { - this.lines[i] = ichatbasecomponent; + this.lines[i] = ichatmutablecomponent; } - } else { -- this.lines[i] = ichatbasecomponent; +- this.lines[i] = ichatmutablecomponent; + } catch (com.google.gson.JsonParseException jsonparseexception) { + this.lines[i] = new ChatComponentText(s); } this.g[i] = null; -@@ -108,11 +134,37 @@ +@@ -111,11 +138,37 @@ return true; } + // CraftBukkit start + @Override -+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {} ++ public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) {} + + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { @@ -101,13 +104,13 @@ String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString(); Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName(); -- return new CommandListenerWrapper(ICommandListener.DUMMY, new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); +- return new CommandListenerWrapper(ICommandListener.DUMMY, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); + // CraftBukkit - this -+ return new CommandListenerWrapper(this, new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); ++ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); } public EnumColor getColor() { -@@ -123,7 +175,7 @@ +@@ -126,7 +179,7 @@ if (enumcolor != this.getColor()) { this.color = enumcolor; this.update(); diff --git a/nms-patches/VillageSiege.patch b/nms-patches/VillageSiege.patch index 9567f53873..62f74972d9 100644 --- a/nms-patches/VillageSiege.patch +++ b/nms-patches/VillageSiege.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/VillageSiege.java +++ b/net/minecraft/server/VillageSiege.java -@@ -104,7 +104,7 @@ +@@ -105,7 +105,7 @@ } entityzombie.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, worldserver.random.nextFloat() * 360.0F, 0.0F); diff --git a/nms-patches/World.patch b/nms-patches/World.patch index a87b511a0a..2bdbbb9beb 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/World.java +++ b/net/minecraft/server/World.java @@ -14,6 +14,17 @@ + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.apache.logging.log4j.util.Supplier; +// CraftBukkit start +import java.util.HashMap; @@ -18,11 +18,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable { protected static final Logger LOGGER = LogManager.getLogger(); -@@ -40,7 +51,43 @@ - private final WorldBorder worldBorder; - private final BiomeManager biomeManager; +@@ -46,7 +57,39 @@ + private final ResourceKey dimensionKey; + private final ResourceKey typeKey; -- protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag) { +- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i) { + // CraftBukkit start Added the following + private final CraftWorld world; + public boolean pvpMode; @@ -48,11 +48,7 @@ + return (CraftServer) Bukkit.getServer(); + } + -+ public Chunk getChunkIfLoaded(int x, int z) { -+ return ((ChunkProviderServer) this.chunkProvider).getChunkAt(x, z, false); -+ } -+ -+ protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { ++ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { + this.generator = gen; + this.world = new CraftWorld((WorldServer) this, gen, env); + this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit @@ -60,13 +56,28 @@ + this.ticksPerWaterSpawns = this.getServer().getTicksPerWaterSpawns(); // CraftBukkit + this.ticksPerAmbientSpawns = this.getServer().getTicksPerAmbientSpawns(); // CraftBukkit + // CraftBukkit end - this.methodProfiler = gameprofilerfiller; - this.worldData = worlddata; - this.worldProvider = dimensionmanager.getWorldProvider(this); -@@ -49,6 +96,35 @@ - this.worldBorder = this.worldProvider.getWorldBorder(); + this.methodProfiler = supplier; + this.worldData = worlddatamutable; + this.x = dimensionmanager; +@@ -57,12 +100,12 @@ + this.worldBorder = new WorldBorder() { + @Override + public double getCenterX() { +- return super.getCenterX() / 8.0D; ++ return super.getCenterX(); // CraftBukkit + } + + @Override + public double getCenterZ() { +- return super.getCenterZ() / 8.0D; ++ return super.getCenterZ(); // CraftBukkit + } + }; + } else { +@@ -72,6 +115,35 @@ this.serverThread = Thread.currentThread(); - this.biomeManager = new BiomeManager(this, flag ? worlddata.getSeed() : WorldData.c(worlddata.getSeed()), dimensionmanager.getGenLayerZoomer()); + this.biomeManager = new BiomeManager(this, i, dimensionmanager.getGenLayerZoomer()); + this.debugWorld = flag1; + // CraftBukkit start + getWorldBorder().world = (WorldServer) this; + // From PlayerList.setPlayerFileData @@ -99,10 +110,10 @@ } @Override -@@ -105,6 +181,17 @@ +@@ -176,6 +248,17 @@ @Override - public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { + public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { + CapturedBlockState blockstate = capturedBlockStates.get(blockposition); @@ -116,8 +127,8 @@ + // CraftBukkit end if (isOutsideWorld(blockposition)) { return false; - } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { -@@ -112,9 +199,24 @@ + } else if (!this.isClientSide && this.isDebugWorld()) { +@@ -183,9 +266,24 @@ } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); Block block = iblockdata.getBlock(); @@ -143,15 +154,15 @@ return false; } else { IBlockData iblockdata2 = this.getType(blockposition); -@@ -125,6 +227,7 @@ - this.methodProfiler.exit(); +@@ -196,6 +294,7 @@ + this.getMethodProfiler().exit(); } + /* if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.b(blockposition, iblockdata1, iblockdata2); -@@ -151,12 +254,65 @@ +@@ -222,12 +321,65 @@ this.a(blockposition, iblockdata1, iblockdata2); } @@ -217,19 +228,7 @@ public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -195,6 +351,11 @@ - @Override - public void update(BlockPosition blockposition, Block block) { - if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { -+ // CraftBukkit start -+ if (populating) { -+ return; -+ } -+ // CraftBukkit end - this.applyPhysics(blockposition, block); - } - -@@ -243,6 +404,17 @@ +@@ -309,6 +461,17 @@ IBlockData iblockdata = this.getType(blockposition); try { @@ -247,7 +246,7 @@ iblockdata.doPhysics(this, blockposition, block, blockposition1, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -285,6 +457,14 @@ +@@ -351,6 +514,14 @@ @Override public IBlockData getType(BlockPosition blockposition) { @@ -262,21 +261,7 @@ if (isOutsideWorld(blockposition)) { return Blocks.VOID_AIR.getBlockData(); } else { -@@ -306,11 +486,11 @@ - } - - public boolean isDay() { -- return this.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && this.c < 4; -+ return this.worldProvider.getDimensionManager().getType() == DimensionManager.OVERWORLD && this.c < 4; // CraftBukkit - } - - public boolean isNight() { -- return this.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && !this.isDay(); -+ return this.worldProvider.getDimensionManager().getType() == DimensionManager.OVERWORLD && !this.isDay(); // CraftBukkit - } - - @Override -@@ -432,9 +612,11 @@ +@@ -498,9 +669,11 @@ TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i); if (!tileentity1.isRemoved()) { @@ -288,7 +273,7 @@ if (this.isLoaded(tileentity1.getPosition())) { Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -442,6 +624,12 @@ +@@ -508,6 +681,12 @@ chunk.setTileEntity(tileentity1.getPosition(), tileentity1); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); @@ -301,7 +286,7 @@ } } } -@@ -606,12 +794,25 @@ +@@ -548,12 +727,25 @@ @Nullable @Override @@ -327,7 +312,7 @@ TileEntity tileentity = null; if (this.tickingTileEntities) { -@@ -646,6 +847,13 @@ +@@ -588,6 +780,13 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { if (!isOutsideWorld(blockposition)) { if (tileentity != null && !tileentity.isRemoved()) { @@ -341,7 +326,7 @@ if (this.tickingTileEntities) { tileentity.setLocation(this, blockposition); Iterator iterator = this.tileEntityListPending.iterator(); -@@ -670,7 +878,7 @@ +@@ -612,7 +811,7 @@ } public void removeTileEntity(BlockPosition blockposition) { @@ -349,4 +334,4 @@ + TileEntity tileentity = this.getTileEntity(blockposition, false); // CraftBukkit if (tileentity != null && this.tickingTileEntities) { - tileentity.ab_(); + tileentity.an_(); diff --git a/nms-patches/WorldBorder.patch b/nms-patches/WorldBorder.patch index 57d8864f30..e89a3161fa 100644 --- a/nms-patches/WorldBorder.patch +++ b/nms-patches/WorldBorder.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/WorldBorder.java +++ b/net/minecraft/server/WorldBorder.java -@@ -15,6 +15,7 @@ - private double g; - private int h = 29999984; - private WorldBorder.a i = new WorldBorder.c(6.0E7D); +@@ -17,6 +17,7 @@ + private int i = 29999984; + private WorldBorder.a j = new WorldBorder.d(6.0E7D); + public static final WorldBorder.c b = new WorldBorder.c(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 6.0E7D, 0L, 0.0D); + public WorldServer world; // CraftBukkit public WorldBorder() {} -@@ -128,6 +129,7 @@ +@@ -130,6 +131,7 @@ } public void a(IWorldBorderListener iworldborderlistener) { diff --git a/nms-patches/WorldData.patch b/nms-patches/WorldData.patch deleted file mode 100644 index fc6f6ffab1..0000000000 --- a/nms-patches/WorldData.patch +++ /dev/null @@ -1,98 +0,0 @@ ---- a/net/minecraft/server/WorldData.java -+++ b/net/minecraft/server/WorldData.java -@@ -12,6 +12,11 @@ - import java.util.UUID; - import java.util.Map.Entry; - import javax.annotation.Nullable; -+// CraftBukkit start -+import org.bukkit.Bukkit; -+import org.bukkit.event.weather.ThunderChangeEvent; -+import org.bukkit.event.weather.WeatherChangeEvent; -+// CraftBukkit end - - public class WorldData { - -@@ -70,6 +75,7 @@ - private boolean Y; - private final GameRules Z; - private final CustomFunctionCallbackTimerQueue aa; -+ public WorldServer world; // CraftBukkit - - protected WorldData() { - this.f = WorldType.NORMAL; -@@ -436,6 +442,7 @@ - nbttagcompound.setString("WanderingTraderId", this.W.toString()); - } - -+ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit - } - - public long getSeed() { -@@ -528,6 +535,20 @@ - } - - public void setThundering(boolean flag) { -+ // CraftBukkit start -+ if (this.thundering == flag) { -+ return; -+ } -+ -+ org.bukkit.World world = Bukkit.getWorld(getName()); -+ if (world != null) { -+ ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag); -+ Bukkit.getServer().getPluginManager().callEvent(thunder); -+ if (thunder.isCancelled()) { -+ return; -+ } -+ } -+ // CraftBukkit end - this.thundering = flag; - } - -@@ -544,6 +565,20 @@ - } - - public void setStorm(boolean flag) { -+ // CraftBukkit start -+ if (this.raining == flag) { -+ return; -+ } -+ -+ org.bukkit.World world = Bukkit.getWorld(getName()); -+ if (world != null) { -+ WeatherChangeEvent weather = new WeatherChangeEvent(world, flag); -+ Bukkit.getServer().getPluginManager().callEvent(weather); -+ if (weather.isCancelled()) { -+ return; -+ } -+ } -+ // CraftBukkit end - this.raining = flag; - } - -@@ -693,6 +728,12 @@ - - public void setDifficulty(EnumDifficulty enumdifficulty) { - this.F = enumdifficulty; -+ // CraftBukkit start -+ PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked()); -+ for (EntityPlayer player : (java.util.List) (java.util.List) world.getPlayers()) { -+ player.playerConnection.sendPacket(packet); -+ } -+ // CraftBukkit end - } - - public boolean isDifficultyLocked() { -@@ -808,4 +849,12 @@ - this.X.add(s); - this.Y |= flag; - } -+ -+ // CraftBukkit start - Check if the name stored in NBT is the correct one -+ public void checkName(String name) { -+ if (!this.levelName.equals(name)) { -+ this.levelName = name; -+ } -+ } -+ // CraftBukkit end - } diff --git a/nms-patches/WorldDataServer.patch b/nms-patches/WorldDataServer.patch new file mode 100644 index 0000000000..3d2db78ea2 --- /dev/null +++ b/nms-patches/WorldDataServer.patch @@ -0,0 +1,123 @@ +--- a/net/minecraft/server/WorldDataServer.java ++++ b/net/minecraft/server/WorldDataServer.java +@@ -13,11 +13,16 @@ + import javax.annotation.Nullable; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; ++// CraftBukkit start ++import org.bukkit.Bukkit; ++import org.bukkit.event.weather.ThunderChangeEvent; ++import org.bukkit.event.weather.WeatherChangeEvent; ++// CraftBukkit end + + public class WorldDataServer implements IWorldDataServer, SaveData { + + private static final Logger LOGGER = LogManager.getLogger(); +- private WorldSettings b; ++ public WorldSettings b; + private final GeneratorSettings c; + private final Lifecycle d; + private int e; +@@ -50,6 +55,7 @@ + private final Set B; + private boolean C; + private final CustomFunctionCallbackTimerQueue D; ++ public WorldServer world; // CraftBukkit + + private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, LinkedHashSet linkedhashset, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) { + this.j = datafixer; +@@ -92,7 +98,8 @@ + return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue(); + }); + +- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.b), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse((Object) null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { ++ // CraftBukkit - decompile error ++ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.b), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse(null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { + return SystemUtils.a(dynamic1.asString().result()); + }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.a, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, generatorsettings, lifecycle); + } +@@ -124,7 +131,7 @@ + nbttagcompound.set("Version", nbttagcompound2); + nbttagcompound.setInt("DataVersion", SharedConstants.getGameVersion().getWorldVersion()); + RegistryWriteOps registrywriteops = RegistryWriteOps.a(DynamicOpsNBT.a, iregistrycustom); +- DataResult dataresult = GeneratorSettings.a.encodeStart(registrywriteops, this.c); ++ DataResult dataresult = GeneratorSettings.a.encodeStart(registrywriteops, this.c); // CraftBukkit - decompile error + Logger logger = WorldDataServer.LOGGER; + + logger.getClass(); +@@ -171,6 +178,7 @@ + nbttagcompound.a("WanderingTraderId", this.A); + } + ++ nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit + } + + @Override +@@ -277,6 +285,20 @@ + + @Override + public void setThundering(boolean flag) { ++ // CraftBukkit start ++ if (this.thundering == flag) { ++ return; ++ } ++ ++ org.bukkit.World world = Bukkit.getWorld(getName()); ++ if (world != null) { ++ ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag); ++ Bukkit.getServer().getPluginManager().callEvent(thunder); ++ if (thunder.isCancelled()) { ++ return; ++ } ++ } ++ // CraftBukkit end + this.thundering = flag; + } + +@@ -297,6 +319,20 @@ + + @Override + public void setStorm(boolean flag) { ++ // CraftBukkit start ++ if (this.raining == flag) { ++ return; ++ } ++ ++ org.bukkit.World world = Bukkit.getWorld(getName()); ++ if (world != null) { ++ WeatherChangeEvent weather = new WeatherChangeEvent(world, flag); ++ Bukkit.getServer().getPluginManager().callEvent(weather); ++ if (weather.isCancelled()) { ++ return; ++ } ++ } ++ // CraftBukkit end + this.raining = flag; + } + +@@ -363,6 +399,12 @@ + @Override + public void setDifficulty(EnumDifficulty enumdifficulty) { + this.b = this.b.a(enumdifficulty); ++ // CraftBukkit start ++ PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked()); ++ for (EntityPlayer player : (java.util.List) (java.util.List) world.getPlayers()) { ++ player.playerConnection.sendPacket(packet); ++ } ++ // CraftBukkit end + } + + @Override +@@ -467,4 +509,12 @@ + public IWorldDataServer G() { + return this; + } ++ ++ // CraftBukkit start - Check if the name stored in NBT is the correct one ++ public void checkName(String name) { ++ if (!this.b.levelName.equals(name)) { ++ this.b.levelName = name; ++ } ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/WorldGenGroundBush.patch b/nms-patches/WorldGenGroundBush.patch deleted file mode 100644 index 950656c8a0..0000000000 --- a/nms-patches/WorldGenGroundBush.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/server/WorldGenGroundBush.java -+++ b/net/minecraft/server/WorldGenGroundBush.java -@@ -29,8 +29,19 @@ - } - } - } -+ // CraftBukkit start - Return false if gen was unsuccessful -+ } else { -+ return false; - } -+ // CraftBukkit end - - return true; - } -+ -+ // CraftBukkit start - decompile error -+ @Override -+ public boolean generate(GeneratorAccess generatoraccess, ChunkGenerator chunkgenerator, Random random, BlockPosition blockposition, WorldGenFeatureTreeConfiguration fc) { -+ return super.a(generatoraccess, chunkgenerator, random, blockposition, fc); -+ } -+ // CraftBukkit end - } diff --git a/nms-patches/WorldGenMegaTreeProvider.patch b/nms-patches/WorldGenMegaTreeProvider.patch index 8d1026f9de..af464d2b26 100644 --- a/nms-patches/WorldGenMegaTreeProvider.patch +++ b/nms-patches/WorldGenMegaTreeProvider.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/WorldGenMegaTreeProvider.java +++ b/net/minecraft/server/WorldGenMegaTreeProvider.java -@@ -29,6 +29,7 @@ - if (worldgenfeatureconfigured == null) { +@@ -30,6 +30,7 @@ return false; } else { + ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.e).a(); + setTreeType(worldgenfeatureconfigured); // CraftBukkit IBlockData iblockdata1 = Blocks.AIR.getBlockData(); - generatoraccess.setTypeAndData(blockposition.b(i, 0, j), iblockdata1, 4); + worldserver.setTypeAndData(blockposition.b(i, 0, j), iblockdata1, 4); diff --git a/nms-patches/WorldGenTreeProvider.patch b/nms-patches/WorldGenTreeProvider.patch index 4dd6108737..172c0f46cb 100644 --- a/nms-patches/WorldGenTreeProvider.patch +++ b/nms-patches/WorldGenTreeProvider.patch @@ -13,9 +13,9 @@ return false; } else { + setTreeType(worldgenfeatureconfigured); // CraftBukkit - generatoraccess.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4); - ((WorldGenFeatureSmallTreeConfigurationConfiguration) worldgenfeatureconfigured.c).a(); - if (worldgenfeatureconfigured.a(generatoraccess, chunkgenerator, random, blockposition)) { + worldserver.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4); + ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.e).a(); + if (worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), chunkgenerator, random, blockposition)) { @@ -43,4 +45,46 @@ return true; @@ -23,39 +23,39 @@ + + // CraftBukkit start + protected void setTreeType(WorldGenFeatureConfigured worldgentreeabstract) { -+ if (worldgentreeabstract.c == BiomeDecoratorGroups.NORMAL_TREE || worldgentreeabstract.c == BiomeDecoratorGroups.NORMAL_TREE_BEES_005) { ++ if (worldgentreeabstract.e == BiomeDecoratorGroups.NORMAL_TREE || worldgentreeabstract.e == BiomeDecoratorGroups.NORMAL_TREE_BEES_005) { + BlockSapling.treeType = TreeType.TREE; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.HUGE_RED_MUSHROOM) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.HUGE_RED_MUSHROOM) { + BlockSapling.treeType = TreeType.RED_MUSHROOM; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM) { + BlockSapling.treeType = TreeType.BROWN_MUSHROOM; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.JUNGLE_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.JUNGLE_TREE) { + BlockSapling.treeType = TreeType.COCOA_TREE; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.JUNGLE_TREE_NOVINE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.JUNGLE_TREE_NOVINE) { + BlockSapling.treeType = TreeType.SMALL_JUNGLE; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.PINE_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.PINE_TREE) { + BlockSapling.treeType = TreeType.TALL_REDWOOD; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.SPRUCE_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.SPRUCE_TREE) { + BlockSapling.treeType = TreeType.REDWOOD; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.ACACIA_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.ACACIA_TREE) { + BlockSapling.treeType = TreeType.ACACIA; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.BIRCH_TREE || worldgentreeabstract.c == BiomeDecoratorGroups.BIRCH_TREE_BEES_005) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.BIRCH_TREE || worldgentreeabstract.e == BiomeDecoratorGroups.BIRCH_TREE_BEES_005) { + BlockSapling.treeType = TreeType.BIRCH; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.TALL_BIRCH_TREE_BEES_0002) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.TALL_BIRCH_TREE_BEES_0002) { + BlockSapling.treeType = TreeType.TALL_BIRCH; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.SWAMP_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.SWAMP_TREE) { + BlockSapling.treeType = TreeType.SWAMP; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.FANCY_TREE || worldgentreeabstract.c == BiomeDecoratorGroups.FANCY_TREE_BEES_005) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.FANCY_TREE || worldgentreeabstract.e == BiomeDecoratorGroups.FANCY_TREE_BEES_005) { + BlockSapling.treeType = TreeType.BIG_TREE; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.JUNGLE_BUSH) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.JUNGLE_BUSH) { + BlockSapling.treeType = TreeType.JUNGLE_BUSH; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.DARK_OAK_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.DARK_OAK_TREE) { + BlockSapling.treeType = TreeType.DARK_OAK; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.MEGA_SPRUCE_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.MEGA_SPRUCE_TREE) { + BlockSapling.treeType = TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.MEGA_PINE_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.MEGA_PINE_TREE) { + BlockSapling.treeType = TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract.c == BiomeDecoratorGroups.MEGA_JUNGLE_TREE) { ++ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.MEGA_JUNGLE_TREE) { + BlockSapling.treeType = TreeType.JUNGLE; + } else { + throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); diff --git a/nms-patches/WorldGenWitchHut.patch b/nms-patches/WorldGenWitchHut.patch index 81d592ebce..f5c7e8ea76 100644 --- a/nms-patches/WorldGenWitchHut.patch +++ b/nms-patches/WorldGenWitchHut.patch @@ -3,9 +3,9 @@ @@ -85,7 +85,7 @@ entitywitch.setPersistent(); entitywitch.setPositionRotation((double) j + 0.5D, (double) i, (double) k + 0.5D, 0.0F, 0.0F); - entitywitch.prepare(generatoraccess, generatoraccess.getDamageScaler(new BlockPosition(j, i, k)), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); -- generatoraccess.addEntity(entitywitch); -+ generatoraccess.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + entitywitch.prepare(generatoraccessseed, generatoraccessseed.getDamageScaler(new BlockPosition(j, i, k)), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); +- generatoraccessseed.addEntity(entitywitch); ++ generatoraccessseed.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } } diff --git a/nms-patches/WorldMap.patch b/nms-patches/WorldMap.patch index fe1d5dba28..a9f7799465 100644 --- a/nms-patches/WorldMap.patch +++ b/nms-patches/WorldMap.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/WorldMap.java +++ b/net/minecraft/server/WorldMap.java -@@ -7,6 +7,15 @@ - import java.util.Map; - import javax.annotation.Nullable; +@@ -11,6 +11,15 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.UUID; @@ -15,10 +15,10 @@ + public class WorldMap extends PersistentBase { - public int centerX; -@@ -23,8 +32,18 @@ + private static final Logger LOGGER = LogManager.getLogger(); +@@ -28,8 +37,18 @@ public final Map decorations = Maps.newLinkedHashMap(); - private final Map m = Maps.newHashMap(); + private final Map n = Maps.newHashMap(); + // CraftBukkit start + public final CraftMapView mapView; @@ -34,16 +34,20 @@ + // CraftBukkit end } - public void a(int i, int j, int k, boolean flag, boolean flag1, DimensionManager dimensionmanager) { -@@ -48,7 +67,30 @@ + public void a(int i, int j, int k, boolean flag, boolean flag1, ResourceKey resourcekey) { +@@ -52,12 +71,30 @@ + @Override public void a(NBTTagCompound nbttagcompound) { - int i = nbttagcompound.getInt("dimension"); -- DimensionManager dimensionmanager = DimensionManager.a(i); +- DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("dimension"))); ++ DataResult> dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("dimension"))); // CraftBukkit - decompile error + Logger logger = WorldMap.LOGGER; + + logger.getClass(); +- this.map = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseThrow(() -> { +- return new IllegalArgumentException("Invalid map dimension: " + nbttagcompound.get("dimension")); + // CraftBukkit start -+ DimensionManager dimensionmanager = null; -+ -+ if (i >= CraftWorld.CUSTOM_DIMENSION_OFFSET) { ++ this.map = (ResourceKey) dataresult.resultOrPartial(logger::error).orElseGet(() -> { + long least = nbttagcompound.getLong("UUIDLeast"); + long most = nbttagcompound.getLong("UUIDMost"); + @@ -55,28 +59,34 @@ + if (world == null) { + /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached. + This is to prevent them being corrupted with the wrong map data. */ -+ dimensionmanager = new DimensionManager(127, null, null, null, false, null, DimensionManager.OVERWORLD); ++ // PAIL: Use Vanilla exception handling for now + } else { -+ dimensionmanager = world.getHandle().getWorldProvider().getDimensionManager(); ++ return world.getHandle().getDimensionKey(); + } + } -+ } else { -+ dimensionmanager = DimensionManager.a(i); -+ } -+ // CraftBukkit end - - if (dimensionmanager == null) { - throw new IllegalArgumentException("Invalid map dimension: " + i); -@@ -88,6 +130,25 @@ ++ throw new IllegalArgumentException("Invalid map dimension: " + nbttagcompound.get("dimension")); ++ // CraftBukkit end + }); + this.centerX = nbttagcompound.getInt("xCenter"); + this.centerZ = nbttagcompound.getInt("zCenter"); +@@ -92,13 +129,32 @@ @Override public NBTTagCompound b(NBTTagCompound nbttagcompound) { +- DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.map.a()); ++ DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.map.a()); // CraftBukkit - decompile error + Logger logger = WorldMap.LOGGER; + + logger.getClass(); + dataresult.resultOrPartial(logger::error).ifPresent((nbtbase) -> { + nbttagcompound.set("dimension", nbtbase); + }); + // CraftBukkit start -+ if (this.map.getDimensionID() >= CraftWorld.CUSTOM_DIMENSION_OFFSET) { ++ if (true) { + if (this.uniqueId == null) { + for (org.bukkit.World world : server.getWorlds()) { + CraftWorld cWorld = (CraftWorld) world; -+ if (cWorld.getHandle().getWorldProvider().getDimensionManager() == this.map) { ++ if (cWorld.getHandle().getDimensionKey() == this.map) { + this.uniqueId = cWorld.getUID(); + break; + } @@ -90,10 +100,10 @@ + } + } + // CraftBukkit end - nbttagcompound.setInt("dimension", this.map.getDimensionID()); nbttagcompound.setInt("xCenter", this.centerX); nbttagcompound.setInt("zCenter", this.centerZ); -@@ -379,12 +440,25 @@ + nbttagcompound.setByte("scale", this.scale); +@@ -389,12 +445,25 @@ @Nullable public Packet a(ItemStack itemstack) { @@ -111,11 +121,11 @@ + if (this.d) { this.d = false; -- return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); -+ return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); +- return new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); ++ return new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); } else { -- return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null; -+ return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, icons, render.buffer, 0, 0, 0, 0) : null; +- return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null; ++ return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.d(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, icons, render.buffer, 0, 0, 0, 0) : null; } + // CraftBukkit end } diff --git a/nms-patches/WorldNBTStorage.patch b/nms-patches/WorldNBTStorage.patch index dcfc3bf9e2..718c53f718 100644 --- a/nms-patches/WorldNBTStorage.patch +++ b/nms-patches/WorldNBTStorage.patch @@ -1,26 +1,17 @@ --- a/net/minecraft/server/WorldNBTStorage.java +++ b/net/minecraft/server/WorldNBTStorage.java -@@ -13,6 +13,11 @@ +@@ -10,6 +10,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start -+import java.util.UUID; +import org.bukkit.craftbukkit.entity.CraftPlayer; +// CraftBukkit end + - public class WorldNBTStorage implements IPlayerFileData { + public class WorldNBTStorage { private static final Logger LOGGER = LogManager.getLogger(); -@@ -22,6 +27,7 @@ - private final String f; - private final DefinedStructureManager g; - protected final DataFixer a; -+ private UUID uuid = null; // CraftBukkit - - public WorldNBTStorage(File file, String s, @Nullable MinecraftServer minecraftserver, DataFixer datafixer) { - this.a = datafixer; -@@ -165,6 +171,16 @@ +@@ -53,6 +57,16 @@ } if (nbttagcompound != null) { @@ -36,8 +27,8 @@ + // CraftBukkit end int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; - entityhuman.f(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i)); -@@ -173,6 +189,22 @@ + entityhuman.load(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i)); +@@ -61,6 +75,22 @@ return nbttagcompound; } @@ -60,52 +51,12 @@ public String[] getSeenPlayers() { String[] astring = this.playerDir.list(); -@@ -196,4 +228,50 @@ - public DataFixer getDataFixer() { - return this.a; +@@ -76,4 +106,10 @@ + + return astring; } + + // CraftBukkit start -+ public UUID getUUID() { -+ if (uuid != null) return uuid; -+ File file1 = new File(this.baseDir, "uid.dat"); -+ if (file1.exists()) { -+ DataInputStream dis = null; -+ try { -+ dis = new DataInputStream(new FileInputStream(file1)); -+ return uuid = new UUID(dis.readLong(), dis.readLong()); -+ } catch (IOException ex) { -+ LOGGER.warn("Failed to read " + file1 + ", generating new random UUID", ex); -+ } finally { -+ if (dis != null) { -+ try { -+ dis.close(); -+ } catch (IOException ex) { -+ // NOOP -+ } -+ } -+ } -+ } -+ uuid = UUID.randomUUID(); -+ DataOutputStream dos = null; -+ try { -+ dos = new DataOutputStream(new FileOutputStream(file1)); -+ dos.writeLong(uuid.getMostSignificantBits()); -+ dos.writeLong(uuid.getLeastSignificantBits()); -+ } catch (IOException ex) { -+ LOGGER.warn("Failed to write " + file1, ex); -+ } finally { -+ if (dos != null) { -+ try { -+ dos.close(); -+ } catch (IOException ex) { -+ // NOOP -+ } -+ } -+ } -+ return uuid; -+ } -+ + public File getPlayerDir() { + return playerDir; + } diff --git a/nms-patches/WorldProvider.patch b/nms-patches/WorldProvider.patch deleted file mode 100644 index a541a34b4b..0000000000 --- a/nms-patches/WorldProvider.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/server/WorldProvider.java -+++ b/net/minecraft/server/WorldProvider.java -@@ -72,5 +72,5 @@ - - public abstract boolean canRespawn(); - -- public abstract DimensionManager getDimensionManager(); -+ public DimensionManager getDimensionManager() { return this.f; } // CraftBukkit - } diff --git a/nms-patches/WorldProviderHell.patch b/nms-patches/WorldProviderHell.patch deleted file mode 100644 index 40664495c9..0000000000 --- a/nms-patches/WorldProviderHell.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/net/minecraft/server/WorldProviderHell.java -+++ b/net/minecraft/server/WorldProviderHell.java -@@ -18,7 +18,7 @@ - - generatorsettingsnether.a(Blocks.NETHERRACK.getBlockData()); - generatorsettingsnether.b(Blocks.LAVA.getBlockData()); -- return ChunkGeneratorType.b.create(this.b, BiomeLayout.b.a((BiomeLayoutConfiguration) ((BiomeLayoutFixedConfiguration) BiomeLayout.b.a(this.b.getWorldData())).a(Biomes.NETHER)), generatorsettingsnether); -+ return ChunkGeneratorType.b.create(this.b, BiomeLayout.b.a(((BiomeLayoutFixedConfiguration) BiomeLayout.b.a(this.b.getWorldData())).a(Biomes.NETHER)), generatorsettingsnether); // CraftBukkit - decompile error - } - - @Override -@@ -53,18 +53,22 @@ - return new WorldBorder() { - @Override - public double getCenterX() { -- return super.getCenterX() / 8.0D; -+ return super.getCenterX(); // CraftBukkit - } - - @Override - public double getCenterZ() { -- return super.getCenterZ() / 8.0D; -+ return super.getCenterZ(); // CraftBukkit - } - }; - } - -+ // CraftBukkit start -+ /* - @Override - public DimensionManager getDimensionManager() { - return DimensionManager.NETHER; - } -+ */ -+ // CraftBukkit end - } diff --git a/nms-patches/WorldProviderNormal.patch b/nms-patches/WorldProviderNormal.patch deleted file mode 100644 index d0049ee61f..0000000000 --- a/nms-patches/WorldProviderNormal.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/net/minecraft/server/WorldProviderNormal.java -+++ b/net/minecraft/server/WorldProviderNormal.java -@@ -13,10 +13,14 @@ - super(world, dimensionmanager, 0.0F); - } - -+ // CraftBukkit start -+ /* - @Override - public DimensionManager getDimensionManager() { - return DimensionManager.OVERWORLD; - } -+ */ -+ // CraftBukkit end - - @Override - public ChunkGenerator getChunkGenerator() { -@@ -34,16 +38,16 @@ - GeneratorSettingsFlat generatorsettingsflat = GeneratorSettingsFlat.a(new Dynamic(DynamicOpsNBT.a, this.b.getWorldData().getGeneratorOptions())); - BiomeLayoutFixedConfiguration biomelayoutfixedconfiguration = ((BiomeLayoutFixedConfiguration) biomelayout.a(this.b.getWorldData())).a(generatorsettingsflat.v()); - -- return chunkgeneratortype.create(this.b, biomelayout.a((BiomeLayoutConfiguration) biomelayoutfixedconfiguration), generatorsettingsflat); -+ return chunkgeneratortype.create(this.b, biomelayout.a(biomelayoutfixedconfiguration), generatorsettingsflat); // CraftBukkit - decompile error - } else if (worldtype == WorldType.DEBUG_ALL_BLOCK_STATES) { - BiomeLayoutFixedConfiguration biomelayoutfixedconfiguration1 = ((BiomeLayoutFixedConfiguration) biomelayout.a(this.b.getWorldData())).a(Biomes.PLAINS); - -- return chunkgeneratortype1.create(this.b, biomelayout.a((BiomeLayoutConfiguration) biomelayoutfixedconfiguration1), chunkgeneratortype1.a()); -+ return chunkgeneratortype1.create(this.b, biomelayout.a(biomelayoutfixedconfiguration1), chunkgeneratortype1.a()); // CraftBukkit - decompile error - } else if (worldtype != WorldType.g) { - GeneratorSettingsOverworld generatorsettingsoverworld = (GeneratorSettingsOverworld) chunkgeneratortype4.a(); - BiomeLayoutOverworldConfiguration biomelayoutoverworldconfiguration = ((BiomeLayoutOverworldConfiguration) biomelayout1.a(this.b.getWorldData())).a(generatorsettingsoverworld); - -- return chunkgeneratortype4.create(this.b, biomelayout1.a((BiomeLayoutConfiguration) biomelayoutoverworldconfiguration), generatorsettingsoverworld); -+ return chunkgeneratortype4.create(this.b, biomelayout1.a(biomelayoutoverworldconfiguration), generatorsettingsoverworld); // CraftBukkit - decompile error - } else { - WorldChunkManager worldchunkmanager = null; - JsonElement jsonelement = (JsonElement) Dynamic.convert(DynamicOpsNBT.a, JsonOps.INSTANCE, this.b.getWorldData().getGeneratorOptions()); -@@ -68,25 +72,25 @@ - if (BiomeLayout.b == biomelayout3) { - BiomeLayoutFixedConfiguration biomelayoutfixedconfiguration2 = ((BiomeLayoutFixedConfiguration) biomelayout.a(this.b.getWorldData())).a(abiomebase[0]); - -- worldchunkmanager = biomelayout.a((BiomeLayoutConfiguration) biomelayoutfixedconfiguration2); -+ worldchunkmanager = biomelayout.a(biomelayoutfixedconfiguration2); // CraftBukkit - decompile error - } - - if (BiomeLayout.a == biomelayout3) { - int j = jsonobject2.has("size") ? jsonobject2.getAsJsonPrimitive("size").getAsInt() : 2; - BiomeLayoutCheckerboardConfiguration biomelayoutcheckerboardconfiguration = ((BiomeLayoutCheckerboardConfiguration) biomelayout2.a(this.b.getWorldData())).a(abiomebase).a(j); - -- worldchunkmanager = biomelayout2.a((BiomeLayoutConfiguration) biomelayoutcheckerboardconfiguration); -+ worldchunkmanager = biomelayout2.a(biomelayoutcheckerboardconfiguration); // CraftBukkit - decompile error - } - - if (BiomeLayout.c == biomelayout3) { - BiomeLayoutOverworldConfiguration biomelayoutoverworldconfiguration1 = (BiomeLayoutOverworldConfiguration) biomelayout1.a(this.b.getWorldData()); - -- worldchunkmanager = biomelayout1.a((BiomeLayoutConfiguration) biomelayoutoverworldconfiguration1); -+ worldchunkmanager = biomelayout1.a(biomelayoutoverworldconfiguration1); // CraftBukkit - decompile error - } - } - - if (worldchunkmanager == null) { -- worldchunkmanager = biomelayout.a((BiomeLayoutConfiguration) ((BiomeLayoutFixedConfiguration) biomelayout.a(this.b.getWorldData())).a(Biomes.OCEAN)); -+ worldchunkmanager = biomelayout.a(((BiomeLayoutFixedConfiguration) biomelayout.a(this.b.getWorldData())).a(Biomes.OCEAN)); // CraftBukkit - decompile error - } - - IBlockData iblockdata = Blocks.STONE.getBlockData(); diff --git a/nms-patches/WorldProviderTheEnd.patch b/nms-patches/WorldProviderTheEnd.patch deleted file mode 100644 index 5a3102fc38..0000000000 --- a/nms-patches/WorldProviderTheEnd.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/server/WorldProviderTheEnd.java -+++ b/net/minecraft/server/WorldProviderTheEnd.java -@@ -60,10 +60,14 @@ - return this.a(new ChunkCoordIntPair(i >> 4, j >> 4), flag); - } - -+ // CraftBukkit start -+ /* - @Override - public DimensionManager getDimensionManager() { - return DimensionManager.THE_END; - } -+ */ -+ // CraftBukkit end - - @Override - public void i() { diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index 1e4f4a3298..825e5083f1 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldServer.java +++ b/net/minecraft/server/WorldServer.java -@@ -36,6 +36,17 @@ +@@ -35,6 +35,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,54 +9,74 @@ +import org.bukkit.Bukkit; +import org.bukkit.WeatherType; +import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.craftbukkit.util.WorldUUID; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.server.MapInitializeEvent; +import org.bukkit.event.weather.LightningStrikeEvent; +import org.bukkit.event.world.TimeSkipEvent; +// CraftBukkit end + - public class WorldServer extends World { + public class WorldServer extends World implements GeneratorAccessSeed { - private static final Logger LOGGER = LogManager.getLogger(); -@@ -60,12 +71,29 @@ - @Nullable - private final MobSpawnerTrader mobSpawnerTrader; + public static final BlockPosition a = new BlockPosition(100, 50, 0); +@@ -46,7 +58,7 @@ + private final ChunkProviderServer chunkProvider; + boolean tickingEntities; + private final MinecraftServer server; +- public final IWorldDataServer worldDataServer; ++ public final WorldDataServer worldDataServer; // CraftBukkit - type + public boolean savingDisabled; + private boolean everyoneSleeping; + private int emptyTime; +@@ -63,8 +75,23 @@ + private final StructureManager structureManager; + private final boolean Q; -- public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener) { +- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1) { +- super(iworlddataserver, resourcekey, resourcekey1, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i); ++ + // CraftBukkit start + private int tickPosition; ++ public final Convertable.ConversionSession convertable; ++ public final UUID uuid; + -+ // Add env and gen to constructor -+ public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { - super(worlddata, dimensionmanager, (world, worldprovider) -> { -- return new ChunkProviderServer((WorldServer) world, worldnbtstorage.getDirectory(), worldnbtstorage.getDataFixer(), worldnbtstorage.f(), executor, worldprovider.getChunkGenerator(), minecraftserver.getPlayerList().getViewDistance(), worldloadlistener, () -> { -+ // CraftBukkit start -+ ChunkGenerator chunkGenerator; ++ public Chunk getChunkIfLoaded(int x, int z) { ++ return this.chunkProvider.getChunkAt(x, z, false); ++ } + -+ if (gen != null) { -+ chunkGenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(world, gen); -+ } else { -+ chunkGenerator = worldprovider.getChunkGenerator(); -+ } -+ -+ return new ChunkProviderServer((WorldServer) world, worldnbtstorage.getDirectory(), worldnbtstorage.getDataFixer(), worldnbtstorage.f(), executor, chunkGenerator, minecraftserver.getPlayerList().getViewDistance(), worldloadlistener, () -> { - return minecraftserver.getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData(); - }); -- }, gameprofilerfiller, false); -+ // CraftBukkit end -+ }, gameprofilerfiller, false, gen, env); ++ // Add env and gen to constructor, WorldData -> WorldDataServer ++ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { ++ super(iworlddataserver, resourcekey, resourcekey1, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env); + this.pvpMode = minecraftserver.getPVP(); -+ worlddata.world = this; ++ convertable = convertable_conversionsession; ++ uuid = WorldUUID.getUUID(convertable_conversionsession.folder.toFile()); + // CraftBukkit end this.nextTickListBlock = new TickListServer<>(this, (block) -> { return block == null || block.getBlockData().isAir(); - }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b); -@@ -87,8 +115,43 @@ - this.getWorldData().setGameType(minecraftserver.getGamemode()); + }, IRegistry.BLOCK::getKey, this::b); +@@ -76,10 +103,17 @@ + this.Q = flag1; + this.server = minecraftserver; + this.mobSpawners = list; +- this.worldDataServer = iworlddataserver; ++ // CraftBukkit start ++ this.worldDataServer = (WorldDataServer) iworlddataserver; ++ worldDataServer.world = this; ++ if (gen != null) { ++ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen); ++ } ++ + this.chunkProvider = new ChunkProviderServer(this, convertable_conversionsession, minecraftserver.getDataFixer(), minecraftserver.getDefinedStructureManager(), executor, chunkgenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.isSyncChunkWrites(), worldloadlistener, () -> { + return minecraftserver.D().getWorldPersistentData(); + }); ++ // CraftBukkit end + this.portalTravelAgent = new PortalTravelAgent(this); + this.N(); + this.O(); +@@ -97,8 +131,42 @@ + } else { + this.dragonBattle = null; } - -- this.mobSpawnerTrader = this.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD ? new MobSpawnerTrader(this) : null; -+ this.mobSpawnerTrader = this.worldProvider.getDimensionManager().getType() == DimensionManager.OVERWORLD ? new MobSpawnerTrader(this) : null; // CraftBukkit - getType() + this.getServer().addWorld(this.getWorld()); // CraftBukkit + } + @@ -69,7 +89,7 @@ + return result; + } + Block type = getType(pos).getBlock(); -+ + + if (result != null && type != Blocks.AIR) { + if (!result.getTileType().isValidBlock(type)) { + result = fixTileEntity(pos, type, result); @@ -94,19 +114,19 @@ } + // CraftBukkit end - @Override - public BiomeBase a(int i, int j, int k) { -@@ -169,6 +232,7 @@ + public void a(int i, int j, boolean flag, boolean flag1) { + this.worldDataServer.a(i); +@@ -189,6 +257,7 @@ this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F); } + /* CraftBukkit start if (this.lastRainLevel != this.rainLevel) { - this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.rainLevel)), this.worldProvider.getDimensionManager()); + this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)), this.getDimensionKey()); } -@@ -187,22 +251,51 @@ - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.rainLevel)); - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.thunderLevel)); +@@ -207,18 +276,47 @@ + this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)); + this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, this.thunderLevel)); } + // */ + for (int idx = 0; idx < this.players.size(); ++idx) { @@ -130,10 +150,6 @@ + } + // CraftBukkit end - if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) { - this.getWorldData().setDifficulty(EnumDifficulty.HARD); - } - if (this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> { - return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping(); + return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit @@ -161,8 +177,8 @@ if (this.getGameRules().getBoolean(GameRules.DO_WEATHER_CYCLE)) { this.clearWeather(); } -@@ -228,7 +321,7 @@ - this.ad(); +@@ -240,7 +338,7 @@ + this.ah(); this.ticking = false; gameprofilerfiller.exitEnter("entities"); - boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); @@ -170,35 +186,23 @@ if (flag3) { this.resetEmptyTime(); -@@ -242,6 +335,11 @@ - - for (i = 0; i < this.globalEntityList.size(); ++i) { - entity = (Entity) this.globalEntityList.get(i); -+ // CraftBukkit start - Fixed an NPE -+ if (entity == null) { -+ continue; -+ } -+ // CraftBukkit end - this.a((entity1) -> { - ++entity1.ticksLived; - entity1.tick(); -@@ -260,6 +358,7 @@ - Entity entity1 = (Entity) entry.getValue(); - Entity entity2 = entity1.getVehicle(); +@@ -259,6 +357,7 @@ + Entity entity = (Entity) entry.getValue(); + Entity entity1 = entity.getVehicle(); + /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed - if (!this.server.getSpawnAnimals() && (entity1 instanceof EntityAnimal || entity1 instanceof EntityWaterAnimal)) { - entity1.die(); + if (!this.server.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { + entity.die(); } -@@ -267,6 +366,7 @@ - if (!this.server.getSpawnNPCs() && entity1 instanceof NPC) { - entity1.die(); +@@ -266,6 +365,7 @@ + if (!this.server.getSpawnNPCs() && entity instanceof NPC) { + entity.die(); } + // CraftBukkit end */ gameprofilerfiller.enter("checkDespawn"); - if (!entity1.dead) { -@@ -312,7 +412,7 @@ + if (!entity.dead) { +@@ -340,7 +440,7 @@ } private void wakeupPlayers() { @@ -207,20 +211,24 @@ entityplayer.wakeup(false, false); }); } -@@ -339,10 +439,10 @@ - entityhorseskeleton.r(true); +@@ -367,14 +467,14 @@ + entityhorseskeleton.t(true); entityhorseskeleton.setAgeRaw(0); entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); - this.addEntity(entityhorseskeleton); + this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit } -- this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag1)); -+ this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag1), org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit + EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.a((World) this); + + entitylightning.c(Vec3D.c((BaseBlockPosition) blockposition)); + entitylightning.setEffect(flag1); +- this.addEntity(entitylightning); ++ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit } } -@@ -353,11 +453,11 @@ +@@ -385,11 +485,11 @@ BiomeBase biomebase = this.getBiome(blockposition); if (biomebase.a((IWorldReader) this, blockposition1)) { @@ -234,7 +242,7 @@ } if (flag && this.getBiome(blockposition1).d() == BiomeBase.Precipitation.RAIN) { -@@ -404,7 +504,7 @@ +@@ -436,7 +536,7 @@ protected BlockPosition a(BlockPosition blockposition) { BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition); AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getBuildHeight(), blockposition1.getZ()))).g(3.0D); @@ -243,7 +251,7 @@ return entityliving != null && entityliving.isAlive() && this.f(entityliving.getChunkCoordinates()); }); -@@ -433,7 +533,7 @@ +@@ -465,7 +565,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -252,32 +260,32 @@ ++i; } else if (entityplayer.isSleeping()) { ++j; -@@ -451,10 +551,22 @@ +@@ -483,10 +583,22 @@ } private void clearWeather() { -- this.worldData.setWeatherDuration(0); +- this.worldDataServer.setWeatherDuration(0); + // CraftBukkit start - this.worldData.setStorm(false); -- this.worldData.setThunderDuration(0); + this.worldDataServer.setStorm(false); +- this.worldDataServer.setThunderDuration(0); + // If we stop due to everyone sleeping we should reset the weather duration to some other random value. + // Not that everyone ever manages to get the whole server to sleep at the same time.... -+ if (!this.worldData.hasStorm()) { -+ this.worldData.setWeatherDuration(0); ++ if (!this.worldDataServer.hasStorm()) { ++ this.worldDataServer.setWeatherDuration(0); + } + // CraftBukkit end - this.worldData.setThundering(false); + this.worldDataServer.setThundering(false); + // CraftBukkit start + // If we stop due to everyone sleeping we should reset the weather duration to some other random value. + // Not that everyone ever manages to get the whole server to sleep at the same time.... -+ if (!this.worldData.isThundering()) { -+ this.worldData.setThunderDuration(0); ++ if (!this.worldDataServer.isThundering()) { ++ this.worldDataServer.setThunderDuration(0); + } + // CraftBukkit end } public void resetEmptyTime() { -@@ -493,6 +605,7 @@ +@@ -527,6 +639,7 @@ }); gameprofilerfiller.c("tickNonPassenger"); entity.tick(); @@ -285,73 +293,30 @@ gameprofilerfiller.exit(); } -@@ -583,6 +696,22 @@ - BlockPosition blockposition = worldchunkmanager.a(0, this.getSeaLevel(), 0, 256, list, random); - ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); - -+ // CraftBukkit start -+ if (this.generator != null) { -+ Random rand = new Random(this.getSeed()); -+ org.bukkit.Location spawn = this.generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand); -+ -+ if (spawn != null) { -+ if (spawn.getWorld() != ((WorldServer) this).getWorld()) { -+ throw new IllegalStateException("Cannot set spawn point for " + this.worldData.getName() + " to be in another world (" + spawn.getWorld().getName() + ")"); -+ } else { -+ this.worldData.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ())); -+ return; -+ } -+ } -+ } -+ // CraftBukkit end -+ - if (blockposition == null) { - WorldServer.LOGGER.warn("Unable to find spawn biome"); - } -@@ -635,7 +764,7 @@ - } - - protected void g() { -- WorldGenFeatureConfigured worldgenfeatureconfigured = WorldGenerator.BONUS_CHEST.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.e); -+ WorldGenFeatureConfigured worldgenfeatureconfigured = WorldGenerator.BONUS_CHEST.b(WorldGenFeatureConfiguration.e); // CraftBukkit - decompile error - - worldgenfeatureconfigured.a(this, this.getChunkProvider().getChunkGenerator(), this.random, new BlockPosition(this.worldData.b(), this.worldData.c(), this.worldData.d())); - } -@@ -649,6 +778,7 @@ +@@ -615,6 +728,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkProvider(); if (!flag1) { + org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit if (iprogressupdate != null) { - iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0])); + iprogressupdate.a(new ChatMessage("menu.savingLevel")); } -@@ -660,6 +790,15 @@ +@@ -626,6 +740,14 @@ chunkproviderserver.save(flag); } + + // CraftBukkit start - moved from MinecraftServer.saveChunks + WorldServer worldserver1 = this; -+ WorldData worlddata = worldserver1.getWorldData(); + -+ worldserver1.getWorldBorder().save(worlddata); -+ worlddata.setCustomBossEvents(this.server.getBossBattleCustomData().save()); -+ worldserver1.getDataManager().saveWorldData(worlddata, this.server.getPlayerList().save()); ++ worldDataServer.a(worldserver1.getWorldBorder().t()); ++ worldDataServer.setCustomBossEvents(this.server.getBossBattleCustomData().save()); ++ convertable.a(this.server.f, this.worldDataServer, this.server.getPlayerList().save()); + // CraftBukkit end } - protected void m_() throws ExceptionWorldConflict { -@@ -731,7 +870,8 @@ - if (entity instanceof EntityInsentient) { - EntityInsentient entityinsentient = (EntityInsentient) entity; - -- if (entityinsentient.isPersistent() || entityinsentient.I()) { -+ // CraftBukkit - Split out persistent check, don't apply it to special persistent mobs -+ if (entityinsentient.isTypeNotPersistent(0) && entityinsentient.isPersistent()) { - continue; - } - } -@@ -748,11 +888,24 @@ + private void ag() { +@@ -691,11 +813,24 @@ @Override public boolean addEntity(Entity entity) { @@ -378,7 +343,7 @@ } public void addEntityTeleport(Entity entity) { -@@ -802,13 +955,18 @@ +@@ -745,13 +880,18 @@ this.registerEntity(entityplayer); } @@ -399,7 +364,7 @@ IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer); if (!(ichunkaccess instanceof Chunk)) { -@@ -836,7 +994,7 @@ +@@ -779,7 +919,7 @@ if (entity1 == null) { return false; } else { @@ -408,7 +373,7 @@ return true; } } -@@ -887,10 +1045,17 @@ +@@ -830,10 +970,17 @@ } this.getScoreboard().a(entity); @@ -426,7 +391,7 @@ } private void registerEntity(Entity entity) { -@@ -911,9 +1076,16 @@ +@@ -854,9 +1001,16 @@ this.entitiesByUUID.put(entity.getUniqueID(), entity); this.getChunkProvider().addEntity(entity); @@ -443,26 +408,28 @@ } } -@@ -944,6 +1116,18 @@ +@@ -886,10 +1040,33 @@ + this.everyoneSleeping(); } - public void strikeLightning(EntityLightning entitylightning) { -+ // CraftBukkit start -+ this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN); ++ // CraftBukkit start ++ public boolean strikeLightning(Entity entitylightning) { ++ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN); + } + -+ public void strikeLightning(EntityLightning entitylightning, LightningStrikeEvent.Cause cause) { ++ public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) { + LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); + this.getServer().getPluginManager().callEvent(lightning); + + if (lightning.isCancelled()) { -+ return; ++ return false; + } -+ // CraftBukkit end - this.globalEntityList.add(entitylightning); - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX(), entitylightning.locY(), entitylightning.locZ(), 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning)); - } -@@ -952,6 +1136,12 @@ ++ ++ return this.addEntity(entitylightning); ++ } ++ // CraftBukkit end ++ + @Override public void a(int i, BlockPosition blockposition, int j) { Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); @@ -475,7 +442,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -960,6 +1150,12 @@ +@@ -898,6 +1075,12 @@ double d1 = (double) blockposition.getY() - entityplayer.locY(); double d2 = (double) blockposition.getZ() - entityplayer.locZ(); @@ -488,22 +455,19 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -1020,6 +1216,14 @@ +@@ -958,10 +1141,20 @@ @Override - public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { + public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { + // CraftBukkit start -+ Explosion explosion = super.createExplosion(entity, damagesource, d0, d1, d2, f, flag, explosion_effect); ++ Explosion explosion = super.createExplosion(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect); + + if (explosion.wasCanceled) { + return explosion; + } + + /* Remove - Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, explosion_effect); - - if (damagesource != null) { -@@ -1028,6 +1232,8 @@ + Explosion explosion = new Explosion(this, entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect); explosion.a(); explosion.a(false); @@ -512,7 +476,7 @@ if (explosion_effect == Explosion.Effect.NONE) { explosion.clearBlocks(); } -@@ -1092,13 +1298,20 @@ +@@ -1026,13 +1219,20 @@ } public int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -535,10 +499,10 @@ ++j; } } -@@ -1180,7 +1393,13 @@ +@@ -1105,7 +1305,13 @@ @Override public WorldMap a(String s) { - return (WorldMap) this.getMinecraftServer().getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData().b(() -> { + return (WorldMap) this.getMinecraftServer().D().getWorldPersistentData().b(() -> { - return new WorldMap(s); + // CraftBukkit start + // We only get here when the data file exists, but is not a valid map @@ -550,3 +514,65 @@ }, s); } +@@ -1412,6 +1618,11 @@ + @Override + public void update(BlockPosition blockposition, Block block) { + if (!this.isDebugWorld()) { ++ // CraftBukkit start ++ if (populating) { ++ return; ++ } ++ // CraftBukkit end + this.applyPhysics(blockposition, block); + } + +@@ -1426,12 +1637,12 @@ + } + + public boolean isFlatWorld() { +- return this.server.getSaveData().getGeneratorSettings().isFlatWorld(); ++ return this.worldDataServer.getGeneratorSettings().isFlatWorld(); // CraftBukkit + } + + @Override + public long getSeed() { +- return this.server.getSaveData().getGeneratorSettings().getSeed(); ++ return this.worldDataServer.getGeneratorSettings().getSeed(); // CraftBukkit + } + + @Nullable +@@ -1440,16 +1651,32 @@ + } + + public static void a(WorldServer worldserver) { ++ // CraftBukkit start ++ WorldServer.a(worldserver, null); ++ } ++ ++ public static void a(WorldServer worldserver, Entity entity) { ++ // CraftBukkit end + BlockPosition blockposition = WorldServer.a; + int i = blockposition.getX(); + int j = blockposition.getY() - 2; + int k = blockposition.getZ(); + ++ // CraftBukkit start ++ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver); + BlockPosition.b(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> { +- worldserver.setTypeUpdate(blockposition1, Blocks.AIR.getBlockData()); ++ blockList.setTypeAndData(blockposition1, Blocks.AIR.getBlockData(), 3); + }); + BlockPosition.b(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> { +- worldserver.setTypeUpdate(blockposition1, Blocks.OBSIDIAN.getBlockData()); ++ blockList.setTypeAndData(blockposition1, Blocks.OBSIDIAN.getBlockData(), 3); + }); ++ org.bukkit.World bworld = worldserver.getWorld(); ++ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); ++ ++ worldserver.getServer().getPluginManager().callEvent(portalEvent); ++ if (!portalEvent.isCancelled()) { ++ blockList.updateList(); ++ } ++ // CraftBukkit end + } + } diff --git a/nms-patches/WorldUpgrader.patch b/nms-patches/WorldUpgrader.patch index 16ab0d5fd6..400ed1e8fc 100644 --- a/nms-patches/WorldUpgrader.patch +++ b/nms-patches/WorldUpgrader.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/WorldUpgrader.java +++ b/net/minecraft/server/WorldUpgrader.java -@@ -124,7 +124,7 @@ +@@ -122,7 +122,7 @@ int j = IChunkLoader.a(nbttagcompound); - NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(dimensionmanager2, () -> { + NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> { return this.q; - }, nbttagcompound); + }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit diff --git a/pom.xml b/pom.xml index cfae8f8c52..52826eb573 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.15.2-R0.1-SNAPSHOT + 1.16.1-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -12,8 +12,8 @@ true UTF-8 unknown - 1.15.2 - 1_15_R1 + 1.16.1 + 1_16_R1 1.8 1.8 @@ -40,7 +40,7 @@ org.ow2.asm asm - 7.3.1 + 8.0.1 compile @@ -53,13 +53,13 @@ org.xerial sqlite-jdbc - 3.30.1 + 3.32.3 runtime mysql mysql-connector-java - 5.1.48 + 5.1.49 runtime diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 12e7916250..ffdaff29af 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -1,9 +1,11 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; +import com.google.common.base.Predicates; import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.Collection; +import java.util.function.Predicate; import net.minecraft.server.BiomeStorage; import net.minecraft.server.BlockPosition; import net.minecraft.server.Blocks; @@ -218,7 +220,7 @@ public class CraftChunk implements Chunk { public boolean contains(BlockData block) { Preconditions.checkArgument(block != null, "Block cannot be null"); - IBlockData nms = ((CraftBlockData) block).getState(); + Predicate nms = Predicates.equalTo(((CraftBlockData) block).getState()); for (ChunkSection section : getHandle().getSections()) { if (section != null && section.getBlocks().contains(nms)) { return true; @@ -253,7 +255,7 @@ public class CraftChunk implements Chunk { NBTTagCompound data = new NBTTagCompound(); cs[i].getBlocks().a(data, "Palette", "BlockStates"); - DataPaletteBlock blockids = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, net.minecraft.server.Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // TODO: snapshot whole ChunkSection + DataPaletteBlock blockids = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, net.minecraft.server.Block.REGISTRY_ID, GameProfileSerializer::c, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // TODO: snapshot whole ChunkSection blockids.a(data.getList("Palette", CraftMagicNumbers.NBT.TAG_COMPOUND), data.getLongArray("BlockStates")); sectionBlockIDs[i] = blockids; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index b909af3d6f..4ec53a54e3 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -1,6 +1,8 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; +import com.google.common.base.Predicates; +import java.util.function.Predicate; import net.minecraft.server.BiomeStorage; import net.minecraft.server.BlockPosition; import net.minecraft.server.DataPaletteBlock; @@ -61,7 +63,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot { public boolean contains(BlockData block) { Preconditions.checkArgument(block != null, "Block cannot be null"); - IBlockData nms = ((CraftBlockData) block).getState(); + Predicate nms = Predicates.equalTo(((CraftBlockData) block).getState()); for (DataPaletteBlock palette : blockids) { if (palette.contains(nms)) { return true; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 260d54b304..584ca998e0 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -82,7 +82,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); builder.set(LootContextParameters.THIS_ENTITY, nmsLootedEntity); builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC); - builder.set(LootContextParameters.POSITION, new BlockPosition(nmsLootedEntity)); + builder.set(LootContextParameters.POSITION, nmsLootedEntity.getChunkCoordinates()); } if (context.getKiller() != null) { @@ -100,23 +100,23 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { } // SPIGOT-5603 - Avoid IllegalArgumentException in LootTableInfo#build() - LootContextParameterSet.a nmsBuilder = new LootContextParameterSet.a(); // PAIL rename Builder - for (LootContextParameter param : getHandle().getLootContextParameterSet().a()) { // PAIL rename required - nmsBuilder.a(param); // PAIL rename addRequired + LootContextParameterSet.Builder nmsBuilder = new LootContextParameterSet.Builder(); + for (LootContextParameter param : getHandle().getLootContextParameterSet().getRequired()) { + nmsBuilder.addRequired(param); } - for (LootContextParameter param : getHandle().getLootContextParameterSet().b()) { // PAIL rename optional - if (!getHandle().getLootContextParameterSet().a().contains(param)) { // PAIL rename required - nmsBuilder.b(param); // PAIL rename addOptional + for (LootContextParameter param : getHandle().getLootContextParameterSet().getOptional()) { + if (!getHandle().getLootContextParameterSet().getRequired().contains(param)) { + nmsBuilder.addOptional(param); } } - nmsBuilder.b(LootContextParameters.LOOTING_MOD); // PAIL rename addOptional + nmsBuilder.addOptional(LootContextParameters.LOOTING_MOD); - return builder.build(nmsBuilder.a()); // PAIL rename build + return builder.build(nmsBuilder.build()); } public static LootContext convertContext(LootTableInfo info) { BlockPosition position = info.getContextParameter(LootContextParameters.POSITION); - Location location = new Location(info.c().getWorld(), position.getX(), position.getY(), position.getZ()); // PAIL rename getWorld + Location location = new Location(info.getWorld().getWorld(), position.getX(), position.getY(), position.getZ()); LootContext.Builder contextBuilder = new LootContext.Builder(location); if (info.hasContextParameter(LootContextParameters.KILLER_ENTITY)) { @@ -134,7 +134,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { contextBuilder.lootingModifier(info.getContextParameter(LootContextParameters.LOOTING_MOD)); } - contextBuilder.luck(info.b()); // PAIL rename getLuck + contextBuilder.luck(info.getLuck()); return contextBuilder.build(); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 58e10381c8..00333548b4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -6,7 +6,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import net.minecraft.server.DimensionManager; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.ServerStatisticManager; import net.minecraft.server.WhiteListEntry; @@ -34,7 +33,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa protected CraftOfflinePlayer(CraftServer server, GameProfile profile) { this.server = server; this.profile = profile; - this.storage = (WorldNBTStorage) (server.console.getWorldServer(DimensionManager.OVERWORLD).getDataManager()); + this.storage = server.console.worldNBTStorage; } @@ -287,7 +286,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.incrementStatistic(manager, statistic); - manager.a(); + manager.save(); } } @@ -298,7 +297,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.decrementStatistic(manager, statistic); - manager.a(); + manager.save(); } } @@ -318,7 +317,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.incrementStatistic(manager, statistic, amount); - manager.a(); + manager.save(); } } @@ -329,7 +328,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.decrementStatistic(manager, statistic, amount); - manager.a(); + manager.save(); } } @@ -340,7 +339,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.setStatistic(manager, statistic, newValue); - manager.a(); + manager.save(); } } @@ -351,7 +350,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.incrementStatistic(manager, statistic, material); - manager.a(); + manager.save(); } } @@ -362,7 +361,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.decrementStatistic(manager, statistic, material); - manager.a(); + manager.save(); } } @@ -382,7 +381,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.incrementStatistic(manager, statistic, material, amount); - manager.a(); + manager.save(); } } @@ -393,7 +392,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.decrementStatistic(manager, statistic, material, amount); - manager.a(); + manager.save(); } } @@ -404,7 +403,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.setStatistic(manager, statistic, material, newValue); - manager.a(); + manager.save(); } } @@ -415,7 +414,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.incrementStatistic(manager, statistic, entityType); - manager.a(); + manager.save(); } } @@ -426,7 +425,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.decrementStatistic(manager, statistic, entityType); - manager.a(); + manager.save(); } } @@ -446,7 +445,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.incrementStatistic(manager, statistic, entityType, amount); - manager.a(); + manager.save(); } } @@ -457,7 +456,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.decrementStatistic(manager, statistic, entityType, amount); - manager.a(); + manager.save(); } } @@ -468,7 +467,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } else { ServerStatisticManager manager = getStatisticManager(); CraftStatistic.setStatistic(manager, statistic, entityType, newValue); - manager.a(); + manager.save(); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index 65c1492c38..54800bbed5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -88,6 +88,16 @@ public enum CraftParticle { FALLING_HONEY("falling_honey"), LANDING_HONEY("landing_honey"), FALLING_NECTAR("falling_nectar"), + SOUL_FIRE_FLAME("soul_fire_flame"), + ASH("ash"), + CRIMSON_SPORE("crimson_spore"), + WARPED_SPORE("warped_spore"), + SOUL("soul"), + DRIPPING_OBSIDIAN_TEAR("dripping_obsidian_tear"), + FALLING_OBSIDIAN_TEAR("falling_obsidian_tear"), + LANDING_OBSIDIAN_TEAR("landing_obsidian_tear"), + REVERSE_PORTAL("reverse_portal"), + WHITE_ASH("white_ash"), // ----- Legacy Separator ----- LEGACY_BLOCK_CRACK("block"), LEGACY_BLOCK_DUST("block"), diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 1d7c64d2b5..677f7e648d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -7,13 +7,13 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; import com.mojang.authlib.GameProfile; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.LiteralCommandNode; +import com.mojang.serialization.DynamicOps; +import com.mojang.serialization.Lifecycle; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; @@ -36,6 +36,9 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.Random; import java.util.Set; import java.util.UUID; import java.util.function.Consumer; @@ -45,21 +48,30 @@ import javax.imageio.ImageIO; import jline.console.ConsoleReader; import net.minecraft.server.Advancement; import net.minecraft.server.ArgumentEntity; +import net.minecraft.server.BiomeManager; import net.minecraft.server.Block; import net.minecraft.server.BlockPosition; import net.minecraft.server.BossBattleCustom; import net.minecraft.server.CommandDispatcher; import net.minecraft.server.CommandListenerWrapper; +import net.minecraft.server.CommandReload; +import net.minecraft.server.Convertable; +import net.minecraft.server.DataConverterRegistry; import net.minecraft.server.DedicatedPlayerList; import net.minecraft.server.DedicatedServer; import net.minecraft.server.DedicatedServerProperties; import net.minecraft.server.DedicatedServerSettings; import net.minecraft.server.DimensionManager; +import net.minecraft.server.DynamicOpsNBT; import net.minecraft.server.Enchantments; import net.minecraft.server.EntityPlayer; import net.minecraft.server.EnumDifficulty; import net.minecraft.server.EnumGamemode; +import net.minecraft.server.GameRules; +import net.minecraft.server.GeneratorSettings; import net.minecraft.server.IRecipe; +import net.minecraft.server.IRegistry; +import net.minecraft.server.IRegistryCustom; import net.minecraft.server.Item; import net.minecraft.server.ItemWorldMap; import net.minecraft.server.Items; @@ -67,18 +79,30 @@ import net.minecraft.server.JsonListEntry; import net.minecraft.server.LootTableRegistry; import net.minecraft.server.MapIcon; import net.minecraft.server.MinecraftKey; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.MobEffects; +import net.minecraft.server.MobSpawner; +import net.minecraft.server.MobSpawnerCat; +import net.minecraft.server.MobSpawnerPatrol; +import net.minecraft.server.MobSpawnerPhantom; +import net.minecraft.server.MobSpawnerTrader; +import net.minecraft.server.NBTBase; import net.minecraft.server.PlayerList; +import net.minecraft.server.RegistryMaterials; +import net.minecraft.server.RegistryReadOps; +import net.minecraft.server.ResourceKey; +import net.minecraft.server.SaveData; import net.minecraft.server.ServerCommand; import net.minecraft.server.TagsServer; import net.minecraft.server.TicketType; import net.minecraft.server.Vec3D; -import net.minecraft.server.WorldData; +import net.minecraft.server.VillageSiege; +import net.minecraft.server.WorldDataServer; +import net.minecraft.server.WorldDimension; import net.minecraft.server.WorldMap; import net.minecraft.server.WorldNBTStorage; import net.minecraft.server.WorldServer; import net.minecraft.server.WorldSettings; -import net.minecraft.server.WorldType; import org.apache.commons.lang.Validate; import org.bukkit.BanList; import org.bukkit.Bukkit; @@ -404,7 +428,7 @@ public final class CraftServer implements Server { private void syncCommands() { // Clear existing commands - CommandDispatcher dispatcher = console.commandDispatcher = new CommandDispatcher(); + CommandDispatcher dispatcher = console.dataPackResources.commandDispatcher = new CommandDispatcher(); // Register all commands, vanilla ones will be using the old dispatcher references for (Map.Entry entry : commandMap.getKnownCommands().entrySet()) { @@ -510,7 +534,7 @@ public final class CraftServer implements Server { @Override public Player getPlayer(UUID id) { - EntityPlayer player = playerList.a(id); + EntityPlayer player = playerList.getPlayer(id); if (player != null) { return player.getBukkitEntity(); @@ -577,12 +601,12 @@ public final class CraftServer implements Server { @Override public String getWorldType() { - return this.getProperties().levelType.name(); + return this.getProperties().properties.getProperty("level-type"); } @Override public boolean getGenerateStructures() { - return this.getServer().getGenerateStructures(); + return this.getProperties().generatorSettings.shouldGenerateMapFeatures(); } @Override @@ -721,7 +745,6 @@ public final class CraftServer implements Server { console.propertyManager = new DedicatedServerSettings(console.options); DedicatedServerProperties config = console.propertyManager.getProperties(); - console.setSpawnAnimals(config.spawnAnimals); console.setPVP(config.pvp); console.setAllowFlight(config.allowFlight); console.setMotd(config.motd); @@ -748,7 +771,7 @@ public final class CraftServer implements Server { } for (WorldServer world : console.getWorlds()) { - world.worldData.setDifficulty(config.difficulty); + world.worldDataServer.setDifficulty(config.difficulty); world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); if (this.getTicksPerAnimalSpawns() < 0) { world.ticksPerAnimalSpawns = 400; @@ -814,7 +837,7 @@ public final class CraftServer implements Server { @Override public void reloadData() { - console.reload(); + CommandReload.reload(console); } private void loadIcon() { @@ -906,8 +929,6 @@ public final class CraftServer implements Server { ChunkGenerator generator = creator.generator(); File folder = new File(getWorldContainer(), name); World world = getWorld(name); - WorldType type = WorldType.getType(creator.type().getName()); - boolean generateStructures = creator.generateStructures(); if (world != null) { return world; @@ -921,50 +942,88 @@ public final class CraftServer implements Server { generator = getGenerator(name); } - console.convertWorld(name); + ResourceKey actualDimension; + switch (creator.environment()) { + case NORMAL: + actualDimension = WorldDimension.OVERWORLD; + break; + case NETHER: + actualDimension = WorldDimension.THE_NETHER; + break; + case THE_END: + actualDimension = WorldDimension.THE_END; + break; + default: + throw new IllegalArgumentException("Illegal dimension"); + } + + Convertable.ConversionSession worldSession; + try { + worldSession = Convertable.a(getWorldContainer().toPath()).c(name, actualDimension); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + MinecraftServer.convertWorld(worldSession); // Run conversion now - int dimension = CraftWorld.CUSTOM_DIMENSION_OFFSET + console.worldServer.size(); - boolean used = false; - do { - for (WorldServer server : console.getWorlds()) { - used = server.getWorldProvider().getDimensionManager().getDimensionID() == dimension; - if (used) { - dimension++; - break; - } - } - } while (used); boolean hardcore = creator.hardcore(); - WorldNBTStorage sdm = new WorldNBTStorage(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager); - WorldData worlddata = sdm.getWorldData(); + IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); + + RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), (IRegistryCustom) iregistrycustom_dimension); + WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration); + WorldSettings worldSettings; // See MinecraftServer.a(String, String, long, WorldType, JsonElement) if (worlddata == null) { - worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type); - JsonElement parsedSettings = new JsonParser().parse(creator.generatorSettings()); - if (parsedSettings.isJsonObject()) { - worldSettings.setGeneratorSettings(parsedSettings.getAsJsonObject()); - } - worlddata = new WorldData(worldSettings, name); - } else { - worlddata.setName(name); - worldSettings = new WorldSettings(worlddata); + Properties properties = new Properties(); + properties.put("generator-settings", Objects.toString(creator.generatorSettings())); + properties.put("level-seed", Objects.toString(creator.seed())); + properties.put("generate-structures", Objects.toString(creator.generateStructures())); + properties.put("level-type", Objects.toString(creator.type().getName())); + + GeneratorSettings generatorsettings = GeneratorSettings.a(properties); + worldSettings = new WorldSettings(name, EnumGamemode.getById(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration); + worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable()); + } + worlddata.a(console.getServerModName(), console.getModded().isPresent()); + + if (console.options.has("forceUpgrade")) { + net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> { + return true; + }, worlddata.getGeneratorSettings().g()); } - DimensionManager actualDimension = DimensionManager.a(creator.environment().getId()); - DimensionManager internalDimension = DimensionManager.register(name.toLowerCase(java.util.Locale.ENGLISH), new DimensionManager(dimension, actualDimension.getSuffix(), actualDimension.folder, (w, manager) -> actualDimension.providerFactory.apply(w, manager), actualDimension.hasSkyLight(), actualDimension.getGenLayerZoomer(), actualDimension)); - WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, sdm, worlddata, internalDimension, console.getMethodProfiler(), getServer().worldLoadListenerFactory.create(11), creator.environment(), generator); + long j = BiomeManager.a(creator.seed()); + List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata)); + RegistryMaterials registrymaterials = worlddata.getGeneratorSettings().e(); + WorldDimension worlddimension = (WorldDimension) registrymaterials.a(actualDimension); + DimensionManager dimensionmanager; + net.minecraft.server.ChunkGenerator chunkgenerator; + + if (worlddimension == null) { + dimensionmanager = DimensionManager.a(); + chunkgenerator = GeneratorSettings.a((new Random()).nextLong()); + } else { + dimensionmanager = worlddimension.b(); + chunkgenerator = worlddimension.c(); + } + + ResourceKey typeKey = (ResourceKey) console.f.a().c(dimensionmanager).orElseThrow(() -> { + return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); + }); + ResourceKey worldKey = ResourceKey.a(IRegistry.ae, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); + + WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, worldSession, worlddata, worldKey, typeKey, dimensionmanager, getServer().worldLoadListenerFactory.create(11), + chunkgenerator, worlddata.getGeneratorSettings().isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), creator.environment() == Environment.NORMAL, creator.environment(), generator); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { return null; } - console.initWorld(internal, worlddata, worldSettings); + console.initWorld(internal, worlddata, worlddata, worlddata.getGeneratorSettings()); - internal.worldData.setDifficulty(EnumDifficulty.EASY); internal.setSpawnFlags(true, true); - console.worldServer.put(internal.getWorldProvider().getDimensionManager(), internal); + console.worldServer.put(internal.getDimensionKey(), internal); pluginManager.callEvent(new WorldInitEvent(internal.getWorld())); @@ -987,11 +1046,11 @@ public final class CraftServer implements Server { WorldServer handle = ((CraftWorld) world).getHandle(); - if (!(console.worldServer.containsKey(handle.getWorldProvider().getDimensionManager()))) { + if (!(console.worldServer.containsKey(handle.getDimensionKey()))) { return false; } - if (handle.getWorldProvider().getDimensionManager() == DimensionManager.OVERWORLD) { + if (handle.getDimensionKey() == net.minecraft.server.World.OVERWORLD) { return false; } @@ -1017,7 +1076,7 @@ public final class CraftServer implements Server { } worlds.remove(world.getName().toLowerCase(java.util.Locale.ENGLISH)); - console.worldServer.remove(handle.getWorldProvider().getDimensionManager()); + console.worldServer.remove(handle.getDimensionKey()); return true; } @@ -1138,7 +1197,7 @@ public final class CraftServer implements Server { @Override public void resetRecipes() { - console.reload(); // Not ideal but hard to reload a subset of a resource pack + reloadData(); // Not ideal but hard to reload a subset of a resource pack } @Override @@ -1256,7 +1315,7 @@ public final class CraftServer implements Server { @Override @Deprecated public CraftMapView getMap(int id) { - WorldMap worldmap = console.getWorldServer(DimensionManager.OVERWORLD).a("map_" + id); + WorldMap worldmap = console.getWorldServer(net.minecraft.server.World.OVERWORLD).a("map_" + id); if (worldmap == null) { return null; } @@ -1453,7 +1512,7 @@ public final class CraftServer implements Server { @Override public GameMode getDefaultGameMode() { - return GameMode.getByValue(console.getWorldServer(DimensionManager.OVERWORLD).getWorldData().getGameType().getId()); + return GameMode.getByValue(console.getWorldServer(net.minecraft.server.World.OVERWORLD).worldDataServer.getGameType().getId()); } @Override @@ -1461,7 +1520,7 @@ public final class CraftServer implements Server { Validate.notNull(mode, "Mode cannot be null"); for (World world : getWorlds()) { - ((CraftWorld) world).getHandle().worldData.setGameType(EnumGamemode.getById(mode.getValue())); + ((CraftWorld) world).getHandle().worldDataServer.setGameType(EnumGamemode.getById(mode.getValue())); } } @@ -1484,20 +1543,12 @@ public final class CraftServer implements Server { @Override public File getWorldContainer() { - if (this.getServer().universe != null) { - return this.getServer().universe; - } - - if (container == null) { - container = new File(configuration.getString("settings.world-container", ".")); - } - - return container; + return this.getServer().convertable.a(net.minecraft.server.World.OVERWORLD).getParentFile(); } @Override public OfflinePlayer[] getOfflinePlayers() { - WorldNBTStorage storage = (WorldNBTStorage) console.getWorldServer(DimensionManager.OVERWORLD).getDataManager(); + WorldNBTStorage storage = console.worldNBTStorage; String[] files = storage.getPlayerDir().list(new DatFileFilter()); Set players = new HashSet(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index 90fdf89c81..7b565ddfff 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -9,13 +9,33 @@ import org.bukkit.Sound; public enum CraftSound { + AMBIENT_BASALT_DELTAS_ADDITIONS("ambient.basalt_deltas.additions"), + AMBIENT_BASALT_DELTAS_LOOP("ambient.basalt_deltas.loop"), + AMBIENT_BASALT_DELTAS_MOOD("ambient.basalt_deltas.mood"), AMBIENT_CAVE("ambient.cave"), + AMBIENT_CRIMSON_FOREST_ADDITIONS("ambient.crimson_forest.additions"), + AMBIENT_CRIMSON_FOREST_LOOP("ambient.crimson_forest.loop"), + AMBIENT_CRIMSON_FOREST_MOOD("ambient.crimson_forest.mood"), + AMBIENT_NETHER_WASTES_ADDITIONS("ambient.nether_wastes.additions"), + AMBIENT_NETHER_WASTES_LOOP("ambient.nether_wastes.loop"), + AMBIENT_NETHER_WASTES_MOOD("ambient.nether_wastes.mood"), + AMBIENT_SOUL_SAND_VALLEY_ADDITIONS("ambient.soul_sand_valley.additions"), + AMBIENT_SOUL_SAND_VALLEY_LOOP("ambient.soul_sand_valley.loop"), + AMBIENT_SOUL_SAND_VALLEY_MOOD("ambient.soul_sand_valley.mood"), AMBIENT_UNDERWATER_ENTER("ambient.underwater.enter"), AMBIENT_UNDERWATER_EXIT("ambient.underwater.exit"), AMBIENT_UNDERWATER_LOOP("ambient.underwater.loop"), AMBIENT_UNDERWATER_LOOP_ADDITIONS("ambient.underwater.loop.additions"), AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE("ambient.underwater.loop.additions.rare"), AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE("ambient.underwater.loop.additions.ultra_rare"), + AMBIENT_WARPED_FOREST_ADDITIONS("ambient.warped_forest.additions"), + AMBIENT_WARPED_FOREST_LOOP("ambient.warped_forest.loop"), + AMBIENT_WARPED_FOREST_MOOD("ambient.warped_forest.mood"), + BLOCK_ANCIENT_DEBRIS_BREAK("block.ancient_debris.break"), + BLOCK_ANCIENT_DEBRIS_FALL("block.ancient_debris.fall"), + BLOCK_ANCIENT_DEBRIS_HIT("block.ancient_debris.hit"), + BLOCK_ANCIENT_DEBRIS_PLACE("block.ancient_debris.place"), + BLOCK_ANCIENT_DEBRIS_STEP("block.ancient_debris.step"), BLOCK_ANVIL_BREAK("block.anvil.break"), BLOCK_ANVIL_DESTROY("block.anvil.destroy"), BLOCK_ANVIL_FALL("block.anvil.fall"), @@ -34,6 +54,11 @@ public enum CraftSound { BLOCK_BAMBOO_STEP("block.bamboo.step"), BLOCK_BARREL_CLOSE("block.barrel.close"), BLOCK_BARREL_OPEN("block.barrel.open"), + BLOCK_BASALT_BREAK("block.basalt.break"), + BLOCK_BASALT_FALL("block.basalt.fall"), + BLOCK_BASALT_HIT("block.basalt.hit"), + BLOCK_BASALT_PLACE("block.basalt.place"), + BLOCK_BASALT_STEP("block.basalt.step"), BLOCK_BEACON_ACTIVATE("block.beacon.activate"), BLOCK_BEACON_AMBIENT("block.beacon.ambient"), BLOCK_BEACON_DEACTIVATE("block.beacon.deactivate"), @@ -46,6 +71,11 @@ public enum CraftSound { BLOCK_BELL_RESONATE("block.bell.resonate"), BLOCK_BELL_USE("block.bell.use"), BLOCK_BLASTFURNACE_FIRE_CRACKLE("block.blastfurnace.fire_crackle"), + BLOCK_BONE_BLOCK_BREAK("block.bone_block.break"), + BLOCK_BONE_BLOCK_FALL("block.bone_block.fall"), + BLOCK_BONE_BLOCK_HIT("block.bone_block.hit"), + BLOCK_BONE_BLOCK_PLACE("block.bone_block.place"), + BLOCK_BONE_BLOCK_STEP("block.bone_block.step"), BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"), BLOCK_BUBBLE_COLUMN_BUBBLE_POP("block.bubble_column.bubble_pop"), BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"), @@ -53,6 +83,11 @@ public enum CraftSound { BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT("block.bubble_column.whirlpool_ambient"), BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE("block.bubble_column.whirlpool_inside"), BLOCK_CAMPFIRE_CRACKLE("block.campfire.crackle"), + BLOCK_CHAIN_BREAK("block.chain.break"), + BLOCK_CHAIN_FALL("block.chain.fall"), + BLOCK_CHAIN_HIT("block.chain.hit"), + BLOCK_CHAIN_PLACE("block.chain.place"), + BLOCK_CHAIN_STEP("block.chain.step"), BLOCK_CHEST_CLOSE("block.chest.close"), BLOCK_CHEST_LOCKED("block.chest.locked"), BLOCK_CHEST_OPEN("block.chest.open"), @@ -87,7 +122,17 @@ public enum CraftSound { BLOCK_FENCE_GATE_OPEN("block.fence_gate.open"), BLOCK_FIRE_AMBIENT("block.fire.ambient"), BLOCK_FIRE_EXTINGUISH("block.fire.extinguish"), + BLOCK_FUNGUS_BREAK("block.fungus.break"), + BLOCK_FUNGUS_FALL("block.fungus.fall"), + BLOCK_FUNGUS_HIT("block.fungus.hit"), + BLOCK_FUNGUS_PLACE("block.fungus.place"), + BLOCK_FUNGUS_STEP("block.fungus.step"), BLOCK_FURNACE_FIRE_CRACKLE("block.furnace.fire_crackle"), + BLOCK_GILDED_BLACKSTONE_BREAK("block.gilded_blackstone.break"), + BLOCK_GILDED_BLACKSTONE_FALL("block.gilded_blackstone.fall"), + BLOCK_GILDED_BLACKSTONE_HIT("block.gilded_blackstone.hit"), + BLOCK_GILDED_BLACKSTONE_PLACE("block.gilded_blackstone.place"), + BLOCK_GILDED_BLACKSTONE_STEP("block.gilded_blackstone.step"), BLOCK_GLASS_BREAK("block.glass.break"), BLOCK_GLASS_FALL("block.glass.fall"), BLOCK_GLASS_HIT("block.glass.hit"), @@ -129,6 +174,11 @@ public enum CraftSound { BLOCK_LAVA_POP("block.lava.pop"), BLOCK_LEVER_CLICK("block.lever.click"), BLOCK_LILY_PAD_PLACE("block.lily_pad.place"), + BLOCK_LODESTONE_BREAK("block.lodestone.break"), + BLOCK_LODESTONE_FALL("block.lodestone.fall"), + BLOCK_LODESTONE_HIT("block.lodestone.hit"), + BLOCK_LODESTONE_PLACE("block.lodestone.place"), + BLOCK_LODESTONE_STEP("block.lodestone.step"), BLOCK_METAL_BREAK("block.metal.break"), BLOCK_METAL_FALL("block.metal.fall"), BLOCK_METAL_HIT("block.metal.hit"), @@ -136,6 +186,36 @@ public enum CraftSound { BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF("block.metal_pressure_plate.click_off"), BLOCK_METAL_PRESSURE_PLATE_CLICK_ON("block.metal_pressure_plate.click_on"), BLOCK_METAL_STEP("block.metal.step"), + BLOCK_NETHERITE_BLOCK_BREAK("block.netherite_block.break"), + BLOCK_NETHERITE_BLOCK_FALL("block.netherite_block.fall"), + BLOCK_NETHERITE_BLOCK_HIT("block.netherite_block.hit"), + BLOCK_NETHERITE_BLOCK_PLACE("block.netherite_block.place"), + BLOCK_NETHERITE_BLOCK_STEP("block.netherite_block.step"), + BLOCK_NETHERRACK_BREAK("block.netherrack.break"), + BLOCK_NETHERRACK_FALL("block.netherrack.fall"), + BLOCK_NETHERRACK_HIT("block.netherrack.hit"), + BLOCK_NETHERRACK_PLACE("block.netherrack.place"), + BLOCK_NETHERRACK_STEP("block.netherrack.step"), + BLOCK_NETHER_BRICKS_BREAK("block.nether_bricks.break"), + BLOCK_NETHER_BRICKS_FALL("block.nether_bricks.fall"), + BLOCK_NETHER_BRICKS_HIT("block.nether_bricks.hit"), + BLOCK_NETHER_BRICKS_PLACE("block.nether_bricks.place"), + BLOCK_NETHER_BRICKS_STEP("block.nether_bricks.step"), + BLOCK_NETHER_GOLD_ORE_BREAK("block.nether_gold_ore.break"), + BLOCK_NETHER_GOLD_ORE_FALL("block.nether_gold_ore.fall"), + BLOCK_NETHER_GOLD_ORE_HIT("block.nether_gold_ore.hit"), + BLOCK_NETHER_GOLD_ORE_PLACE("block.nether_gold_ore.place"), + BLOCK_NETHER_GOLD_ORE_STEP("block.nether_gold_ore.step"), + BLOCK_NETHER_ORE_BREAK("block.nether_ore.break"), + BLOCK_NETHER_ORE_FALL("block.nether_ore.fall"), + BLOCK_NETHER_ORE_HIT("block.nether_ore.hit"), + BLOCK_NETHER_ORE_PLACE("block.nether_ore.place"), + BLOCK_NETHER_ORE_STEP("block.nether_ore.step"), + BLOCK_NETHER_SPROUTS_BREAK("block.nether_sprouts.break"), + BLOCK_NETHER_SPROUTS_FALL("block.nether_sprouts.fall"), + BLOCK_NETHER_SPROUTS_HIT("block.nether_sprouts.hit"), + BLOCK_NETHER_SPROUTS_PLACE("block.nether_sprouts.place"), + BLOCK_NETHER_SPROUTS_STEP("block.nether_sprouts.step"), BLOCK_NETHER_WART_BREAK("block.nether_wart.break"), BLOCK_NOTE_BLOCK_BANJO("block.note_block.banjo"), BLOCK_NOTE_BLOCK_BASEDRUM("block.note_block.basedrum"), @@ -153,6 +233,11 @@ public enum CraftSound { BLOCK_NOTE_BLOCK_PLING("block.note_block.pling"), BLOCK_NOTE_BLOCK_SNARE("block.note_block.snare"), BLOCK_NOTE_BLOCK_XYLOPHONE("block.note_block.xylophone"), + BLOCK_NYLIUM_BREAK("block.nylium.break"), + BLOCK_NYLIUM_FALL("block.nylium.fall"), + BLOCK_NYLIUM_HIT("block.nylium.hit"), + BLOCK_NYLIUM_PLACE("block.nylium.place"), + BLOCK_NYLIUM_STEP("block.nylium.step"), BLOCK_PISTON_CONTRACT("block.piston.contract"), BLOCK_PISTON_EXTEND("block.piston.extend"), BLOCK_PORTAL_AMBIENT("block.portal.ambient"), @@ -160,6 +245,15 @@ public enum CraftSound { BLOCK_PORTAL_TRIGGER("block.portal.trigger"), BLOCK_PUMPKIN_CARVE("block.pumpkin.carve"), BLOCK_REDSTONE_TORCH_BURNOUT("block.redstone_torch.burnout"), + BLOCK_RESPAWN_ANCHOR_AMBIENT("block.respawn_anchor.ambient"), + BLOCK_RESPAWN_ANCHOR_CHARGE("block.respawn_anchor.charge"), + BLOCK_RESPAWN_ANCHOR_DEPLETE("block.respawn_anchor.deplete"), + BLOCK_RESPAWN_ANCHOR_SET_SPAWN("block.respawn_anchor.set_spawn"), + BLOCK_ROOTS_BREAK("block.roots.break"), + BLOCK_ROOTS_FALL("block.roots.fall"), + BLOCK_ROOTS_HIT("block.roots.hit"), + BLOCK_ROOTS_PLACE("block.roots.place"), + BLOCK_ROOTS_STEP("block.roots.step"), BLOCK_SAND_BREAK("block.sand.break"), BLOCK_SAND_FALL("block.sand.fall"), BLOCK_SAND_HIT("block.sand.hit"), @@ -170,6 +264,11 @@ public enum CraftSound { BLOCK_SCAFFOLDING_HIT("block.scaffolding.hit"), BLOCK_SCAFFOLDING_PLACE("block.scaffolding.place"), BLOCK_SCAFFOLDING_STEP("block.scaffolding.step"), + BLOCK_SHROOMLIGHT_BREAK("block.shroomlight.break"), + BLOCK_SHROOMLIGHT_FALL("block.shroomlight.fall"), + BLOCK_SHROOMLIGHT_HIT("block.shroomlight.hit"), + BLOCK_SHROOMLIGHT_PLACE("block.shroomlight.place"), + BLOCK_SHROOMLIGHT_STEP("block.shroomlight.step"), BLOCK_SHULKER_BOX_CLOSE("block.shulker_box.close"), BLOCK_SHULKER_BOX_OPEN("block.shulker_box.open"), BLOCK_SLIME_BLOCK_BREAK("block.slime_block.break"), @@ -177,12 +276,28 @@ public enum CraftSound { BLOCK_SLIME_BLOCK_HIT("block.slime_block.hit"), BLOCK_SLIME_BLOCK_PLACE("block.slime_block.place"), BLOCK_SLIME_BLOCK_STEP("block.slime_block.step"), + BLOCK_SMITHING_TABLE_USE("block.smithing_table.use"), BLOCK_SMOKER_SMOKE("block.smoker.smoke"), BLOCK_SNOW_BREAK("block.snow.break"), BLOCK_SNOW_FALL("block.snow.fall"), BLOCK_SNOW_HIT("block.snow.hit"), BLOCK_SNOW_PLACE("block.snow.place"), BLOCK_SNOW_STEP("block.snow.step"), + BLOCK_SOUL_SAND_BREAK("block.soul_sand.break"), + BLOCK_SOUL_SAND_FALL("block.soul_sand.fall"), + BLOCK_SOUL_SAND_HIT("block.soul_sand.hit"), + BLOCK_SOUL_SAND_PLACE("block.soul_sand.place"), + BLOCK_SOUL_SAND_STEP("block.soul_sand.step"), + BLOCK_SOUL_SOIL_BREAK("block.soul_soil.break"), + BLOCK_SOUL_SOIL_FALL("block.soul_soil.fall"), + BLOCK_SOUL_SOIL_HIT("block.soul_soil.hit"), + BLOCK_SOUL_SOIL_PLACE("block.soul_soil.place"), + BLOCK_SOUL_SOIL_STEP("block.soul_soil.step"), + BLOCK_STEM_BREAK("block.stem.break"), + BLOCK_STEM_FALL("block.stem.fall"), + BLOCK_STEM_HIT("block.stem.hit"), + BLOCK_STEM_PLACE("block.stem.place"), + BLOCK_STEM_STEP("block.stem.step"), BLOCK_STONE_BREAK("block.stone.break"), BLOCK_STONE_BUTTON_CLICK_OFF("block.stone_button.click_off"), BLOCK_STONE_BUTTON_CLICK_ON("block.stone_button.click_on"), @@ -198,7 +313,18 @@ public enum CraftSound { BLOCK_TRIPWIRE_CLICK_OFF("block.tripwire.click_off"), BLOCK_TRIPWIRE_CLICK_ON("block.tripwire.click_on"), BLOCK_TRIPWIRE_DETACH("block.tripwire.detach"), + BLOCK_VINE_STEP("block.vine.step"), + BLOCK_WART_BLOCK_BREAK("block.wart_block.break"), + BLOCK_WART_BLOCK_FALL("block.wart_block.fall"), + BLOCK_WART_BLOCK_HIT("block.wart_block.hit"), + BLOCK_WART_BLOCK_PLACE("block.wart_block.place"), + BLOCK_WART_BLOCK_STEP("block.wart_block.step"), BLOCK_WATER_AMBIENT("block.water.ambient"), + BLOCK_WEEPING_VINES_BREAK("block.weeping_vines.break"), + BLOCK_WEEPING_VINES_FALL("block.weeping_vines.fall"), + BLOCK_WEEPING_VINES_HIT("block.weeping_vines.hit"), + BLOCK_WEEPING_VINES_PLACE("block.weeping_vines.place"), + BLOCK_WEEPING_VINES_STEP("block.weeping_vines.step"), BLOCK_WET_GRASS_BREAK("block.wet_grass.break"), BLOCK_WET_GRASS_FALL("block.wet_grass.fall"), BLOCK_WET_GRASS_HIT("block.wet_grass.hit"), @@ -288,6 +414,7 @@ public enum CraftSound { ENTITY_DONKEY_ANGRY("entity.donkey.angry"), ENTITY_DONKEY_CHEST("entity.donkey.chest"), ENTITY_DONKEY_DEATH("entity.donkey.death"), + ENTITY_DONKEY_EAT("entity.donkey.eat"), ENTITY_DONKEY_HURT("entity.donkey.hurt"), ENTITY_DRAGON_FIREBALL_EXPLODE("entity.dragon_fireball.explode"), ENTITY_DROWNED_AMBIENT("entity.drowned.ambient"), @@ -360,6 +487,7 @@ public enum CraftSound { ENTITY_FOX_SLEEP("entity.fox.sleep"), ENTITY_FOX_SNIFF("entity.fox.sniff"), ENTITY_FOX_SPIT("entity.fox.spit"), + ENTITY_FOX_TELEPORT("entity.fox.teleport"), ENTITY_GENERIC_BIG_FALL("entity.generic.big_fall"), ENTITY_GENERIC_BURN("entity.generic.burn"), ENTITY_GENERIC_DEATH("entity.generic.death"), @@ -385,6 +513,14 @@ public enum CraftSound { ENTITY_GUARDIAN_FLOP("entity.guardian.flop"), ENTITY_GUARDIAN_HURT("entity.guardian.hurt"), ENTITY_GUARDIAN_HURT_LAND("entity.guardian.hurt_land"), + ENTITY_HOGLIN_AMBIENT("entity.hoglin.ambient"), + ENTITY_HOGLIN_ANGRY("entity.hoglin.angry"), + ENTITY_HOGLIN_ATTACK("entity.hoglin.attack"), + ENTITY_HOGLIN_CONVERTED_TO_ZOMBIFIED("entity.hoglin.converted_to_zombified"), + ENTITY_HOGLIN_DEATH("entity.hoglin.death"), + ENTITY_HOGLIN_HURT("entity.hoglin.hurt"), + ENTITY_HOGLIN_RETREAT("entity.hoglin.retreat"), + ENTITY_HOGLIN_STEP("entity.hoglin.step"), ENTITY_HORSE_AMBIENT("entity.horse.ambient"), ENTITY_HORSE_ANGRY("entity.horse.angry"), ENTITY_HORSE_ARMOR("entity.horse.armor"), @@ -458,8 +594,10 @@ public enum CraftSound { ENTITY_MOOSHROOM_SHEAR("entity.mooshroom.shear"), ENTITY_MOOSHROOM_SUSPICIOUS_MILK("entity.mooshroom.suspicious_milk"), ENTITY_MULE_AMBIENT("entity.mule.ambient"), + ENTITY_MULE_ANGRY("entity.mule.angry"), ENTITY_MULE_CHEST("entity.mule.chest"), ENTITY_MULE_DEATH("entity.mule.death"), + ENTITY_MULE_EAT("entity.mule.eat"), ENTITY_MULE_HURT("entity.mule.hurt"), ENTITY_OCELOT_AMBIENT("entity.ocelot.ambient"), ENTITY_OCELOT_DEATH("entity.ocelot.death"), @@ -491,10 +629,12 @@ public enum CraftSound { ENTITY_PARROT_IMITATE_EVOKER("entity.parrot.imitate.evoker"), ENTITY_PARROT_IMITATE_GHAST("entity.parrot.imitate.ghast"), ENTITY_PARROT_IMITATE_GUARDIAN("entity.parrot.imitate.guardian"), + ENTITY_PARROT_IMITATE_HOGLIN("entity.parrot.imitate.hoglin"), ENTITY_PARROT_IMITATE_HUSK("entity.parrot.imitate.husk"), ENTITY_PARROT_IMITATE_ILLUSIONER("entity.parrot.imitate.illusioner"), ENTITY_PARROT_IMITATE_MAGMA_CUBE("entity.parrot.imitate.magma_cube"), ENTITY_PARROT_IMITATE_PHANTOM("entity.parrot.imitate.phantom"), + ENTITY_PARROT_IMITATE_PIGLIN("entity.parrot.imitate.piglin"), ENTITY_PARROT_IMITATE_PILLAGER("entity.parrot.imitate.pillager"), ENTITY_PARROT_IMITATE_RAVAGER("entity.parrot.imitate.ravager"), ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"), @@ -508,6 +648,7 @@ public enum CraftSound { 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_ZOGLIN("entity.parrot.imitate.zoglin"), ENTITY_PARROT_IMITATE_ZOMBIE("entity.parrot.imitate.zombie"), ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER("entity.parrot.imitate.zombie_villager"), ENTITY_PARROT_STEP("entity.parrot.step"), @@ -517,6 +658,16 @@ public enum CraftSound { ENTITY_PHANTOM_FLAP("entity.phantom.flap"), ENTITY_PHANTOM_HURT("entity.phantom.hurt"), ENTITY_PHANTOM_SWOOP("entity.phantom.swoop"), + ENTITY_PIGLIN_ADMIRING_ITEM("entity.piglin.admiring_item"), + ENTITY_PIGLIN_AMBIENT("entity.piglin.ambient"), + ENTITY_PIGLIN_ANGRY("entity.piglin.angry"), + ENTITY_PIGLIN_CELEBRATE("entity.piglin.celebrate"), + ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED("entity.piglin.converted_to_zombified"), + ENTITY_PIGLIN_DEATH("entity.piglin.death"), + ENTITY_PIGLIN_HURT("entity.piglin.hurt"), + ENTITY_PIGLIN_JEALOUS("entity.piglin.jealous"), + ENTITY_PIGLIN_RETREAT("entity.piglin.retreat"), + ENTITY_PIGLIN_STEP("entity.piglin.step"), ENTITY_PIG_AMBIENT("entity.pig.ambient"), ENTITY_PIG_DEATH("entity.pig.death"), ENTITY_PIG_HURT("entity.pig.hurt"), @@ -620,6 +771,7 @@ public enum CraftSound { ENTITY_SNOW_GOLEM_AMBIENT("entity.snow_golem.ambient"), ENTITY_SNOW_GOLEM_DEATH("entity.snow_golem.death"), ENTITY_SNOW_GOLEM_HURT("entity.snow_golem.hurt"), + ENTITY_SNOW_GOLEM_SHEAR("entity.snow_golem.shear"), ENTITY_SNOW_GOLEM_SHOOT("entity.snow_golem.shoot"), ENTITY_SPIDER_AMBIENT("entity.spider.ambient"), ENTITY_SPIDER_DEATH("entity.spider.death"), @@ -635,6 +787,15 @@ public enum CraftSound { ENTITY_STRAY_DEATH("entity.stray.death"), ENTITY_STRAY_HURT("entity.stray.hurt"), ENTITY_STRAY_STEP("entity.stray.step"), + ENTITY_STRIDER_AMBIENT("entity.strider.ambient"), + ENTITY_STRIDER_DEATH("entity.strider.death"), + ENTITY_STRIDER_EAT("entity.strider.eat"), + ENTITY_STRIDER_HAPPY("entity.strider.happy"), + ENTITY_STRIDER_HURT("entity.strider.hurt"), + ENTITY_STRIDER_RETREAT("entity.strider.retreat"), + ENTITY_STRIDER_SADDLE("entity.strider.saddle"), + ENTITY_STRIDER_STEP("entity.strider.step"), + ENTITY_STRIDER_STEP_LAVA("entity.strider.step_lava"), ENTITY_TNT_PRIMED("entity.tnt.primed"), ENTITY_TROPICAL_FISH_AMBIENT("entity.tropical_fish.ambient"), ENTITY_TROPICAL_FISH_DEATH("entity.tropical_fish.death"), @@ -715,6 +876,12 @@ public enum CraftSound { ENTITY_WOLF_SHAKE("entity.wolf.shake"), ENTITY_WOLF_STEP("entity.wolf.step"), ENTITY_WOLF_WHINE("entity.wolf.whine"), + ENTITY_ZOGLIN_AMBIENT("entity.zoglin.ambient"), + ENTITY_ZOGLIN_ANGRY("entity.zoglin.angry"), + ENTITY_ZOGLIN_ATTACK("entity.zoglin.attack"), + ENTITY_ZOGLIN_DEATH("entity.zoglin.death"), + ENTITY_ZOGLIN_HURT("entity.zoglin.hurt"), + ENTITY_ZOGLIN_STEP("entity.zoglin.step"), ENTITY_ZOMBIE_AMBIENT("entity.zombie.ambient"), ENTITY_ZOMBIE_ATTACK_IRON_DOOR("entity.zombie.attack_iron_door"), ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR("entity.zombie.attack_wooden_door"), @@ -727,10 +894,6 @@ public enum CraftSound { ENTITY_ZOMBIE_HORSE_HURT("entity.zombie_horse.hurt"), ENTITY_ZOMBIE_HURT("entity.zombie.hurt"), ENTITY_ZOMBIE_INFECT("entity.zombie.infect"), - ENTITY_ZOMBIE_PIGMAN_AMBIENT("entity.zombie_pigman.ambient"), - ENTITY_ZOMBIE_PIGMAN_ANGRY("entity.zombie_pigman.angry"), - ENTITY_ZOMBIE_PIGMAN_DEATH("entity.zombie_pigman.death"), - ENTITY_ZOMBIE_PIGMAN_HURT("entity.zombie_pigman.hurt"), ENTITY_ZOMBIE_STEP("entity.zombie.step"), ENTITY_ZOMBIE_VILLAGER_AMBIENT("entity.zombie_villager.ambient"), ENTITY_ZOMBIE_VILLAGER_CONVERTED("entity.zombie_villager.converted"), @@ -738,6 +901,10 @@ public enum CraftSound { ENTITY_ZOMBIE_VILLAGER_DEATH("entity.zombie_villager.death"), ENTITY_ZOMBIE_VILLAGER_HURT("entity.zombie_villager.hurt"), ENTITY_ZOMBIE_VILLAGER_STEP("entity.zombie_villager.step"), + ENTITY_ZOMBIFIED_PIGLIN_AMBIENT("entity.zombified_piglin.ambient"), + ENTITY_ZOMBIFIED_PIGLIN_ANGRY("entity.zombified_piglin.angry"), + ENTITY_ZOMBIFIED_PIGLIN_DEATH("entity.zombified_piglin.death"), + ENTITY_ZOMBIFIED_PIGLIN_HURT("entity.zombified_piglin.hurt"), EVENT_RAID_HORN("event.raid.horn"), ITEM_ARMOR_EQUIP_CHAIN("item.armor.equip_chain"), ITEM_ARMOR_EQUIP_DIAMOND("item.armor.equip_diamond"), @@ -746,6 +913,7 @@ public enum CraftSound { ITEM_ARMOR_EQUIP_GOLD("item.armor.equip_gold"), ITEM_ARMOR_EQUIP_IRON("item.armor.equip_iron"), ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"), + ITEM_ARMOR_EQUIP_NETHERITE("item.armor.equip_netherite"), ITEM_ARMOR_EQUIP_TURTLE("item.armor.equip_turtle"), ITEM_AXE_STRIP("item.axe.strip"), ITEM_BOOK_PAGE_TURN("item.book.page_turn"), @@ -774,6 +942,7 @@ public enum CraftSound { ITEM_FLINTANDSTEEL_USE("item.flintandsteel.use"), ITEM_HOE_TILL("item.hoe.till"), ITEM_HONEY_BOTTLE_DRINK("item.honey_bottle.drink"), + ITEM_LODESTONE_COMPASS_LOCK("item.lodestone_compass.lock"), ITEM_NETHER_WART_PLANT("item.nether_wart.plant"), ITEM_SHIELD_BLOCK("item.shield.block"), ITEM_SHIELD_BREAK("item.shield.break"), @@ -798,6 +967,7 @@ public enum CraftSound { MUSIC_DISC_FAR("music_disc.far"), MUSIC_DISC_MALL("music_disc.mall"), MUSIC_DISC_MELLOHI("music_disc.mellohi"), + MUSIC_DISC_PIGSTEP("music_disc.pigstep"), MUSIC_DISC_STAL("music_disc.stal"), MUSIC_DISC_STRAD("music_disc.strad"), MUSIC_DISC_WAIT("music_disc.wait"), @@ -806,8 +976,13 @@ public enum CraftSound { MUSIC_END("music.end"), MUSIC_GAME("music.game"), MUSIC_MENU("music.menu"), - MUSIC_NETHER("music.nether"), + MUSIC_NETHER_BASALT_DELTAS("music.nether.basalt_deltas"), + MUSIC_NETHER_CRIMSON_FOREST("music.nether.crimson_forest"), + MUSIC_NETHER_NETHER_WASTES("music.nether.nether_wastes"), + MUSIC_NETHER_SOUL_SAND_VALLEY("music.nether.soul_sand_valley"), + MUSIC_NETHER_WARPED_FOREST("music.nether.warped_forest"), MUSIC_UNDER_WATER("music.under_water"), + PARTICLE_SOUL_ESCAPE("particle.soul_escape"), UI_BUTTON_CLICK("ui.button.click"), UI_CARTOGRAPHY_TABLE_TAKE_RESULT("ui.cartography_table.take_result"), UI_LOOM_SELECT_PATTERN("ui.loom.select_pattern"), diff --git a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index 29d298319b..2758eee2be 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -96,7 +96,10 @@ public enum CraftStatistic { RAID_TRIGGER(StatisticList.RAID_TRIGGER), RAID_WIN(StatisticList.RAID_WIN), INTERACT_WITH_ANVIL(StatisticList.INTERACT_WITH_ANVIL), - INTERACT_WITH_GRINDSTONE(StatisticList.INTERACT_WITH_GRINDSTONE); + INTERACT_WITH_GRINDSTONE(StatisticList.INTERACT_WITH_GRINDSTONE), + TARGET_HIT(StatisticList.TARGET_HIT), + INTERACT_WITH_SMITHING_TABLE(StatisticList.INTERACT_WITH_SMITHING_TABLE), + STRIDER_ONE_CM(StatisticList.STRIDER_ONE_CM); private final MinecraftKey minecraftKey; private final org.bukkit.Statistic bukkit; private static final BiMap statistics; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 831048f83a..e5130bf609 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -67,7 +67,6 @@ import net.minecraft.server.EntityZombie; import net.minecraft.server.EnumDifficulty; import net.minecraft.server.EnumDirection; import net.minecraft.server.EnumMobSpawn; -import net.minecraft.server.ExceptionWorldConflict; import net.minecraft.server.Explosion; import net.minecraft.server.GameRules; import net.minecraft.server.GroupDataEntity; @@ -82,14 +81,14 @@ import net.minecraft.server.PersistentRaid; import net.minecraft.server.PlayerChunk; import net.minecraft.server.ProtoChunkExtension; import net.minecraft.server.RayTrace; +import net.minecraft.server.SavedFile; import net.minecraft.server.SoundCategory; +import net.minecraft.server.StructureGenerator; import net.minecraft.server.Ticket; import net.minecraft.server.TicketType; import net.minecraft.server.Unit; import net.minecraft.server.Vec3D; import net.minecraft.server.WorldGenerator; -import net.minecraft.server.WorldProvider; -import net.minecraft.server.WorldProviderTheEnd; import net.minecraft.server.WorldServer; import org.apache.commons.lang.Validate; import org.bukkit.BlockChangeDelegate; @@ -119,8 +118,6 @@ import org.bukkit.craftbukkit.block.CraftBlockState; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.boss.CraftDragonBattle; import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftItem; -import org.bukkit.craftbukkit.entity.CraftLightningStrike; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.metadata.BlockMetadataStore; @@ -173,6 +170,7 @@ import org.bukkit.entity.Giant; import org.bukkit.entity.Golem; import org.bukkit.entity.Guardian; import org.bukkit.entity.Hanging; +import org.bukkit.entity.Hoglin; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Husk; import org.bukkit.entity.Illager; @@ -196,6 +194,7 @@ import org.bukkit.entity.Parrot; import org.bukkit.entity.Phantom; import org.bukkit.entity.Pig; import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Piglin; import org.bukkit.entity.Pillager; import org.bukkit.entity.Player; import org.bukkit.entity.PolarBear; @@ -219,6 +218,7 @@ import org.bukkit.entity.Spellcaster; import org.bukkit.entity.Spider; import org.bukkit.entity.Squid; import org.bukkit.entity.Stray; +import org.bukkit.entity.Strider; import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.Tameable; import org.bukkit.entity.ThrownExpBottle; @@ -237,6 +237,7 @@ import org.bukkit.entity.Wither; import org.bukkit.entity.WitherSkeleton; import org.bukkit.entity.WitherSkull; import org.bukkit.entity.Wolf; +import org.bukkit.entity.Zoglin; import org.bukkit.entity.Zombie; import org.bukkit.entity.ZombieHorse; import org.bukkit.entity.ZombieVillager; @@ -642,16 +643,19 @@ public class CraftWorld implements World { @Override public LightningStrike strikeLightning(Location loc) { - EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), false); + EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.a(world); + lightning.teleportAndSync(loc.getX(), loc.getY(), loc.getZ()); world.strikeLightning(lightning); - return new CraftLightningStrike(server, lightning); + return (LightningStrike) lightning.getBukkitEntity(); } @Override public LightningStrike strikeLightningEffect(Location loc) { - EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), true); + EntityLightning lightning = EntityTypes.LIGHTNING_BOLT.a(world); + lightning.teleportAndSync(loc.getX(), loc.getY(), loc.getZ()); + lightning.setEffect(true); world.strikeLightning(lightning); - return new CraftLightningStrike(server, lightning); + return (LightningStrike) lightning.getBukkitEntity(); } @Override @@ -662,35 +666,35 @@ public class CraftWorld implements World { net.minecraft.server.WorldGenFeatureConfiguration conf; switch (type) { case BIG_TREE: - gen = WorldGenerator.FANCY_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.FANCY_TREE; break; case BIRCH: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.BIRCH_TREE; break; case REDWOOD: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.SPRUCE_TREE; break; case TALL_REDWOOD: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.PINE_TREE; break; case JUNGLE: - gen = WorldGenerator.MEGA_JUNGLE_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.MEGA_JUNGLE_TREE; break; case SMALL_JUNGLE: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.JUNGLE_TREE_NOVINE; break; case COCOA_TREE: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.JUNGLE_TREE; break; case JUNGLE_BUSH: - gen = WorldGenerator.JUNGLE_GROUND_BUSH; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.JUNGLE_BUSH; break; case RED_MUSHROOM: @@ -702,23 +706,23 @@ public class CraftWorld implements World { conf = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM; break; case SWAMP: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.SWAMP_TREE; break; case ACACIA: - gen = WorldGenerator.ACACIA_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.ACACIA_TREE; break; case DARK_OAK: - gen = WorldGenerator.DARK_OAK_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.DARK_OAK_TREE; break; case MEGA_REDWOOD: - gen = WorldGenerator.MEGA_SPRUCE_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.MEGA_PINE_TREE; break; case TALL_BIRCH: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.TALL_BIRCH_TREE_BEES_0002; break; case CHORUS_PLANT: @@ -726,12 +730,12 @@ public class CraftWorld implements World { return true; case TREE: default: - gen = WorldGenerator.NORMAL_TREE; + gen = WorldGenerator.TREE; conf = BiomeDecoratorGroups.NORMAL_TREE; break; } - return gen.generate(world, world.worldProvider.getChunkGenerator(), rand, pos, conf); + return gen.generate(world, world.getStructureManager(), world.getChunkProvider().getChunkGenerator(), rand, pos, conf); } @Override @@ -760,12 +764,12 @@ public class CraftWorld implements World { @Override public String getName() { - return world.worldData.getName(); + return world.worldDataServer.getName(); } @Override public UUID getUID() { - return world.getDataManager().getUUID(); + return world.uuid; } @Override @@ -898,7 +902,7 @@ public class CraftWorld implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { // Transient load for this tick - return world.getChunkAt(x >> 4, z >> 4).a(CraftHeightMap.toNMS(heightMap), x, z); + return world.getChunkAt(x >> 4, z >> 4).getHighestBlock(CraftHeightMap.toNMS(heightMap), x, z); } @Override @@ -1242,16 +1246,12 @@ public class CraftWorld implements World { @Override public void save() { this.server.checkSaveState(); - try { - boolean oldSave = world.savingDisabled; + boolean oldSave = world.savingDisabled; - world.savingDisabled = false; - world.save(null, false, false); + world.savingDisabled = false; + world.save(null, false, false); - world.savingDisabled = oldSave; - } catch (ExceptionWorldConflict ex) { - ex.printStackTrace(); - } + world.savingDisabled = oldSave; } @Override @@ -1266,7 +1266,7 @@ public class CraftWorld implements World { @Override public void setDifficulty(Difficulty difficulty) { - this.getHandle().worldData.setDifficulty(EnumDifficulty.getById(difficulty.getValue())); + this.getHandle().worldDataServer.setDifficulty(EnumDifficulty.getById(difficulty.getValue())); } @Override @@ -1291,12 +1291,12 @@ public class CraftWorld implements World { @Override public int getWeatherDuration() { - return world.worldData.getWeatherDuration(); + return world.worldDataServer.getWeatherDuration(); } @Override public void setWeatherDuration(int duration) { - world.worldData.setWeatherDuration(duration); + world.worldDataServer.setWeatherDuration(duration); } @Override @@ -1306,23 +1306,23 @@ public class CraftWorld implements World { @Override public void setThundering(boolean thundering) { - world.worldData.setThundering(thundering); + world.worldDataServer.setThundering(thundering); setThunderDuration(0); // Reset weather duration (legacy behaviour) } @Override public int getThunderDuration() { - return world.worldData.getThunderDuration(); + return world.worldDataServer.getThunderDuration(); } @Override public void setThunderDuration(int duration) { - world.worldData.setThunderDuration(duration); + world.worldDataServer.setThunderDuration(duration); } @Override public long getSeed() { - return world.worldData.getSeed(); + return world.getSeed(); } @Override @@ -1593,7 +1593,7 @@ public class CraftWorld implements World { entity = EntityTypes.CAT.a(world); } } else if (PigZombie.class.isAssignableFrom(clazz)) { - entity = EntityTypes.ZOMBIE_PIGMAN.a(world); + entity = EntityTypes.ZOMBIFIED_PIGLIN.a(world); } else if (Zombie.class.isAssignableFrom(clazz)) { if (Husk.class.isAssignableFrom(clazz)) { entity = EntityTypes.HUSK.a(world); @@ -1684,6 +1684,14 @@ public class CraftWorld implements World { entity = EntityTypes.FOX.a(world); } else if (Bee.class.isAssignableFrom(clazz)) { entity = EntityTypes.BEE.a(world); + } else if (Hoglin.class.isAssignableFrom(clazz)) { + entity = EntityTypes.HOGLIN.a(world); + } else if (Piglin.class.isAssignableFrom(clazz)) { + entity = EntityTypes.PIGLIN.a(world); + } else if (Strider.class.isAssignableFrom(clazz)) { + entity = EntityTypes.STRIDER.a(world); + } else if (Zoglin.class.isAssignableFrom(clazz)) { + entity = EntityTypes.ZOGLIN.a(world); } if (entity != null) { @@ -1751,9 +1759,9 @@ public class CraftWorld implements World { } else if (ExperienceOrb.class.isAssignableFrom(clazz)) { entity = new EntityExperienceOrb(world, x, y, z, 0); } else if (LightningStrike.class.isAssignableFrom(clazz)) { - entity = new EntityLightning(world, x, y, z, false); + entity = EntityTypes.LIGHTNING_BOLT.a(world); } else if (Firework.class.isAssignableFrom(clazz)) { - entity = new EntityFireworks(world, x, y, z, net.minecraft.server.ItemStack.a); + entity = new EntityFireworks(world, x, y, z, net.minecraft.server.ItemStack.b); } else if (AreaEffectCloud.class.isAssignableFrom(clazz)) { entity = new EntityAreaEffectCloud(world, x, y, z); } else if (EvokerFangs.class.isAssignableFrom(clazz)) { @@ -1777,7 +1785,7 @@ public class CraftWorld implements World { Preconditions.checkArgument(entity != null, "Cannot spawn null entity"); if (entity instanceof EntityInsentient) { - ((EntityInsentient) entity).prepare(getHandle(), getHandle().getDamageScaler(new BlockPosition(entity)), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null); + ((EntityInsentient) entity).prepare(getHandle(), getHandle().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null); } if (function != null) { @@ -1863,7 +1871,7 @@ public class CraftWorld implements World { @Override public File getWorldFolder() { - return world.getDataManager().getDirectory(); + return world.convertable.getWorldFolder(SavedFile.ROOT).toFile(); } @Override @@ -1888,12 +1896,12 @@ public class CraftWorld implements World { @Override public org.bukkit.WorldType getWorldType() { - return org.bukkit.WorldType.getByName(world.getWorldData().getType().name()); + return world.isFlatWorld() ? org.bukkit.WorldType.FLAT : org.bukkit.WorldType.NORMAL; } @Override public boolean canGenerateStructures() { - return world.getWorldData().shouldGenerateMapFeatures(); + return world.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures(); } @Override @@ -1903,7 +1911,7 @@ public class CraftWorld implements World { @Override public void setHardcore(boolean hardcore) { - world.getWorldData().setHardcore(hardcore); + world.worldDataServer.b.hardcore = true; } @Override @@ -2052,7 +2060,7 @@ public class CraftWorld implements World { double z = loc.getZ(); PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch); - world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.getWorldProvider().getDimensionManager(), packet); + world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.getDimensionKey(), packet); } private static Map> gamerules; @@ -2257,7 +2265,7 @@ public class CraftWorld implements World { @Override public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) { BlockPosition originPos = new BlockPosition(origin.getX(), origin.getY(), origin.getZ()); - BlockPosition nearest = getHandle().getChunkProvider().getChunkGenerator().findNearestMapFeature(getHandle(), structureType.getName(), originPos, radius, findUnexplored); + BlockPosition nearest = getHandle().getChunkProvider().getChunkGenerator().findNearestMapFeature(getHandle(), StructureGenerator.a.get(structureType.getName()), originPos, radius, findUnexplored); return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); } @@ -2279,11 +2287,6 @@ public class CraftWorld implements World { @Override public DragonBattle getEnderDragonBattle() { - WorldProvider worldProvider = getHandle().worldProvider; - if (!(worldProvider instanceof WorldProviderTheEnd)) { - return null; - } - - return new CraftDragonBattle(((WorldProviderTheEnd) worldProvider).o()); // PAIL rename getDragonBattle + return (getHandle().getDragonBattle() == null) ? null : new CraftDragonBattle(getHandle().getDragonBattle()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 37a1f817cf..d1c2fe1536 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -12,7 +12,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import joptsimple.OptionParser; import joptsimple.OptionSet; -import net.minecraft.server.MinecraftServer; import org.fusesource.jansi.AnsiConsole; public class Main { @@ -45,6 +44,7 @@ public class Main { acceptsAll(asList("W", "world-dir", "universe", "world-container"), "World container") .withRequiredArg() .ofType(File.class) + .defaultsTo(new File(".")) .describedAs("Directory containing worlds"); acceptsAll(asList("w", "world", "level-name"), "World name") @@ -177,11 +177,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 Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -21); + 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/go/outdated-spigot ***"); @@ -191,7 +191,7 @@ public class Main { } System.out.println("Loading libraries, please wait..."); - MinecraftServer.main(options); + net.minecraft.server.Main.main(options); } catch (Throwable t) { t.printStackTrace(); } diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java index f9da97c074..a7c500323b 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java @@ -10,10 +10,10 @@ import org.bukkit.attribute.AttributeModifier; public class CraftAttributeInstance implements AttributeInstance { - private final net.minecraft.server.AttributeInstance handle; + private final net.minecraft.server.AttributeModifiable handle; private final Attribute attribute; - public CraftAttributeInstance(net.minecraft.server.AttributeInstance handle, Attribute attribute) { + public CraftAttributeInstance(net.minecraft.server.AttributeModifiable handle, Attribute attribute) { this.handle = handle; this.attribute = attribute; } diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java index 77e584b129..67052387bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java @@ -1,13 +1,14 @@ package org.bukkit.craftbukkit.attribute; -import com.google.common.base.CaseFormat; import com.google.common.base.Preconditions; -import java.util.Locale; import net.minecraft.server.AttributeMapBase; -import org.apache.commons.lang3.EnumUtils; +import net.minecraft.server.IRegistry; +import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.attribute.Attributable; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; public class CraftAttributeMap implements Attributable { @@ -20,36 +21,12 @@ public class CraftAttributeMap implements Attributable { @Override public AttributeInstance getAttribute(Attribute attribute) { Preconditions.checkArgument(attribute != null, "attribute"); - net.minecraft.server.AttributeInstance nms = handle.a(toMinecraft(attribute.name())); + net.minecraft.server.AttributeModifiable nms = handle.a(IRegistry.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey()))); return (nms == null) ? null : new CraftAttributeInstance(nms, attribute); } - public static String toMinecraft(String bukkit) { - int first = bukkit.indexOf('_'); - int second = bukkit.indexOf('_', first + 1); - - StringBuilder sb = new StringBuilder(bukkit.toLowerCase(java.util.Locale.ENGLISH)); - - sb.setCharAt(first, '.'); - if (second != -1) { - sb.deleteCharAt(second); - sb.setCharAt(second, bukkit.charAt(second + 1)); - } - - return sb.toString(); - } - - public static String toMinecraft(Attribute attribute) { - return toMinecraft(attribute.name()); - } - public static Attribute fromMinecraft(String nms) { - String[] split = nms.split("\\.", 2); - - String generic = split[0]; - String descriptor = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, split[1]); // movementSpeed -> MOVEMENT_SPEED - String fin = generic + "_" + descriptor; - return EnumUtils.getEnum(Attribute.class, fin.toUpperCase(Locale.ROOT)); // so we can return null without throwing exceptions + return Registry.ATTRIBUTE.get(NamespacedKey.minecraft(nms)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java index c8b41ba0bd..0ffec81155 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java @@ -43,12 +43,12 @@ public class CraftBeehive extends CraftBlockEntityState imple @Override public boolean isSedated() { - return isPlaced() && getTileEntity().k(); // PAIL rename isSedated + return isPlaced() && getTileEntity().isSedated(); } @Override public int getEntityCount() { - return getSnapshot().j(); // PAIL rename beeCount + return getSnapshot().getBeeCount(); } @Override @@ -81,6 +81,6 @@ public class CraftBeehive extends CraftBlockEntityState imple public void addEntity(Bee entity) { Preconditions.checkArgument(entity != null, "Entity must not be null"); - getSnapshot().a(((CraftBee) entity).getHandle(), false); // PAIL rename addBee + getSnapshot().addBee(((CraftBee) entity).getHandle(), false); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 5a1629a19f..562d9daa34 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -551,20 +551,29 @@ public class CraftBlock implements Block { @Override public int getBlockPower(BlockFace face) { int power = 0; - BlockRedstoneWire wire = (BlockRedstoneWire) Blocks.REDSTONE_WIRE; net.minecraft.server.World world = this.world.getMinecraftWorld(); int x = getX(); int y = getY(); int z = getZ(); - if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = wire.getPower(power, world.getType(new BlockPosition(x, y - 1, z))); - if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = wire.getPower(power, world.getType(new BlockPosition(x, y + 1, z))); - if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = wire.getPower(power, world.getType(new BlockPosition(x + 1, y, z))); - if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = wire.getPower(power, world.getType(new BlockPosition(x - 1, y, z))); - if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = wire.getPower(power, world.getType(new BlockPosition(x, y, z - 1))); - if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = wire.getPower(power, world.getType(new BlockPosition(x, y, z + 1))); + if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = getPower(power, world.getType(new BlockPosition(x, y - 1, z))); + if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = getPower(power, world.getType(new BlockPosition(x, y + 1, z))); + if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = getPower(power, world.getType(new BlockPosition(x + 1, y, z))); + if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = getPower(power, world.getType(new BlockPosition(x - 1, y, z))); + if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = getPower(power, world.getType(new BlockPosition(x, y, z - 1))); + if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = getPower(power, world.getType(new BlockPosition(x, y, z + 1))); return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0; } + private static int getPower(int i, IBlockData iblockdata) { + if (!iblockdata.getBlock().a(Blocks.REDSTONE_WIRE)) { + return i; + } else { + int j = iblockdata.get(BlockRedstoneWire.POWER); + + return j > i ? j : i; + } + } + @Override public int getBlockPower() { return getBlockPower(BlockFace.SELF); @@ -599,7 +608,7 @@ public class CraftBlock implements Block { boolean result = false; // Modelled off EntityHuman#hasBlock - if (block != Blocks.AIR && (item == null || iblockdata.getMaterial().isAlwaysDestroyable() || nmsItem.canDestroySpecialBlock(iblockdata))) { + if (block != Blocks.AIR && (item == null || iblockdata.isAlwaysDestroyable() || nmsItem.canDestroySpecialBlock(iblockdata))) { net.minecraft.server.Block.dropItems(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), null, nmsItem); result = true; } @@ -623,7 +632,7 @@ public class CraftBlock implements Block { net.minecraft.server.ItemStack nms = CraftItemStack.asNMSCopy(item); // Modelled off EntityHuman#hasBlock - if (item == null || iblockdata.getMaterial().isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) { + if (item == null || iblockdata.isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) { return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms) .stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); } else { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index 2831419446..da5a80267b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -48,7 +48,7 @@ public class CraftBlockEntityState extends CraftBlockState } NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound()); - T snapshot = (T) TileEntity.create(nbtTagCompound); + T snapshot = (T) TileEntity.create(getHandle(), nbtTagCompound); return snapshot; } @@ -57,7 +57,7 @@ public class CraftBlockEntityState extends CraftBlockState private void copyData(T from, T to) { BlockPosition pos = to.getPosition(); NBTTagCompound nbtTagCompound = from.save(new NBTTagCompound()); - to.load(nbtTagCompound); + to.load(getHandle(), nbtTagCompound); // reset the original position: to.setPosition(pos); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 683b17a0c9..c7eed6b572 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -13,12 +13,12 @@ import java.util.Set; import java.util.stream.Collectors; import net.minecraft.server.ArgumentBlock; import net.minecraft.server.Block; -import net.minecraft.server.BlockDataAbstract; import net.minecraft.server.BlockStateBoolean; import net.minecraft.server.BlockStateEnum; import net.minecraft.server.BlockStateInteger; import net.minecraft.server.EnumDirection; import net.minecraft.server.IBlockData; +import net.minecraft.server.IBlockDataHolder; import net.minecraft.server.IBlockState; import net.minecraft.server.INamable; import net.minecraft.server.IRegistry; @@ -93,7 +93,7 @@ public class CraftBlockData implements BlockData { */ protected , N extends Enum & INamable> void set(BlockStateEnum nms, Enum bukkit) { this.parsedStates = null; - this.state = this.state.set(nms, toNMS(bukkit, nms.b())); + this.state = this.state.set(nms, toNMS(bukkit, nms.getType())); } @Override @@ -241,7 +241,7 @@ public class CraftBlockData implements BlockData { @Override public String getAsString() { - return toString(((BlockDataAbstract) state).getStateMap()); + return toString(state.getStateMap()); } @Override @@ -269,7 +269,7 @@ public class CraftBlockData implements BlockData { if (!states.isEmpty()) { stateString.append('['); - stateString.append(states.entrySet().stream().map(BlockDataAbstract.STATE_TO_VALUE).collect(Collectors.joining(","))); + stateString.append(states.entrySet().stream().map(IBlockDataHolder.STATE_TO_VALUE).collect(Collectors.joining(","))); stateString.append(']'); } @@ -282,7 +282,7 @@ public class CraftBlockData implements BlockData { for (Map.Entry, Comparable> entry : state.getStateMap().entrySet()) { IBlockState iblockstate = (IBlockState) entry.getKey(); - compound.setString(iblockstate.a(), iblockstate.a(entry.getValue())); + compound.setString(iblockstate.getName(), iblockstate.a(entry.getValue())); } return compound; @@ -403,6 +403,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockCampfire.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new); register(net.minecraft.server.BlockCarrots.class, org.bukkit.craftbukkit.block.impl.CraftCarrots::new); register(net.minecraft.server.BlockCauldron.class, org.bukkit.craftbukkit.block.impl.CraftCauldron::new); + register(net.minecraft.server.BlockChain.class, org.bukkit.craftbukkit.block.impl.CraftChain::new); register(net.minecraft.server.BlockChest.class, org.bukkit.craftbukkit.block.impl.CraftChest::new); register(net.minecraft.server.BlockChestTrapped.class, org.bukkit.craftbukkit.block.impl.CraftChestTrapped::new); register(net.minecraft.server.BlockChorusFlower.class, org.bukkit.craftbukkit.block.impl.CraftChorusFlower::new); @@ -449,7 +450,6 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::new); register(net.minecraft.server.BlockLectern.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new); register(net.minecraft.server.BlockLever.class, org.bukkit.craftbukkit.block.impl.CraftLever::new); - register(net.minecraft.server.BlockLogAbstract.class, org.bukkit.craftbukkit.block.impl.CraftLogAbstract::new); register(net.minecraft.server.BlockLoom.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new); register(net.minecraft.server.BlockMinecartDetector.class, org.bukkit.craftbukkit.block.impl.CraftMinecartDetector::new); register(net.minecraft.server.BlockMinecartTrack.class, org.bukkit.craftbukkit.block.impl.CraftMinecartTrack::new); @@ -474,6 +474,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockRedstoneWire.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneWire::new); register(net.minecraft.server.BlockReed.class, org.bukkit.craftbukkit.block.impl.CraftReed::new); register(net.minecraft.server.BlockRepeater.class, org.bukkit.craftbukkit.block.impl.CraftRepeater::new); + register(net.minecraft.server.BlockRespawnAnchor.class, org.bukkit.craftbukkit.block.impl.CraftRespawnAnchor::new); register(net.minecraft.server.BlockRotatable.class, org.bukkit.craftbukkit.block.impl.CraftRotatable::new); register(net.minecraft.server.BlockSapling.class, org.bukkit.craftbukkit.block.impl.CraftSapling::new); register(net.minecraft.server.BlockScaffolding.class, org.bukkit.craftbukkit.block.impl.CraftScaffolding::new); @@ -499,13 +500,16 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockTallPlant.class, org.bukkit.craftbukkit.block.impl.CraftTallPlant::new); register(net.minecraft.server.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower::new); register(net.minecraft.server.BlockTallSeaGrass.class, org.bukkit.craftbukkit.block.impl.CraftTallSeaGrass::new); + register(net.minecraft.server.BlockTarget.class, org.bukkit.craftbukkit.block.impl.CraftTarget::new); register(net.minecraft.server.BlockTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall::new); register(net.minecraft.server.BlockTrapdoor.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor::new); register(net.minecraft.server.BlockTripwire.class, org.bukkit.craftbukkit.block.impl.CraftTripwire::new); register(net.minecraft.server.BlockTripwireHook.class, org.bukkit.craftbukkit.block.impl.CraftTripwireHook::new); register(net.minecraft.server.BlockTurtleEgg.class, org.bukkit.craftbukkit.block.impl.CraftTurtleEgg::new); + register(net.minecraft.server.BlockTwistingVines.class, org.bukkit.craftbukkit.block.impl.CraftTwistingVines::new); register(net.minecraft.server.BlockVine.class, org.bukkit.craftbukkit.block.impl.CraftVine::new); register(net.minecraft.server.BlockWallSign.class, org.bukkit.craftbukkit.block.impl.CraftWallSign::new); + register(net.minecraft.server.BlockWeepingVines.class, org.bukkit.craftbukkit.block.impl.CraftWeepingVines::new); register(net.minecraft.server.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull::new); register(net.minecraft.server.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall::new); register(net.minecraft.server.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton::new); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJigsaw.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJigsaw.java new file mode 100644 index 0000000000..3ed9e82171 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJigsaw.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Jigsaw; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftJigsaw extends CraftBlockData implements Jigsaw { + + private static final net.minecraft.server.BlockStateEnum ORIENTATION = getEnum("orientation"); + + @Override + public Orientation getOrientation() { + return get(ORIENTATION, Orientation.class); + } + + @Override + public void setOrientation(Orientation orientation) { + set(ORIENTATION, orientation); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRespawnAnchor.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRespawnAnchor.java new file mode 100644 index 0000000000..b75d993f8e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRespawnAnchor.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.RespawnAnchor; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftRespawnAnchor extends CraftBlockData implements RespawnAnchor { + + private static final net.minecraft.server.BlockStateInteger CHARGES = getInteger("charges"); + + @Override + public int getCharges() { + return get(CHARGES); + } + + @Override + public void setCharges(int charges) { + set(CHARGES, charges); + } + + @Override + public int getMaximumCharges() { + return getMax(CHARGES); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftWall.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftWall.java new file mode 100644 index 0000000000..2d2242b84d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftWall.java @@ -0,0 +1,21 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Wall; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftWall extends CraftBlockData implements Wall { + + private static final net.minecraft.server.BlockStateEnum[] HEIGHTS = new net.minecraft.server.BlockStateEnum[]{ + getEnum("north"), getEnum("east"), getEnum("south"), getEnum("west") + }; + + @Override + public Height getHeight(org.bukkit.block.BlockFace face) { + return get(HEIGHTS[face.ordinal()], Height.class); + } + + @Override + public void setHeight(org.bukkit.block.BlockFace face, Height height) { + set(HEIGHTS[face.ordinal()], height); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java new file mode 100644 index 0000000000..c75cc95e62 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftChain extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged { + + public CraftChain() { + super(); + } + + public CraftChain(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockChain.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java index f77b551286..94e9840c53 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftCobbleWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Fence, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged { +public final class CraftCobbleWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Wall, org.bukkit.block.data.Waterlogged { public CraftCobbleWall() { super(); @@ -13,54 +13,20 @@ public final class CraftCobbleWall extends org.bukkit.craftbukkit.block.data.Cra super(state); } - // org.bukkit.craftbukkit.block.data.CraftMultipleFacing + // org.bukkit.craftbukkit.block.data.type.CraftWall - private static final net.minecraft.server.BlockStateBoolean[] FACES = new net.minecraft.server.BlockStateBoolean[]{ - getBoolean(net.minecraft.server.BlockCobbleWall.class, "north", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "east", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "south", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "west", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "up", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "down", true) + private static final net.minecraft.server.BlockStateEnum[] HEIGHTS = new net.minecraft.server.BlockStateEnum[]{ + getEnum(net.minecraft.server.BlockCobbleWall.class, "north"), getEnum(net.minecraft.server.BlockCobbleWall.class, "east"), getEnum(net.minecraft.server.BlockCobbleWall.class, "south"), getEnum(net.minecraft.server.BlockCobbleWall.class, "west") }; @Override - public boolean hasFace(org.bukkit.block.BlockFace face) { - net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; - if (state == null) { - throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); - } - return get(state); + public Height getHeight(org.bukkit.block.BlockFace face) { + return get(HEIGHTS[face.ordinal()], Height.class); } @Override - public void setFace(org.bukkit.block.BlockFace face, boolean has) { - net.minecraft.server.BlockStateBoolean state = FACES[face.ordinal()]; - if (state == null) { - throw new IllegalArgumentException("Non-allowed face " + face + ". Check MultipleFacing.getAllowedFaces."); - } - set(state, has); - } - - @Override - public java.util.Set getFaces() { - com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); - - for (int i = 0; i < FACES.length; i++) { - if (FACES[i] != null && get(FACES[i])) { - faces.add(org.bukkit.block.BlockFace.values()[i]); - } - } - - return faces.build(); - } - - @Override - public java.util.Set getAllowedFaces() { - com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); - - for (int i = 0; i < FACES.length; i++) { - if (FACES[i] != null) { - faces.add(org.bukkit.block.BlockFace.values()[i]); - } - } - - return faces.build(); + public void setHeight(org.bukkit.block.BlockFace face, Height height) { + set(HEIGHTS[face.ordinal()], height); } // org.bukkit.craftbukkit.block.data.CraftWaterlogged diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java index 10f0094b7f..8699ca52bf 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftJigsaw extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { +public final class CraftJigsaw extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Jigsaw { public CraftJigsaw() { super(); @@ -13,22 +13,17 @@ public final class CraftJigsaw extends org.bukkit.craftbukkit.block.data.CraftBl super(state); } - // org.bukkit.craftbukkit.block.data.CraftDirectional + // org.bukkit.craftbukkit.block.data.type.CraftJigsaw - private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockJigsaw.class, "facing"); + private static final net.minecraft.server.BlockStateEnum ORIENTATION = getEnum(net.minecraft.server.BlockJigsaw.class, "orientation"); @Override - public org.bukkit.block.BlockFace getFacing() { - return get(FACING, org.bukkit.block.BlockFace.class); + public Orientation getOrientation() { + return get(ORIENTATION, Orientation.class); } @Override - public void setFacing(org.bukkit.block.BlockFace facing) { - set(FACING, facing); - } - - @Override - public java.util.Set getFaces() { - return getValues(FACING, org.bukkit.block.BlockFace.class); + public void setOrientation(Orientation orientation) { + set(ORIENTATION, orientation); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLogAbstract.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLogAbstract.java deleted file mode 100644 index efa4049023..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLogAbstract.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Automatically generated file, changes will be lost. - */ -package org.bukkit.craftbukkit.block.impl; - -public final class CraftLogAbstract extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Orientable { - - public CraftLogAbstract() { - super(); - } - - public CraftLogAbstract(net.minecraft.server.IBlockData state) { - super(state); - } - - // org.bukkit.craftbukkit.block.data.CraftOrientable - - private static final net.minecraft.server.BlockStateEnum AXIS = getEnum(net.minecraft.server.BlockLogAbstract.class, "axis"); - - @Override - public org.bukkit.Axis getAxis() { - return get(AXIS, org.bukkit.Axis.class); - } - - @Override - public void setAxis(org.bukkit.Axis axis) { - set(AXIS, axis); - } - - @Override - public java.util.Set getAxes() { - return getValues(AXIS, org.bukkit.Axis.class); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java new file mode 100644 index 0000000000..4a3e388640 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRespawnAnchor extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RespawnAnchor { + + public CraftRespawnAnchor() { + super(); + } + + public CraftRespawnAnchor(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftRespawnAnchor + + private static final net.minecraft.server.BlockStateInteger CHARGES = getInteger(net.minecraft.server.BlockRespawnAnchor.class, "charges"); + + @Override + public int getCharges() { + return get(CHARGES); + } + + @Override + public void setCharges(int charges) { + set(CHARGES, charges); + } + + @Override + public int getMaximumCharges() { + return getMax(CHARGES); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java new file mode 100644 index 0000000000..4d1ba198ab --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTarget extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.AnaloguePowerable { + + public CraftTarget() { + super(); + } + + public CraftTarget(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAnaloguePowerable + + private static final net.minecraft.server.BlockStateInteger POWER = getInteger(net.minecraft.server.BlockTarget.class, "power"); + + @Override + public int getPower() { + return get(POWER); + } + + @Override + public void setPower(int power) { + set(POWER, power); + } + + @Override + public int getMaximumPower() { + return getMax(POWER); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java new file mode 100644 index 0000000000..3d63dd4373 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTwistingVines extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftTwistingVines() { + super(); + } + + public CraftTwistingVines(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAgeable + + private static final net.minecraft.server.BlockStateInteger AGE = getInteger(net.minecraft.server.BlockTwistingVines.class, "age"); + + @Override + public int getAge() { + return get(AGE); + } + + @Override + public void setAge(int age) { + set(AGE, age); + } + + @Override + public int getMaximumAge() { + return getMax(AGE); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java new file mode 100644 index 0000000000..c217b27e50 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWeepingVines extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftWeepingVines() { + super(); + } + + public CraftWeepingVines(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAgeable + + private static final net.minecraft.server.BlockStateInteger AGE = getInteger(net.minecraft.server.BlockWeepingVines.class, "age"); + + @Override + public int getAge() { + return get(AGE); + } + + @Override + public void setAge(int age) { + set(AGE, age); + } + + @Override + public int getMaximumAge() { + return getMax(AGE); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java index 2ec656dcc8..83a12e4776 100644 --- a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java +++ b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java @@ -19,7 +19,7 @@ public class CraftDragonBattle implements DragonBattle { @Override public EnderDragon getEnderDragon() { - Entity entity = handle.d.getEntity(handle.m); + Entity entity = handle.world.getEntity(handle.dragonUUID); return (entity != null) ? (EnderDragon) entity.getBukkitEntity() : null; } @@ -30,39 +30,39 @@ public class CraftDragonBattle implements DragonBattle { @Override public Location getEndPortalLocation() { - return new Location(handle.d.getWorld(), handle.o.getX(), handle.o.getY(), handle.o.getZ()); + return new Location(handle.world.getWorld(), handle.exitPortalLocation.getX(), handle.exitPortalLocation.getY(), handle.exitPortalLocation.getZ()); } @Override public boolean hasBeenPreviouslyKilled() { - return handle.d(); // PAIL rename hasBeenPreviouslyKilled + return handle.isPreviouslyKilled(); } @Override public void initiateRespawn() { - this.handle.e(); // PAIL rename initiateRespawn + this.handle.initiateRespawn(); } @Override public RespawnPhase getRespawnPhase() { - return toBukkitRespawnPhase(handle.p); + return toBukkitRespawnPhase(handle.respawnPhase); } @Override public boolean setRespawnPhase(RespawnPhase phase) { Preconditions.checkArgument(phase != null && phase != RespawnPhase.NONE, "Invalid respawn phase provided: %s", phase); - if (handle.p == null) { + if (handle.respawnPhase == null) { return false; } - this.handle.a(toNMSRespawnPhase(phase)); + this.handle.setRespawnPhase(toNMSRespawnPhase(phase)); return true; } @Override public void resetCrystals() { - this.handle.f(); // PAIL rename resetCrystals + this.handle.resetCrystals(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java index e0bd5adc19..fefb09f27d 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java @@ -50,7 +50,7 @@ public class ColouredConsoleSender extends CraftConsoleCommandSender { // support jansi passthrough VM option when jansi doesn't detect an ANSI supported terminal if (jansiPassthrough || terminal.isAnsiSupported()) { if (!conversationTracker.isConversingModaly()) { - String result = message; + String result = message.replaceAll("(?i)" + ChatColor.COLOR_CHAR + "x(" + ChatColor.COLOR_CHAR + "[0-9a-f]){6}", ""); // Hex is not supported by ANSI console for (ChatColor color : colors) { if (replacements.containsKey(color)) { result = result.replaceAll("(?i)" + color.toString(), replacements.get(color)); diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java index 5beb2ad621..17aa866252 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.command; import net.minecraft.server.CommandListenerWrapper; import net.minecraft.server.IChatBaseComponent; +import net.minecraft.server.SystemUtils; import net.minecraft.server.TileEntity; import org.bukkit.block.Block; import org.bukkit.command.BlockCommandSender; @@ -29,7 +30,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc @Override public void sendMessage(String message) { for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - block.base.sendMessage(component); + block.base.sendMessage(component, SystemUtils.b); } } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java index 228e88a6e2..655bdbc37d 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.command; import net.minecraft.server.ChatComponentText; import net.minecraft.server.RemoteControlCommandListener; +import net.minecraft.server.SystemUtils; import org.bukkit.command.RemoteConsoleCommandSender; public class CraftRemoteConsoleCommandSender extends ServerCommandSender implements RemoteConsoleCommandSender { @@ -14,7 +15,7 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme @Override public void sendMessage(String message) { - listener.sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting. + listener.sendMessage(new ChatComponentText(message + "\n"), SystemUtils.b); // Send a newline after each message, to preserve formatting. } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 64ceeda1af..34ceee4a81 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -31,8 +31,6 @@ public class CraftEnchantment extends Enchantment { @Override public EnchantmentTarget getItemTarget() { switch (target.itemTarget) { - case ALL: - return EnchantmentTarget.ALL; case ARMOR: return EnchantmentTarget.ARMOR; case ARMOR_FEET: @@ -59,6 +57,8 @@ public class CraftEnchantment extends Enchantment { return EnchantmentTarget.TRIDENT; case CROSSBOW: return EnchantmentTarget.CROSSBOW; + case VANISHABLE: + return EnchantmentTarget.VANISHABLE; default: return null; } @@ -106,56 +106,58 @@ public class CraftEnchantment extends Enchantment { case 10: return "BINDING_CURSE"; case 11: - return "DAMAGE_ALL"; + return "SOUL_SPEED"; case 12: - return "DAMAGE_UNDEAD"; + return "DAMAGE_ALL"; case 13: - return "DAMAGE_ARTHROPODS"; + return "DAMAGE_UNDEAD"; case 14: - return "KNOCKBACK"; + return "DAMAGE_ARTHROPODS"; case 15: - return "FIRE_ASPECT"; + return "KNOCKBACK"; case 16: - return "LOOT_BONUS_MOBS"; + return "FIRE_ASPECT"; case 17: - return "SWEEPING_EDGE"; + return "LOOT_BONUS_MOBS"; case 18: - return "DIG_SPEED"; + return "SWEEPING_EDGE"; case 19: - return "SILK_TOUCH"; + return "DIG_SPEED"; case 20: - return "DURABILITY"; + return "SILK_TOUCH"; case 21: - return "LOOT_BONUS_BLOCKS"; + return "DURABILITY"; case 22: - return "ARROW_DAMAGE"; + return "LOOT_BONUS_BLOCKS"; case 23: - return "ARROW_KNOCKBACK"; + return "ARROW_DAMAGE"; case 24: - return "ARROW_FIRE"; + return "ARROW_KNOCKBACK"; case 25: - return "ARROW_INFINITE"; + return "ARROW_FIRE"; case 26: - return "LUCK"; + return "ARROW_INFINITE"; case 27: - return "LURE"; + return "LUCK"; case 28: - return "LOYALTY"; + return "LURE"; case 29: - return "IMPALING"; + return "LOYALTY"; case 30: - return "RIPTIDE"; + return "IMPALING"; case 31: - return "CHANNELING"; + return "RIPTIDE"; case 32: - return "MULTISHOT"; + return "CHANNELING"; case 33: - return "QUICK_CHARGE"; + return "MULTISHOT"; case 34: - return "PIERCING"; + return "QUICK_CHARGE"; case 35: - return "MENDING"; + return "PIERCING"; case 36: + return "MENDING"; + case 37: return "VANISHING_CURSE"; default: return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.a(target); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 09016e3547..339656c623 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -1,8 +1,8 @@ package org.bukkit.craftbukkit.entity; import java.util.UUID; -import net.minecraft.server.EntityHorse; import net.minecraft.server.EntityHorseAbstract; +import net.minecraft.server.GenericAttributes; import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventoryAbstractHorse; @@ -58,7 +58,7 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac @Override public void setJumpStrength(double strength) { Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero"); - getHandle().getAttributeInstance(EntityHorse.attributeJumpStrength).setValue(strength); + getHandle().getAttributeInstance(GenericAttributes.JUMP_STRENGTH).setValue(strength); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 228e1327ca..cf40d62492 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -112,12 +112,12 @@ public class CraftArrow extends AbstractProjectile implements AbstractArrow { @Override public boolean isShotFromCrossbow() { - return getHandle().r(); + return getHandle().isShotFromCrossbow(); } @Override public void setShotFromCrossbow(boolean shotFromCrossbow) { - getHandle().o(shotFromCrossbow); + getHandle().setShotFromCrossbow(shotFromCrossbow); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java index 779f34ad02..e8eb5f9f26 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java @@ -76,6 +76,6 @@ public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderD @Override public int getDeathAnimationTicks() { - return getHandle().bA; // PAIL rename deathAnimationTicks + return getHandle().deathAnimationTicks; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 30bcfae653..c61fc26a92 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -53,6 +53,7 @@ import net.minecraft.server.EntityGolem; import net.minecraft.server.EntityGuardian; import net.minecraft.server.EntityGuardianElder; import net.minecraft.server.EntityHanging; +import net.minecraft.server.EntityHoglin; import net.minecraft.server.EntityHorse; import net.minecraft.server.EntityHorseAbstract; import net.minecraft.server.EntityHorseChestedAbstract; @@ -92,6 +93,7 @@ import net.minecraft.server.EntityParrot; import net.minecraft.server.EntityPhantom; import net.minecraft.server.EntityPig; import net.minecraft.server.EntityPigZombie; +import net.minecraft.server.EntityPiglin; import net.minecraft.server.EntityPillager; import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPolarBear; @@ -115,6 +117,7 @@ import net.minecraft.server.EntitySnowman; import net.minecraft.server.EntitySpectralArrow; import net.minecraft.server.EntitySpider; import net.minecraft.server.EntitySquid; +import net.minecraft.server.EntityStrider; import net.minecraft.server.EntityTNTPrimed; import net.minecraft.server.EntityTameableAnimal; import net.minecraft.server.EntityThrownExpBottle; @@ -132,6 +135,7 @@ import net.minecraft.server.EntityWitch; import net.minecraft.server.EntityWither; import net.minecraft.server.EntityWitherSkull; import net.minecraft.server.EntityWolf; +import net.minecraft.server.EntityZoglin; import net.minecraft.server.EntityZombie; import net.minecraft.server.EntityZombieHusk; import net.minecraft.server.EntityZombieVillager; @@ -234,6 +238,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityPanda) { return new CraftPanda(server, (EntityPanda) entity); } else if (entity instanceof EntityFox) { return new CraftFox(server, (EntityFox) entity); } else if (entity instanceof EntityBee) { return new CraftBee(server, (EntityBee) entity); } + else if (entity instanceof EntityHoglin) { return new CraftHoglin(server, (EntityHoglin) entity); } + else if (entity instanceof EntityStrider) { return new CraftStrider(server, (EntityStrider) entity); } else { return new CraftAnimals(server, (EntityAnimal) entity); } } // Monsters @@ -278,6 +284,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftIllager(server, (EntityIllagerAbstract) entity); } } else if (entity instanceof EntityRavager) { return new CraftRavager(server, (EntityRavager) entity); } + else if (entity instanceof EntityPiglin) { return new CraftPiglin(server, (EntityPiglin) entity); } + else if (entity instanceof EntityZoglin) { return new CraftZoglin(server, (EntityZoglin) entity); } else { return new CraftMonster(server, (EntityMonster) entity); } } @@ -426,7 +434,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntityArrow) { return ((EntityArrow) entity).inGround; } - return entity.onGround; + return entity.isOnGround(); } @Override @@ -468,7 +476,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // Let the server handle cross world teleports if (!location.getWorld().equals(getWorld())) { - entity.teleportTo(((CraftWorld) location.getWorld()).getHandle().getWorldProvider().getDimensionManager(), new BlockPosition(location.getX(), location.getY(), location.getZ())); + entity.teleportTo(((CraftWorld) location.getWorld()).getHandle(), new BlockPosition(location.getX(), location.getY(), location.getZ())); return true; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 0cff2145fc..97fdf35603 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -42,9 +42,9 @@ public class CraftFireball extends AbstractProjectile implements Fireball { @Override public void setShooter(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { - getHandle().shooter = ((CraftLivingEntity) shooter).getHandle(); + getHandle().setShooter(((CraftLivingEntity) shooter).getHandle()); } else { - getHandle().shooter = null; + getHandle().setShooter(null); } getHandle().projectileSource = shooter; } @@ -57,13 +57,7 @@ public class CraftFireball extends AbstractProjectile implements Fireball { @Override public void setDirection(Vector direction) { Validate.notNull(direction, "Direction can not be null"); - double x = direction.getX(); - double y = direction.getY(); - double z = direction.getZ(); - double magnitude = (double) MathHelper.sqrt(x * x + y * y + z * z); - getHandle().dirX = x / magnitude * 0.1D; - getHandle().dirY = y / magnitude * 0.1D; - getHandle().dirZ = z / magnitude * 0.1D; + getHandle().setDirection(direction.getX(), direction.getY(), direction.getZ()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 475b7b004b..d984a7a78e 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -11,7 +11,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.inventory.meta.FireworkMeta; -public class CraftFirework extends CraftEntity implements Firework { +public class CraftFirework extends CraftProjectile implements Firework { private final Random random = new Random(); private final CraftItemStack item; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java index 257ce11664..5916507121 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java @@ -2,37 +2,19 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.BlockPosition; import net.minecraft.server.EntityFishingHook; -import net.minecraft.server.EntityHuman; import net.minecraft.server.MathHelper; import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.FishHook; -import org.bukkit.projectiles.ProjectileSource; -public class CraftFishHook extends AbstractProjectile implements FishHook { +public class CraftFishHook extends CraftProjectile implements FishHook { private double biteChance = -1; public CraftFishHook(CraftServer server, EntityFishingHook entity) { super(server, entity); } - @Override - public ProjectileSource getShooter() { - if (getHandle().owner != null) { - return getHandle().owner.getBukkitEntity(); - } - - return null; - } - - @Override - public void setShooter(ProjectileSource shooter) { - if (shooter instanceof CraftHumanEntity) { - getHandle().owner = (EntityHuman) ((CraftHumanEntity) shooter).entity; - } - } - @Override public EntityFishingHook getHandle() { return (EntityFishingHook) entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java new file mode 100644 index 0000000000..41bbdb2715 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityHoglin; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Hoglin; + +public class CraftHoglin extends CraftAnimals implements Hoglin { + + public CraftHoglin(CraftServer server, EntityHoglin entity) { + super(server, entity); + } + + @Override + public EntityHoglin getHandle() { + return (EntityHoglin) entity; + } + + @Override + public String toString() { + return "CraftHoglin"; + } + + @Override + public EntityType getType() { + return EntityType.HOGLIN; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index 98ef44c302..74396af5d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -1,6 +1,8 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityHorse; +import net.minecraft.server.HorseColor; +import net.minecraft.server.HorseStyle; import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventoryHorse; @@ -26,24 +28,24 @@ public class CraftHorse extends CraftAbstractHorse implements Horse { @Override public Color getColor() { - return Color.values()[getHandle().getVariant() & 0xFF]; + return Color.values()[getHandle().getColor().a()]; } @Override public void setColor(Color color) { Validate.notNull(color, "Color cannot be null"); - getHandle().setVariant(color.ordinal() & 0xFF | getStyle().ordinal() << 8); + getHandle().setVariant(HorseColor.a(color.ordinal()), getHandle().getStyle()); } @Override public Style getStyle() { - return Style.values()[getHandle().getVariant() >>> 8]; + return Style.values()[getHandle().getStyle().a()]; } @Override public void setStyle(Style style) { Validate.notNull(style, "Style cannot be null"); - getHandle().setVariant(getColor().ordinal() & 0xFF | style.ordinal() << 8); + getHandle().setVariant(getHandle().getColor(), HorseStyle.a(style.ordinal())); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 2c20a7b924..9e0bd99122 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -31,15 +31,12 @@ import net.minecraft.server.PacketPlayInCloseWindow; import net.minecraft.server.PacketPlayOutOpenWindow; import net.minecraft.server.TileEntity; import net.minecraft.server.TileEntityContainer; -import net.minecraft.server.Vec3D; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftContainer; import org.bukkit.craftbukkit.inventory.CraftInventory; @@ -128,36 +125,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return getHandle().sleepTicks; } - @Override - public Location getBedSpawnLocation() { - World world = getServer().getWorld(getHandle().spawnWorld); - BlockPosition bed = getHandle().getBed(); - - if (world != null && bed != null) { - Optional spawnLoc = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isRespawnForced()); - if (spawnLoc.isPresent()) { - Vec3D vec = spawnLoc.get(); - return new Location(world, vec.x, vec.y, vec.z); - } - } - return null; - } - - @Override - public void setBedSpawnLocation(Location location) { - setBedSpawnLocation(location, false); - } - - @Override - public void setBedSpawnLocation(Location location, boolean override) { - if (location == null) { - getHandle().setRespawnPosition(null, override, false); - } else { - getHandle().setRespawnPosition(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override, false); - getHandle().spawnWorld = location.getWorld().getName(); - } - } - @Override public boolean sleep(Location location, boolean force) { Preconditions.checkArgument(location != null, "Location cannot be null"); @@ -192,7 +159,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public Location getBedLocation() { Preconditions.checkState(isSleeping(), "Not sleeping"); - BlockPosition bed = getHandle().getBed(); + BlockPosition bed = getHandle().getBedPosition().get(); return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ()); } @@ -492,7 +459,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public float getAttackCooldown() { - return getHandle().s(0.5f); + return getHandle().getAttackCooldown(0.5f); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java index cb1efe9694..6c05cb414a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java @@ -12,7 +12,7 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike @Override public boolean isEffect() { - return ((EntityLightning) super.getHandle()).isEffect; + return getHandle().isEffect; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 6146db1841..ac29dd3394 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -428,7 +428,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { launch = EntityTypes.LLAMA_SPIT.a(world); - ((EntityLlamaSpit) launch).shooter = getHandle(); + ((EntityLlamaSpit) launch).setShooter(getHandle()); ((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F); // EntityLlama launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); } else if (ShulkerBullet.class.isAssignableFrom(projectile)) { @@ -588,17 +588,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void attack(Entity target) { Preconditions.checkArgument(target != null, "target == null"); - getHandle().B(((CraftEntity) target).getHandle()); // PAIL rename attack + getHandle().attackEntity(((CraftEntity) target).getHandle()); } @Override public void swingMainHand() { - getHandle().a(EnumHand.MAIN_HAND, true); // PAIL rename swingHand + getHandle().swingHand(EnumHand.MAIN_HAND, true); } @Override public void swingOffHand() { - getHandle().a(EnumHand.OFF_HAND, true); // PAIL rename swingHand + getHandle().swingHand(EnumHand.OFF_HAND, true); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java index 68d10c23a6..4fec54bac2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java @@ -29,11 +29,11 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit { @Override public ProjectileSource getShooter() { - return (getHandle().shooter != null) ? (ProjectileSource) getHandle().shooter.getBukkitEntity() : null; + return (getHandle().getShooter() != null) ? (ProjectileSource) getHandle().getShooter().getBukkitEntity() : null; } @Override public void setShooter(ProjectileSource source) { - getHandle().shooter = (source != null) ? ((CraftLivingEntity) source).getHandle() : null; + getHandle().setShooter((source != null) ? ((CraftLivingEntity) source).getHandle() : null); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index 85fee3f21e..a426856318 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -17,7 +17,7 @@ public class CraftPig extends CraftAnimals implements Pig { @Override public void setSaddle(boolean saddled) { - getHandle().setSaddle(saddled); + getHandle().saddleStorage.setSaddle(saddled); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java index 10c12ef5a6..1af3afdaf1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java @@ -13,12 +13,12 @@ public class CraftPigZombie extends CraftZombie implements PigZombie { @Override public int getAnger() { - return getHandle().angerLevel; + return getHandle().getAnger(); } @Override public void setAnger(int level) { - getHandle().angerLevel = level; + getHandle().setAnger(level); } @Override @@ -43,7 +43,7 @@ public class CraftPigZombie extends CraftZombie implements PigZombie { @Override public EntityType getType() { - return EntityType.PIG_ZOMBIE; + return EntityType.ZOMBIFIED_PIGLIN; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java new file mode 100644 index 0000000000..41ba2d89aa --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityPiglin; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Piglin; + +public class CraftPiglin extends CraftMonster implements Piglin { + + public CraftPiglin(CraftServer server, EntityPiglin entity) { + super(server, entity); + } + + @Override + public EntityPiglin getHandle() { + return (EntityPiglin) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.PIGLIN; + } + + @Override + public String toString() { + return "CraftPiglin"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index c17c125a09..27289d0cf2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -17,6 +17,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.WeakHashMap; @@ -25,18 +26,19 @@ import java.util.logging.Logger; import javax.annotation.Nullable; import net.minecraft.server.AdvancementDataPlayer; import net.minecraft.server.AdvancementProgress; -import net.minecraft.server.AttributeInstance; -import net.minecraft.server.AttributeMapServer; +import net.minecraft.server.AttributeMapBase; import net.minecraft.server.AttributeModifiable; -import net.minecraft.server.AttributeRanged; import net.minecraft.server.BlockPosition; import net.minecraft.server.ChatComponentText; +import net.minecraft.server.ChatMessageType; import net.minecraft.server.Container; import net.minecraft.server.Entity; +import net.minecraft.server.EntityHuman; import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityPlayer; import net.minecraft.server.EnumColor; import net.minecraft.server.EnumGamemode; +import net.minecraft.server.GenericAttributes; import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.MapIcon; import net.minecraft.server.MinecraftKey; @@ -60,6 +62,7 @@ import net.minecraft.server.PacketPlayOutWorldEvent; import net.minecraft.server.PacketPlayOutWorldParticles; import net.minecraft.server.PlayerChunkMap; import net.minecraft.server.PlayerConnection; +import net.minecraft.server.SystemUtils; import net.minecraft.server.TileEntitySign; import net.minecraft.server.Vec3D; import net.minecraft.server.WhiteListEntry; @@ -80,6 +83,7 @@ import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.Statistic; import org.bukkit.WeatherType; +import org.bukkit.World; import org.bukkit.block.data.BlockData; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.conversations.Conversation; @@ -189,7 +193,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().playerConnection == null) return; for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - getHandle().playerConnection.sendPacket(new PacketPlayOutChat(component)); + getHandle().playerConnection.sendPacket(new PacketPlayOutChat(component, ChatMessageType.CHAT, SystemUtils.b)); } } @@ -664,7 +668,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (fromWorld == toWorld) { entity.playerConnection.teleport(to); } else { - server.getHandle().moveToWorld(entity, toWorld.getWorldProvider().getDimensionManager(), true, to, true); + server.getHandle().moveToWorld(entity, toWorld, true, to, true); } return true; } @@ -716,6 +720,43 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return getHandle().fauxSleeping; } + @Override + public Location getBedSpawnLocation() { + World world = getHandle().server.getWorldServer(getHandle().getSpawnDimension()).getWorld(); + BlockPosition bed = getHandle().getSpawn(); + + if (world != null && bed != null) { + Optional spawnLoc = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isSpawnForced(), true); + if (spawnLoc.isPresent()) { + Vec3D vec = spawnLoc.get(); + return new Location(world, vec.x, vec.y, vec.z); + } + } + return null; + } + + @Override + public void setBedSpawnLocation(Location location) { + setBedSpawnLocation(location, false); + } + + @Override + public void setBedSpawnLocation(Location location, boolean override) { + if (location == null) { + getHandle().setRespawnPosition(null, null, override, false); + } else { + getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override, false); + } + } + + @Override + public Location getBedLocation() { + Preconditions.checkState(isSleeping(), "Not sleeping"); + + BlockPosition bed = getHandle().getSpawn(); + return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ()); + } + @Override public void incrementStatistic(Statistic statistic) { CraftStatistic.incrementStatistic(getHandle().getStatisticManager(), statistic); @@ -1457,8 +1498,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void updateScaledHealth(boolean sendHealth) { - AttributeMapServer attributemapserver = (AttributeMapServer) getHandle().getAttributeMap(); - Collection set = attributemapserver.c(); // PAIL: Rename + AttributeMapBase attributemapserver = getHandle().getAttributeMap(); + Collection set = attributemapserver.b(); // PAIL: Rename injectScaledMaxHealth(set, true); @@ -1478,17 +1519,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); } - public void injectScaledMaxHealth(Collection collection, boolean force) { + public void injectScaledMaxHealth(Collection collection, boolean force) { if (!scaledHealth && !force) { return; } - for (AttributeInstance genericInstance : collection) { - if (genericInstance.getAttribute().getName().equals("generic.maxHealth")) { - collection.remove(genericInstance); + for (AttributeModifiable genericInstance : collection) { + if (genericInstance.getAttribute() == GenericAttributes.MAX_HEALTH) { + genericInstance.setValue(scaledHealth ? healthScale : getMaxHealth()); break; } } - collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged(null, "generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true))); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index 649684fc86..f947a6e8c6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -1,13 +1,13 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityLiving; -import net.minecraft.server.EntityProjectile; +import net.minecraft.server.IProjectile; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Projectile; import org.bukkit.projectiles.ProjectileSource; public abstract class CraftProjectile extends AbstractProjectile implements Projectile { - public CraftProjectile(CraftServer server, net.minecraft.server.Entity entity) { + public CraftProjectile(CraftServer server, net.minecraft.server.IProjectile entity) { super(server, entity); } @@ -19,18 +19,16 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj @Override public void setShooter(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { - getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; - getHandle().shooterId = ((CraftLivingEntity) shooter).getUniqueId(); + getHandle().setShooter((EntityLiving) ((CraftLivingEntity) shooter).entity); } else { - getHandle().shooter = null; - getHandle().shooterId = null; + getHandle().setShooter(null); } getHandle().projectileSource = shooter; } @Override - public EntityProjectile getHandle() { - return (EntityProjectile) entity; + public IProjectile getHandle() { + return (IProjectile) entity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index a75d7a3039..7dcae39aae 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -41,8 +41,8 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { if (getRabbitType() == Type.THE_KILLER_BUNNY) { // Reset goals and target finders. World world = ((CraftWorld) this.getWorld()).getHandle(); - entity.goalSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null); - entity.targetSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null); + entity.goalSelector = new PathfinderGoalSelector(world.getMethodProfilerSupplier()); + entity.targetSelector = new PathfinderGoalSelector(world.getMethodProfilerSupplier()); entity.initializePathFinderGoals(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java index 8fbdedc86a..7dbd111d98 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java @@ -2,8 +2,8 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityShulkerBullet; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.ShulkerBullet; import org.bukkit.projectiles.ProjectileSource; @@ -20,8 +20,8 @@ public class CraftShulkerBullet extends AbstractProjectile implements ShulkerBul @Override public void setShooter(ProjectileSource shooter) { - if (shooter instanceof LivingEntity) { - getHandle().setShooter(((CraftLivingEntity) shooter).getHandle()); + if (shooter instanceof Entity) { + getHandle().setShooter(((CraftEntity) shooter).getHandle()); } else { getHandle().setShooter(null); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java index f5db1ed38e..082e7bda74 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSizedFireball.java @@ -15,16 +15,16 @@ public class CraftSizedFireball extends CraftFireball implements SizedFireball { @Override public ItemStack getDisplayItem() { - if (getHandle().l().isEmpty()) { // PAIL rename getItem + if (getHandle().getItem().isEmpty()) { return new ItemStack(Material.FIRE_CHARGE); } else { - return CraftItemStack.asBukkitCopy(getHandle().l()); // PAIL rename getItem + return CraftItemStack.asBukkitCopy(getHandle().getItem()); } } @Override public void setDisplayItem(ItemStack item) { - getHandle().b(CraftItemStack.asNMSCopy(item)); // PAIL rename setItem + getHandle().setItem(CraftItemStack.asNMSCopy(item)); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java new file mode 100644 index 0000000000..4dfbd62c63 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityStrider; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Strider; + +public class CraftStrider extends CraftAnimals implements Strider { + + public CraftStrider(CraftServer server, EntityStrider entity) { + super(server, entity); + } + + @Override + public EntityStrider getHandle() { + return (EntityStrider) entity; + } + + @Override + public String toString() { + return "CraftStrider"; + } + + @Override + public EntityType getType() { + return EntityType.STRIDER; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java index bff9854f30..58d9cd8172 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java @@ -74,7 +74,7 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat public void setSitting(boolean sitting) { getHandle().setSitting(sitting); - getHandle().getGoalSit().setSitting(sitting); + getHandle().setWillSit(sitting); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java index 4a6fce47be..0516f2e713 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrowableProjectile.java @@ -15,7 +15,7 @@ public abstract class CraftThrowableProjectile extends CraftProjectile implement @Override public ItemStack getItem() { if (getHandle().getItem().isEmpty()) { - return CraftItemStack.asBukkitCopy(new net.minecraft.server.ItemStack(getHandle().getDefaultItem())); + return CraftItemStack.asBukkitCopy(new net.minecraft.server.ItemStack(getHandle().getDefaultItemPublic())); } else { return CraftItemStack.asBukkitCopy(getHandle().getItem()); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index 80244fba3f..5f3314febb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -19,7 +19,11 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf { @Override public void setAngry(boolean angry) { - getHandle().setAngry(angry); + if (angry) { + getHandle().anger(); + } else { + getHandle().pacify(); + } } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java new file mode 100644 index 0000000000..bdfb5ef791 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityZoglin; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Zoglin; + +public class CraftZoglin extends CraftMonster implements Zoglin { + + public CraftZoglin(CraftServer server, EntityZoglin entity) { + super(server, entity); + } + + @Override + public EntityZoglin getHandle() { + return (EntityZoglin) entity; + } + + @Override + public String toString() { + return "CraftZoglin"; + } + + @Override + public EntityType getType() { + return EntityType.ZOGLIN; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java b/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java index e7eacfc74c..0616cdf196 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/memory/CraftMemoryMapper.java @@ -1,8 +1,8 @@ package org.bukkit.craftbukkit.entity.memory; +import java.util.UUID; import net.minecraft.server.BlockPosition; import net.minecraft.server.GlobalPos; -import net.minecraft.server.MinecraftSerializableLong; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; @@ -15,8 +15,12 @@ public final class CraftMemoryMapper { public static Object fromNms(Object object) { if (object instanceof GlobalPos) { return fromNms((GlobalPos) object); - } else if (object instanceof MinecraftSerializableLong) { - return ((MinecraftSerializableLong) object).a(); + } else if (object instanceof Long) { + return (Long) object; + } else if (object instanceof UUID) { + return (UUID) object; + } else if (object instanceof Boolean) { + return (Boolean) object; } throw new UnsupportedOperationException("Do not know how to map " + object); @@ -28,7 +32,11 @@ public final class CraftMemoryMapper { } else if (object instanceof Location) { return toNms((Location) object); } else if (object instanceof Long) { - return MinecraftSerializableLong.a((Long) object); + return (Long) object; + } else if (object instanceof UUID) { + return (UUID) object; + } else if (object instanceof Boolean) { + return (Boolean) object; } throw new UnsupportedOperationException("Do not know how to map " + object); @@ -39,6 +47,6 @@ public final class CraftMemoryMapper { } public static GlobalPos toNms(Location location) { - return GlobalPos.create(((CraftWorld) location.getWorld()).getHandle().getWorldProvider().getDimensionManager(), new BlockPosition(location.getX(), location.getY(), location.getZ())); + return GlobalPos.create(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getX(), location.getY(), location.getZ())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 2929cac69a..e60f5ca773 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -19,7 +19,6 @@ import net.minecraft.server.ChatModifier; import net.minecraft.server.Container; import net.minecraft.server.ContainerMerchant; import net.minecraft.server.DamageSource; -import net.minecraft.server.DimensionManager; import net.minecraft.server.Entity; import net.minecraft.server.EntityAnimal; import net.minecraft.server.EntityAreaEffectCloud; @@ -39,7 +38,6 @@ import net.minecraft.server.EntityMonster; import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPotion; import net.minecraft.server.EntityRaider; -import net.minecraft.server.EntitySheep; import net.minecraft.server.EntitySlime; import net.minecraft.server.EntityTypes; import net.minecraft.server.EntityVillager; @@ -68,6 +66,7 @@ import net.minecraft.server.PacketPlayInCloseWindow; import net.minecraft.server.Raid; import net.minecraft.server.Unit; import net.minecraft.server.World; +import net.minecraft.server.WorldServer; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -111,7 +110,6 @@ import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.Raider; -import org.bukkit.entity.Sheep; import org.bukkit.entity.ThrownExpBottle; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.Vehicle; @@ -218,10 +216,10 @@ public class CraftEventFactory { public static Entity entityDamage; // For use in EntityDamageByEntityEvent // helper methods - private static boolean canBuild(World world, Player player, int x, int z) { + private static boolean canBuild(WorldServer world, Player player, int x, int z) { int spawnSize = Bukkit.getServer().getSpawnRadius(); - if (world.getWorldProvider().getDimensionManager() != DimensionManager.OVERWORLD) return true; + if (world.getDimensionKey() != World.OVERWORLD) return true; if (spawnSize <= 0) return true; if (((CraftServer) Bukkit.getServer()).getHandle().getOPs().isEmpty()) return true; if (player.isOp()) return true; @@ -284,7 +282,7 @@ public class CraftEventFactory { /** * Block place methods */ - public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(World world, EntityHuman who, EnumHand hand, List blockStates, int clickedX, int clickedY, int clickedZ) { + public static BlockMultiPlaceEvent callBlockMultiPlaceEvent(WorldServer world, EntityHuman who, EnumHand hand, List blockStates, int clickedX, int clickedY, int clickedZ) { CraftWorld craftWorld = world.getWorld(); CraftServer craftServer = world.getServer(); Player player = (Player) who.getBukkitEntity(); @@ -312,7 +310,7 @@ public class CraftEventFactory { return event; } - public static BlockPlaceEvent callBlockPlaceEvent(World world, EntityHuman who, EnumHand hand, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) { + public static BlockPlaceEvent callBlockPlaceEvent(WorldServer world, EntityHuman who, EnumHand hand, BlockState replacedBlockState, int clickedX, int clickedY, int clickedZ) { CraftWorld craftWorld = world.getWorld(); CraftServer craftServer = world.getServer(); @@ -368,15 +366,15 @@ public class CraftEventFactory { /** * Bucket methods */ - public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(World world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand) { + public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand) { return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, world, who, changed, clicked, clickedFace, itemInHand, Items.BUCKET); } - public static PlayerBucketFillEvent callPlayerBucketFillEvent(World world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, net.minecraft.server.Item bucket) { + public static PlayerBucketFillEvent callPlayerBucketFillEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, net.minecraft.server.Item bucket) { return (PlayerBucketFillEvent) getPlayerBucketEvent(true, world, who, clicked, changed, clickedFace, itemInHand, bucket); } - private static PlayerEvent getPlayerBucketEvent(boolean isFilling, World world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.server.Item item) { + private static PlayerEvent getPlayerBucketEvent(boolean isFilling, WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.server.Item item) { Player player = (Player) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item); Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem()); @@ -1272,10 +1270,9 @@ public class CraftEventFactory { private static IChatBaseComponent stripEvents(IChatBaseComponent c) { ChatModifier modi = c.getChatModifier(); if (modi != null) { - modi.setChatClickable(null); - modi.setChatHoverable(null); + modi = modi.setChatClickable(null); + modi = modi.setChatHoverable(null); } - c.setChatModifier(modi); if (c instanceof ChatMessage) { ChatMessage cm = (ChatMessage) c; Object[] oo = cm.getArgs(); @@ -1292,7 +1289,7 @@ public class CraftEventFactory { ls.set(i, stripEvents(ls.get(i))); } } - return c; + return c.mutableCopy().setChatModifier(modi); } public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player) { @@ -1307,9 +1304,8 @@ public class CraftEventFactory { return event; } - public static BlockShearEntityEvent callBlockShearEntityEvent(EntitySheep animal, org.bukkit.block.Block dispenser, CraftItemStack is) { - Sheep sheep = (Sheep) animal.getBukkitEntity(); - BlockShearEntityEvent bse = new BlockShearEntityEvent(dispenser, sheep, is); + public static BlockShearEntityEvent callBlockShearEntityEvent(Entity animal, org.bukkit.block.Block dispenser, CraftItemStack is) { + BlockShearEntityEvent bse = new BlockShearEntityEvent(dispenser, animal.getBukkitEntity(), is); Bukkit.getPluginManager().callEvent(bse); return bse; } @@ -1324,7 +1320,7 @@ public class CraftEventFactory { return !event.isCancelled(); } - public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int incrementation) { + public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int newValue) { Player player = ((EntityPlayer) entityHuman).getBukkitEntity(); Event event; if (true) { @@ -1355,13 +1351,13 @@ public class CraftEventFactory { default: } if (stat.getType() == Type.UNTYPED) { - event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation); + event = new PlayerStatisticIncrementEvent(player, stat, current, newValue); } else if (stat.getType() == Type.ENTITY) { EntityType entityType = CraftStatistic.getEntityTypeFromStatistic((net.minecraft.server.Statistic>) statistic); - event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, entityType); + event = new PlayerStatisticIncrementEvent(player, stat, current, newValue, entityType); } else { Material material = CraftStatistic.getMaterialFromStatistic(statistic); - event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, material); + event = new PlayerStatisticIncrementEvent(player, stat, current, newValue, material); } } entityHuman.world.getServer().getPluginManager().callEvent(event); @@ -1549,7 +1545,7 @@ public class CraftEventFactory { } public static LootGenerateEvent callLootGenerateEvent(IInventory inventory, LootTable lootTable, LootTableInfo lootInfo, List loot, boolean plugin) { - CraftWorld world = lootInfo.c().getWorld(); // PAIL rename getWorld + CraftWorld world = lootInfo.getWorld().getWorld(); Entity entity = lootInfo.getContextParameter(LootContextParameters.THIS_ENTITY); NamespacedKey key = CraftNamespacedKey.fromMinecraft(world.getHandle().getMinecraftServer().getLootTableRegistry().lootTableToKey.get(lootTable)); CraftLootTable craftLootTable = new CraftLootTable(key, lootTable); diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 79a0513ac9..b53d44f0c2 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.generator; import com.google.common.base.Preconditions; +import com.mojang.serialization.Codec; import java.util.List; import java.util.Random; import net.minecraft.server.BiomeBase; @@ -8,36 +9,33 @@ import net.minecraft.server.BiomeManager; import net.minecraft.server.BiomeStorage; import net.minecraft.server.Block; import net.minecraft.server.BlockPosition; -import net.minecraft.server.ChunkProviderGenerate; -import net.minecraft.server.ChunkProviderHell; -import net.minecraft.server.ChunkProviderTheEnd; import net.minecraft.server.ChunkSection; import net.minecraft.server.DefinedStructureManager; +import net.minecraft.server.DimensionManager; import net.minecraft.server.EnumCreatureType; import net.minecraft.server.GeneratorAccess; -import net.minecraft.server.GeneratorSettingsDefault; -import net.minecraft.server.GeneratorSettingsEnd; -import net.minecraft.server.GeneratorSettingsNether; -import net.minecraft.server.GeneratorSettingsOverworld; import net.minecraft.server.HeightMap; +import net.minecraft.server.IBlockAccess; import net.minecraft.server.IChunkAccess; import net.minecraft.server.ITileEntity; import net.minecraft.server.ProtoChunk; import net.minecraft.server.RegionLimitedWorldAccess; -import net.minecraft.server.StructureGenerator; +import net.minecraft.server.RegistryMaterials; +import net.minecraft.server.StructureManager; +import net.minecraft.server.StructureSettings; import net.minecraft.server.TileEntity; -import net.minecraft.server.World; import net.minecraft.server.WorldChunkManager; -import net.minecraft.server.WorldGenFeatureConfiguration; +import net.minecraft.server.WorldDimension; import net.minecraft.server.WorldGenStage; import net.minecraft.server.WorldServer; +import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.ChunkData; -public class CustomChunkGenerator extends InternalChunkGenerator { +public class CustomChunkGenerator extends InternalChunkGenerator { private final net.minecraft.server.ChunkGenerator delegate; private final ChunkGenerator generator; private final WorldServer world; @@ -74,23 +72,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator C getFeatureConfiguration(BiomeBase biomebase, StructureGenerator structuregenerator) { - return (C) delegate.getFeatureConfiguration(biomebase, structuregenerator); - } - @Override public WorldChunkManager getWorldChunkManager() { return delegate.getWorldChunkManager(); } @Override - public void storeStructures(GeneratorAccess generatoraccess, IChunkAccess ichunkaccess) { - delegate.storeStructures(generatoraccess, ichunkaccess); + public void storeStructures(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess) { + delegate.storeStructures(generatoraccess, structuremanager, ichunkaccess); } @Override @@ -174,23 +155,23 @@ public class CustomChunkGenerator extends InternalChunkGenerator chunkgenerator, DefinedStructureManager definedstructuremanager) { + public void createStructures(StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i) { if (generator.shouldGenerateStructures()) { // Still need a way of getting the biome of this chunk to pass to createStructures // Using default biomes for now. - delegate.createStructures(biomemanager, ichunkaccess, chunkgenerator, definedstructuremanager); + delegate.createStructures(structuremanager, ichunkaccess, definedstructuremanager, i); } } @Override - public void doCarving(BiomeManager biomemanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features) { + public void doCarving(long i, BiomeManager biomemanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features) { if (generator.shouldGenerateCaves()) { - delegate.doCarving(biomemanager, ichunkaccess, worldgenstage_features); + delegate.doCarving(i, biomemanager, ichunkaccess, worldgenstage_features); } } @Override - public void buildNoise(GeneratorAccess generatoraccess, IChunkAccess ichunkaccess) { + public void buildNoise(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess) { // Disable vanilla generation } @@ -200,14 +181,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator getMobsFor(EnumCreatureType enumcreaturetype, BlockPosition blockposition) { - return delegate.getMobsFor(enumcreaturetype, blockposition); + public List getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) { + return delegate.getMobsFor(biomebase, structuremanager, enumcreaturetype, blockposition); } @Override - public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess) { + public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager) { if (generator.shouldGenerateDecorations()) { - delegate.addDecorations(regionlimitedworldaccess); + delegate.addDecorations(regionlimitedworldaccess, structuremanager); } } @@ -218,31 +199,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator structuregenerator) { - return delegate.canSpawnStructure(biomebase, structuregenerator); - } - - @Override - public long getSeed() { - return delegate.getSeed(); - } - @Override public int getSpawnHeight() { return delegate.getSpawnHeight(); @@ -252,4 +208,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator a() { + throw new UnsupportedOperationException("Cannot serialize CustomChunkGenerator"); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java index d98b1be39e..b595cee49b 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java @@ -1,13 +1,12 @@ package org.bukkit.craftbukkit.generator; -import net.minecraft.server.GeneratorAccess; -import net.minecraft.server.GeneratorSettingsDefault; +import net.minecraft.server.StructureSettings; import net.minecraft.server.WorldChunkManager; // Do not implement functions to this class, add to NormalChunkGenerator -public abstract class InternalChunkGenerator extends net.minecraft.server.ChunkGenerator { +public abstract class InternalChunkGenerator extends net.minecraft.server.ChunkGenerator { - public InternalChunkGenerator(GeneratorAccess generatorAccess, WorldChunkManager worldChunkManager, C c0) { - super(generatorAccess, worldChunkManager, c0); + public InternalChunkGenerator(WorldChunkManager worldchunkmanager, StructureSettings structuresettings) { + super(worldchunkmanager, structuresettings); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index 454ec3c76e..8c714c7430 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -18,6 +18,7 @@ import net.minecraft.server.ContainerLoom; import net.minecraft.server.ContainerMerchant; import net.minecraft.server.ContainerProperties; import net.minecraft.server.ContainerShulkerBox; +import net.minecraft.server.ContainerSmithing; import net.minecraft.server.ContainerSmoker; import net.minecraft.server.ContainerStonecutter; import net.minecraft.server.ContainerWorkbench; @@ -157,6 +158,8 @@ public class CraftContainer extends Container { return Containers.BEACON; case ANVIL: return Containers.ANVIL; + case SMITHING: + return Containers.SMITHING; case HOPPER: return Containers.HOPPER; case DROPPER: @@ -221,6 +224,9 @@ public class CraftContainer extends Container { case ANVIL: delegate = new ContainerAnvil(windowId, bottom); break; + case SMITHING: + delegate = new ContainerSmithing(windowId, bottom); + break; case BEACON: delegate = new ContainerBeacon(windowId, bottom); break; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index acc2a57ff2..98aea6b291 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -473,6 +473,8 @@ public class CraftInventory implements Inventory { return InventoryType.BEACON; } else if (this instanceof CraftInventoryAnvil) { return InventoryType.ANVIL; + } else if (this instanceof CraftInventorySmithing) { + return InventoryType.SMITHING; } else if (inventory instanceof IHopper) { return InventoryType.HOPPER; } else if (inventory instanceof TileEntityShulkerBox) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index 3787b9f04a..3cf4cd5fa8 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -105,7 +105,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn if (i < contents.length) { getMatrixInventory().setItem(i, CraftItemStack.asNMSCopy(contents[i])); } else { - getMatrixInventory().setItem(i, net.minecraft.server.ItemStack.a); + getMatrixInventory().setItem(i, net.minecraft.server.ItemStack.b); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index f3558c945a..e1dfdb23f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -55,7 +55,7 @@ public class CraftInventoryCustom extends CraftInventory { public MinecraftInventory(InventoryHolder owner, int size, String title) { Validate.notNull(title, "Title cannot be null"); - this.items = NonNullList.a(size, ItemStack.a); + this.items = NonNullList.a(size, ItemStack.b); this.title = title; this.viewers = new ArrayList(); this.owner = owner; @@ -76,9 +76,9 @@ public class CraftInventoryCustom extends CraftInventory { public ItemStack splitStack(int i, int j) { ItemStack stack = this.getItem(i); ItemStack result; - if (stack == ItemStack.a) return stack; + if (stack == ItemStack.b) return stack; if (stack.getCount() <= j) { - this.setItem(i, ItemStack.a); + this.setItem(i, ItemStack.b); result = stack; } else { result = CraftItemStack.copyNMSStack(stack, j); @@ -92,7 +92,7 @@ public class CraftInventoryCustom extends CraftInventory { public ItemStack splitWithoutUpdate(int i) { ItemStack stack = this.getItem(i); ItemStack result; - if (stack == ItemStack.a) return stack; + if (stack == ItemStack.b) return stack; if (stack.getCount() <= 1) { this.setItem(i, null); result = stack; @@ -106,7 +106,7 @@ public class CraftInventoryCustom extends CraftInventory { @Override public void setItem(int i, ItemStack itemstack) { items.set(i, itemstack); - if (itemstack != ItemStack.a && this.getMaxStackSize() > 0 && itemstack.getCount() > this.getMaxStackSize()) { + if (itemstack != ItemStack.b && this.getMaxStackSize() > 0 && itemstack.getCount() > this.getMaxStackSize()) { itemstack.setCount(this.getMaxStackSize()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithing.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithing.java new file mode 100644 index 0000000000..66193df7e0 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventorySmithing.java @@ -0,0 +1,11 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.inventory.SmithingInventory; + +public class CraftInventorySmithing extends CraftResultInventory implements SmithingInventory { + + public CraftInventorySmithing(IInventory inventory, IInventory resultInventory) { + super(inventory, resultInventory); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 01ab19434a..b2fadd5a3c 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -1,7 +1,5 @@ package org.bukkit.craftbukkit.inventory; -import com.google.common.collect.ImmutableSet; -import java.util.Collection; import org.apache.commons.lang.Validate; import org.bukkit.Color; import org.bukkit.Material; @@ -13,27 +11,11 @@ import org.bukkit.inventory.meta.ItemMeta; public final class CraftItemFactory implements ItemFactory { static final Color DEFAULT_LEATHER_COLOR = Color.fromRGB(0xA06540); - static final Collection KNOWN_NBT_ATTRIBUTE_NAMES; private static final CraftItemFactory instance; static { instance = new CraftItemFactory(); ConfigurationSerialization.registerClass(CraftMetaItem.SerializableMeta.class); - KNOWN_NBT_ATTRIBUTE_NAMES = ImmutableSet.builder() - .add("generic.armor") - .add("generic.armorToughness") - .add("generic.attackDamage") - .add("generic.followRange") - .add("generic.knockbackResistance") - .add("generic.maxHealth") - .add("generic.movementSpeed") - .add("generic.flyingSpeed") - .add("generic.attackSpeed") - .add("generic.luck") - .add("horse.jumpStrength") - .add("zombie.spawnReinforcements") - .add("generic.attackKnockback") - .build(); } private CraftItemFactory() { @@ -159,6 +141,7 @@ public final class CraftItemFactory implements ItemFactory { case FOX_SPAWN_EGG: case GHAST_SPAWN_EGG: case GUARDIAN_SPAWN_EGG: + case HOGLIN_SPAWN_EGG: case HORSE_SPAWN_EGG: case HUSK_SPAWN_EGG: case LLAMA_SPAWN_EGG: @@ -169,6 +152,7 @@ public final class CraftItemFactory implements ItemFactory { case PANDA_SPAWN_EGG: case PARROT_SPAWN_EGG: case PHANTOM_SPAWN_EGG: + case PIGLIN_SPAWN_EGG: case PIG_SPAWN_EGG: case PILLAGER_SPAWN_EGG: case POLAR_BEAR_SPAWN_EGG: @@ -185,6 +169,7 @@ public final class CraftItemFactory implements ItemFactory { case SPIDER_SPAWN_EGG: case SQUID_SPAWN_EGG: case STRAY_SPAWN_EGG: + case STRIDER_SPAWN_EGG: case TRADER_LLAMA_SPAWN_EGG: case TROPICAL_FISH_SPAWN_EGG: case TURTLE_SPAWN_EGG: @@ -195,10 +180,11 @@ public final class CraftItemFactory implements ItemFactory { case WITCH_SPAWN_EGG: case WITHER_SKELETON_SPAWN_EGG: case WOLF_SPAWN_EGG: + case ZOGLIN_SPAWN_EGG: case ZOMBIE_HORSE_SPAWN_EGG: - case ZOMBIE_PIGMAN_SPAWN_EGG: case ZOMBIE_SPAWN_EGG: case ZOMBIE_VILLAGER_SPAWN_EGG: + case ZOMBIFIED_PIGLIN_SPAWN_EGG: return meta instanceof CraftMetaSpawnEgg ? meta : new CraftMetaSpawnEgg(meta); case ARMOR_STAND: return meta instanceof CraftMetaArmorStand ? meta : new CraftMetaArmorStand(meta); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index e181df6f4d..e636cc71f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -25,16 +25,16 @@ public final class CraftItemStack extends ItemStack { public static net.minecraft.server.ItemStack asNMSCopy(ItemStack original) { if (original instanceof CraftItemStack) { CraftItemStack stack = (CraftItemStack) original; - return stack.handle == null ? net.minecraft.server.ItemStack.a : stack.handle.cloneItemStack(); + return stack.handle == null ? net.minecraft.server.ItemStack.b : stack.handle.cloneItemStack(); } if (original == null || original.getType() == Material.AIR) { - return net.minecraft.server.ItemStack.a; + return net.minecraft.server.ItemStack.b; } Item item = CraftMagicNumbers.getItem(original.getType(), original.getDurability()); if (item == null) { - return net.minecraft.server.ItemStack.a; + return net.minecraft.server.ItemStack.b; } net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount()); @@ -410,6 +410,7 @@ public final class CraftItemStack extends ItemStack { case FOX_SPAWN_EGG: case GHAST_SPAWN_EGG: case GUARDIAN_SPAWN_EGG: + case HOGLIN_SPAWN_EGG: case HORSE_SPAWN_EGG: case HUSK_SPAWN_EGG: case LLAMA_SPAWN_EGG: @@ -420,6 +421,7 @@ public final class CraftItemStack extends ItemStack { case PANDA_SPAWN_EGG: case PARROT_SPAWN_EGG: case PHANTOM_SPAWN_EGG: + case PIGLIN_SPAWN_EGG: case PIG_SPAWN_EGG: case PILLAGER_SPAWN_EGG: case POLAR_BEAR_SPAWN_EGG: @@ -436,6 +438,7 @@ public final class CraftItemStack extends ItemStack { case SPIDER_SPAWN_EGG: case SQUID_SPAWN_EGG: case STRAY_SPAWN_EGG: + case STRIDER_SPAWN_EGG: case TRADER_LLAMA_SPAWN_EGG: case TROPICAL_FISH_SPAWN_EGG: case TURTLE_SPAWN_EGG: @@ -446,10 +449,11 @@ public final class CraftItemStack extends ItemStack { case WITCH_SPAWN_EGG: case WITHER_SKELETON_SPAWN_EGG: case WOLF_SPAWN_EGG: + case ZOGLIN_SPAWN_EGG: case ZOMBIE_HORSE_SPAWN_EGG: - case ZOMBIE_PIGMAN_SPAWN_EGG: case ZOMBIE_SPAWN_EGG: case ZOMBIE_VILLAGER_SPAWN_EGG: + case ZOMBIFIED_PIGLIN_SPAWN_EGG: return new CraftMetaSpawnEgg(item.getTag()); case ARMOR_STAND: return new CraftMetaArmorStand(item.getTag()); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 39acedcf6d..9f6e797d34 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -72,7 +72,7 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public void i(ItemStack itemstack) { + public void k(ItemStack itemstack) { } public IChatBaseComponent getScoreboardDisplayName() { @@ -90,7 +90,7 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public void setExperience(int i) { + public void setForcedExperience(int i) { } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java index ff7c656348..e198251617 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java @@ -19,8 +19,8 @@ public class CraftMerchantRecipe extends MerchantRecipe { public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) { super(result, uses, maxUses, experienceReward, experience, priceMultiplier); this.handle = new net.minecraft.server.MerchantRecipe( - net.minecraft.server.ItemStack.a, - net.minecraft.server.ItemStack.a, + net.minecraft.server.ItemStack.b, + net.minecraft.server.ItemStack.b, CraftItemStack.asNMSCopy(result), uses, maxUses, diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index 7d47e2615c..e073bd6f1a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -293,7 +293,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta break; } } - TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(blockEntityTag); + TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(CraftMagicNumbers.getBlock(material).getBlockData(), blockEntityTag); switch (material) { case ACACIA_SIGN: diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index c7612457a7..c4d5bc21e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -38,7 +38,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.minecraft.server.ChatComponentText; import net.minecraft.server.EnumItemSlot; -import net.minecraft.server.GenericAttributes; import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.ItemBlock; import net.minecraft.server.NBTBase; @@ -429,7 +428,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { // entry is not an actual NBTTagCompound. getCompound returns empty NBTTagCompound in that case continue; } - net.minecraft.server.AttributeModifier nmsModifier = GenericAttributes.a(entry); + net.minecraft.server.AttributeModifier nmsModifier = net.minecraft.server.AttributeModifier.a(entry); if (nmsModifier == null) { continue; } @@ -710,12 +709,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { continue; } net.minecraft.server.AttributeModifier nmsModifier = CraftAttributeInstance.convert(entry.getValue()); - NBTTagCompound sub = GenericAttributes.a(nmsModifier); + NBTTagCompound sub = nmsModifier.save(); if (sub.isEmpty()) { continue; } - String name = CraftAttributeMap.toMinecraft(entry.getKey()); + String name = entry.getKey().getKey().toString(); if (name == null || name.isEmpty()) { continue; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index 0634fb36dd..592017c819 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java @@ -129,6 +129,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { case FOX_SPAWN_EGG: case GHAST_SPAWN_EGG: case GUARDIAN_SPAWN_EGG: + case HOGLIN_SPAWN_EGG: case HORSE_SPAWN_EGG: case HUSK_SPAWN_EGG: case LLAMA_SPAWN_EGG: @@ -139,6 +140,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { case PANDA_SPAWN_EGG: case PARROT_SPAWN_EGG: case PHANTOM_SPAWN_EGG: + case PIGLIN_SPAWN_EGG: case PIG_SPAWN_EGG: case PILLAGER_SPAWN_EGG: case POLAR_BEAR_SPAWN_EGG: @@ -155,6 +157,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { case SPIDER_SPAWN_EGG: case SQUID_SPAWN_EGG: case STRAY_SPAWN_EGG: + case STRIDER_SPAWN_EGG: case TRADER_LLAMA_SPAWN_EGG: case TROPICAL_FISH_SPAWN_EGG: case TURTLE_SPAWN_EGG: @@ -165,10 +168,11 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { case WITCH_SPAWN_EGG: case WITHER_SKELETON_SPAWN_EGG: case WOLF_SPAWN_EGG: + case ZOGLIN_SPAWN_EGG: case ZOMBIE_HORSE_SPAWN_EGG: - case ZOMBIE_PIGMAN_SPAWN_EGG: case ZOMBIE_SPAWN_EGG: case ZOMBIE_VILLAGER_SPAWN_EGG: + case ZOMBIFIED_PIGLIN_SPAWN_EGG: return true; default: return false; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java index 9957ed0402..b51321c8dd 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java @@ -25,6 +25,7 @@ public final class CraftInventoryCreator { converterMap.put(InventoryType.MERCHANT, DEFAULT_CONVERTER); converterMap.put(InventoryType.ENDER_CHEST, DEFAULT_CONVERTER); converterMap.put(InventoryType.ANVIL, DEFAULT_CONVERTER); + converterMap.put(InventoryType.SMITHING, DEFAULT_CONVERTER); converterMap.put(InventoryType.BEACON, DEFAULT_CONVERTER); converterMap.put(InventoryType.HOPPER, new CraftTileInventoryConverter.Hopper()); converterMap.put(InventoryType.SHULKER_BOX, DEFAULT_CONVERTER); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java index 32b36c70ae..ad91eabb47 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java @@ -1,7 +1,6 @@ package org.bukkit.craftbukkit.inventory.util; import net.minecraft.server.BlockPosition; -import net.minecraft.server.DimensionManager; import net.minecraft.server.IInventory; import net.minecraft.server.MinecraftServer; import net.minecraft.server.TileEntityBlastFurnace; @@ -14,6 +13,7 @@ import net.minecraft.server.TileEntityHopper; import net.minecraft.server.TileEntityLectern; import net.minecraft.server.TileEntityLootable; import net.minecraft.server.TileEntitySmoker; +import net.minecraft.server.World; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer; import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; @@ -50,7 +50,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public IInventory getTileEntity() { TileEntityFurnace furnace = new TileEntityFurnaceFurnace(); - furnace.setLocation(MinecraftServer.getServer().getWorldServer(DimensionManager.OVERWORLD), BlockPosition.ZERO); // TODO: customize this if required + furnace.setLocation(MinecraftServer.getServer().getWorldServer(World.OVERWORLD), BlockPosition.ZERO); // TODO: customize this if required return furnace; } diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java index 049e9f98de..b14333ce9e 100644 --- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.legacy; import com.google.common.base.Preconditions; -import com.mojang.datafixers.Dynamic; +import com.mojang.serialization.Dynamic; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -309,7 +309,7 @@ public final class CraftLegacy { SPAWN_EGGS.put((byte) EntityType.WOLF.getTypeId(), Material.WOLF_SPAWN_EGG); SPAWN_EGGS.put((byte) EntityType.ZOMBIE.getTypeId(), Material.ZOMBIE_SPAWN_EGG); SPAWN_EGGS.put((byte) EntityType.ZOMBIE_HORSE.getTypeId(), Material.ZOMBIE_HORSE_SPAWN_EGG); - SPAWN_EGGS.put((byte) EntityType.PIG_ZOMBIE.getTypeId(), Material.ZOMBIE_PIGMAN_SPAWN_EGG); + SPAWN_EGGS.put((byte) EntityType.ZOMBIFIED_PIGLIN.getTypeId(), Material.ZOMBIFIED_PIGLIN_SPAWN_EGG); SPAWN_EGGS.put((byte) EntityType.ZOMBIE_VILLAGER.getTypeId(), Material.ZOMBIE_VILLAGER_SPAWN_EGG); DispenserRegistry.init(); @@ -338,7 +338,7 @@ public final class CraftLegacy { IBlockData blockData = block.getBlockData(); BlockStateList states = block.getStates(); - Optional propMap = blockTag.getElement("Properties"); + Optional propMap = blockTag.getElement("Properties").result(); if (propMap.isPresent()) { NBTTagCompound properties = propMap.get(); for (String dataKey : properties.getKeys()) { diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index 3725845761..2b0d7f841b 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -6,8 +6,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; -import net.minecraft.server.DimensionManager; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.ResourceKey; import net.minecraft.server.WorldMap; import net.minecraft.server.WorldServer; import org.bukkit.Bukkit; @@ -60,7 +60,7 @@ public final class CraftMapView implements MapView { @Override public World getWorld() { - DimensionManager dimension = worldMap.map; + ResourceKey dimension = worldMap.map; WorldServer world = MinecraftServer.getServer().getWorldServer(dimension); return (world == null) ? null : world.getWorld(); @@ -68,7 +68,7 @@ public final class CraftMapView implements MapView { @Override public void setWorld(World world) { - worldMap.map = ((CraftWorld) world).getHandle().getWorldProvider().getDimensionManager(); + worldMap.map = ((CraftWorld) world).getHandle().getDimensionKey(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java index 2fe308d91b..694aff9b1b 100644 --- a/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java +++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java @@ -22,6 +22,6 @@ public class CraftBlockTag extends CraftTag { @Override public Set getValues() { - return Collections.unmodifiableSet(getHandle().a().stream().map((block) -> CraftMagicNumbers.getMaterial(block)).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().getTagged().stream().map((block) -> CraftMagicNumbers.getMaterial(block)).collect(Collectors.toSet())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java index 4a1a45257f..cd72f07c5f 100644 --- a/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java +++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java @@ -22,6 +22,6 @@ public class CraftItemTag extends CraftTag { @Override public Set getValues() { - return Collections.unmodifiableSet(getHandle().a().stream().map((item) -> CraftMagicNumbers.getMaterial(item)).collect(Collectors.toSet())); + return Collections.unmodifiableSet(getHandle().getTagged().stream().map((item) -> CraftMagicNumbers.getMaterial(item)).collect(Collectors.toSet())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 9b4a0f0678..ce57078117 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -128,7 +128,7 @@ public class Commodore ClassReader cr = new ClassReader( b ); ClassWriter cw = new ClassWriter( cr, 0 ); - cr.accept( new ClassVisitor( Opcodes.ASM7, cw ) + cr.accept( new ClassVisitor( Opcodes.ASM8, cw ) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) @@ -160,6 +160,9 @@ public class Commodore case "WALL_SIGN": name = "OAK_WALL_SIGN"; break; + case "ZOMBIE_PIGMAN_SPAWN_EGG": + name = "ZOMBIFIED_PIGLIN_SPAWN_EGG"; + break; } } @@ -216,6 +219,26 @@ public class Commodore } } + if ( owner.equals( "org/bukkit/block/Biome" ) ) + { + switch ( name ) + { + case "NETHER": + super.visitFieldInsn( opcode, owner, "NETHER_WASTES", desc ); + return; + } + } + + if ( owner.equals( "org/bukkit/entity/EntityType" ) ) + { + switch ( name ) + { + case "PIG_ZOMBIE": + super.visitFieldInsn( opcode, owner, "ZOMBIFIED_PIGLIN", desc ); + return; + } + } + super.visitFieldInsn( opcode, owner, name, desc ); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index a44602ce01..e402a0e3af 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -5,15 +5,18 @@ import com.google.common.collect.ImmutableMap.Builder; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.minecraft.server.ChatClickable; import net.minecraft.server.ChatClickable.EnumClickAction; import net.minecraft.server.ChatComponentText; +import net.minecraft.server.ChatHexColor; import net.minecraft.server.ChatMessage; import net.minecraft.server.ChatModifier; import net.minecraft.server.EnumChatFormat; import net.minecraft.server.IChatBaseComponent; +import net.minecraft.server.IChatMutableComponent; import org.bukkit.ChatColor; public final class CraftChatMessage { @@ -38,15 +41,16 @@ public final class CraftChatMessage { } private static final class StringMessage { - private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))|(\\n)", Pattern.CASE_INSENSITIVE); + private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))|(\\n)", Pattern.CASE_INSENSITIVE); // Separate pattern with no group 3, new lines are part of previous string - private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE); + private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE); private final List list = new ArrayList(); - private IChatBaseComponent currentChatComponent = new ChatComponentText(""); - private ChatModifier modifier = new ChatModifier(); + private IChatMutableComponent currentChatComponent = new ChatComponentText(""); + private ChatModifier modifier = ChatModifier.b; private final IChatBaseComponent[] output; private int currentIndex; + private StringBuilder hex; private final String message; private StringMessage(String message, boolean keepNewlines) { @@ -72,29 +76,40 @@ public final class CraftChatMessage { } switch (groupId) { case 1: - EnumChatFormat format = formatMap.get(match.toLowerCase(java.util.Locale.ENGLISH).charAt(1)); - if (format.isFormat() && format != EnumChatFormat.RESET) { + char c = match.toLowerCase(java.util.Locale.ENGLISH).charAt(1); + EnumChatFormat format = formatMap.get(c); + + if (c == 'x') { + hex = new StringBuilder("#"); + } else if (hex != null) { + hex.append(c); + + if (hex.length() == 7) { + modifier = modifier.setColor(ChatHexColor.a(hex.toString())); + hex = null; + } + } else if (format.isFormat() && format != EnumChatFormat.RESET) { switch (format) { case BOLD: - modifier.setBold(Boolean.TRUE); + modifier = modifier.setBold(Boolean.TRUE); break; case ITALIC: - modifier.setItalic(Boolean.TRUE); + modifier = modifier.setItalic(Boolean.TRUE); break; case STRIKETHROUGH: - modifier.setStrikethrough(Boolean.TRUE); + modifier = modifier.setStrikethrough(Boolean.TRUE); break; case UNDERLINE: - modifier.setUnderline(Boolean.TRUE); + modifier = modifier.setUnderline(Boolean.TRUE); break; case OBFUSCATED: - modifier.setRandom(Boolean.TRUE); + modifier = modifier.setRandom(Boolean.TRUE); break; default: throw new AssertionError("Unexpected message format"); } } else { // Color resets formatting - modifier = new ChatModifier().setColor(format); + modifier = ChatModifier.b.setColor(format); } needsAdd = true; break; @@ -102,9 +117,9 @@ public final class CraftChatMessage { if (!(match.startsWith("http://") || match.startsWith("https://"))) { match = "http://" + match; } - modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match)); + modifier = modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match)); appendNewComponent(matcher.end(groupId)); - modifier.setChatClickable((ChatClickable) null); + modifier = modifier.setChatClickable((ChatClickable) null); break; case 3: if (needsAdd) { @@ -126,10 +141,6 @@ public final class CraftChatMessage { private void appendNewComponent(int index) { IChatBaseComponent addition = new ChatComponentText(message.substring(currentIndex, index)).setChatModifier(modifier); currentIndex = index; - modifier = modifier.clone(); - if (modifier.getColor() == EnumChatFormat.RESET) { - modifier.setColor(null); - } if (currentChatComponent == null) { currentChatComponent = new ChatComponentText(""); list.add(currentChatComponent); @@ -177,13 +188,18 @@ public final class CraftChatMessage { boolean hadFormat = false; for (IChatBaseComponent c : component) { ChatModifier modi = c.getChatModifier(); - EnumChatFormat color = modi.getColor(); + ChatHexColor color = modi.getColor(); if (!c.getText().isEmpty() || color != null) { if (color != null) { - out.append(color); - if (color != EnumChatFormat.RESET) { - hadFormat = true; + if (color.format != null) { + out.append(color.format); + } else { + out.append(ChatColor.COLOR_CHAR).append("x"); + for (char magic : color.b().substring(1).toCharArray()) { + out.append(ChatColor.COLOR_CHAR).append(magic); + } } + hadFormat = true; } else if (hadFormat) { out.append(ChatColor.RESET); hadFormat = false; @@ -191,20 +207,28 @@ public final class CraftChatMessage { } if (modi.isBold()) { out.append(EnumChatFormat.BOLD); + hadFormat = true; } if (modi.isItalic()) { out.append(EnumChatFormat.ITALIC); + hadFormat = true; } if (modi.isUnderlined()) { out.append(EnumChatFormat.UNDERLINE); + hadFormat = true; } if (modi.isStrikethrough()) { out.append(EnumChatFormat.STRIKETHROUGH); + hadFormat = true; } if (modi.isRandom()) { out.append(EnumChatFormat.OBFUSCATED); + hadFormat = true; } - out.append(c.getText()); + c.b((x) -> { + out.append(x); + return Optional.empty(); + }); } return out.toString(); } @@ -221,7 +245,7 @@ public final class CraftChatMessage { if (matcher.reset(msg).find()) { matcher.reset(); - ChatModifier modifier = text.getChatModifier() != null ? text.getChatModifier() : new ChatModifier(); + ChatModifier modifier = text.getChatModifier(); List extras = new ArrayList(); List extrasOld = new ArrayList(text.getSiblings()); component = text = new ChatComponentText(""); @@ -239,8 +263,7 @@ public final class CraftChatMessage { extras.add(prev); ChatComponentText link = new ChatComponentText(matcher.group()); - ChatModifier linkModi = modifier.clone(); - linkModi.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match)); + ChatModifier linkModi = modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match)); link.setChatModifier(linkModi); extras.add(link); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 68728b4d86..9c5becd4df 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -5,7 +5,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import com.google.common.io.Files; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.datafixers.Dynamic; +import com.mojang.serialization.Dynamic; import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -197,7 +197,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "5684afcc1835d966e1b6eb0ed3f72edb"; + return "25afc67716a170ea965092c1067ff439"; } @Override @@ -256,7 +256,7 @@ public final class CraftMagicNumbers implements UnsafeValues { return file.delete(); } - private static final List SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15"); + private static final List SUPPORTED_API = Arrays.asList("1.13", "1.14", "1.15", "1.16"); @Override public void checkSupported(PluginDescriptionFile pdf) throws InvalidPluginException { diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index d8358a0f03..254bc29d71 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -10,6 +10,7 @@ import net.minecraft.server.Block; import net.minecraft.server.BlockPosition; import net.minecraft.server.ChunkStatus; import net.minecraft.server.DifficultyDamageScaler; +import net.minecraft.server.DimensionManager; import net.minecraft.server.Entity; import net.minecraft.server.EntityHuman; import net.minecraft.server.Fluid; @@ -28,7 +29,6 @@ import net.minecraft.server.TileEntity; import net.minecraft.server.World; import net.minecraft.server.WorldBorder; import net.minecraft.server.WorldData; -import net.minecraft.server.WorldProvider; public class DummyGeneratorAccess implements GeneratorAccess { @@ -37,11 +37,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { protected DummyGeneratorAccess() { } - @Override - public long getSeed() { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public TickList getBlockTickList() { throw new UnsupportedOperationException("Not supported yet."); @@ -77,11 +72,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public void update(BlockPosition bp, Block block) { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public void playSound(EntityHuman eh, BlockPosition bp, SoundEffect se, SoundCategory sc, float f, float f1) { throw new UnsupportedOperationException("Not supported yet."); @@ -138,7 +128,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public boolean p_() { + public boolean s_() { throw new UnsupportedOperationException("Not supported yet."); } @@ -148,7 +138,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public WorldProvider getWorldProvider() { + public DimensionManager getDimensionManager() { throw new UnsupportedOperationException("Not supported yet."); } @@ -183,7 +173,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { + public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { return false; } @@ -193,7 +183,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public boolean a(BlockPosition blockposition, boolean flag, Entity entity) { + public boolean a(BlockPosition blockposition, boolean flag, Entity entity, int i) { throw new UnsupportedOperationException("Not supported yet."); } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/WorldUUID.java b/src/main/java/org/bukkit/craftbukkit/util/WorldUUID.java new file mode 100644 index 0000000000..f101ed6c5a --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/util/WorldUUID.java @@ -0,0 +1,58 @@ +package org.bukkit.craftbukkit.util; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.UUID; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public final class WorldUUID { + + private static final Logger LOGGER = LogManager.getLogger(); + + private WorldUUID() { + } + + public static UUID getUUID(File baseDir) { + File file1 = new File(baseDir, "uid.dat"); + if (file1.exists()) { + DataInputStream dis = null; + try { + dis = new DataInputStream(new FileInputStream(file1)); + return new UUID(dis.readLong(), dis.readLong()); + } catch (IOException ex) { + LOGGER.warn("Failed to read " + file1 + ", generating new random UUID", ex); + } finally { + if (dis != null) { + try { + dis.close(); + } catch (IOException ex) { + // NOOP + } + } + } + } + UUID uuid = UUID.randomUUID(); + DataOutputStream dos = null; + try { + dos = new DataOutputStream(new FileOutputStream(file1)); + dos.writeLong(uuid.getMostSignificantBits()); + dos.writeLong(uuid.getLeastSignificantBits()); + } catch (IOException ex) { + LOGGER.warn("Failed to write " + file1, ex); + } finally { + if (dos != null) { + try { + dos.close(); + } catch (IOException ex) { + // NOOP + } + } + } + return uuid; + } +} diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java index b7f67d73cf..9bd05a7025 100644 --- a/src/test/java/org/bukkit/DyeColorsTest.java +++ b/src/test/java/org/bukkit/DyeColorsTest.java @@ -29,7 +29,7 @@ public class DyeColorsTest extends AbstractTestingBase { @Test public void checkColor() { Color color = dye.getColor(); - float[] nmsColorArray = EnumColor.fromColorIndex(dye.getWoolData()).d(); + float[] nmsColorArray = EnumColor.fromColorIndex(dye.getWoolData()).getColor(); Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255)); assertThat(color, is(nmsColor)); } @@ -37,7 +37,7 @@ public class DyeColorsTest extends AbstractTestingBase { @Test public void checkFireworkColor() { Color color = dye.getFireworkColor(); - int nmsColor = EnumColor.fromColorIndex(dye.getWoolData()).f(); + int nmsColor = EnumColor.fromColorIndex(dye.getWoolData()).getFireworksColor(); assertThat(color, is(Color.fromRGB(nmsColor))); } } diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java index ba8ea77eec..b99ad0faf3 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import net.minecraft.server.Block; import net.minecraft.server.BlockAccessAir; +import net.minecraft.server.BlockBase; import net.minecraft.server.BlockFalling; import net.minecraft.server.BlockFire; import net.minecraft.server.BlockPosition; @@ -153,7 +154,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isOccluding() { if (material.isBlock()) { - assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).isOccluding(CraftMagicNumbers.getBlock(material).getBlockData(), BlockAccessAir.INSTANCE, BlockPosition.ZERO))); + assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).getBlockData().isOccluding(BlockAccessAir.INSTANCE, BlockPosition.ZERO))); } else { assertFalse(material.isOccluding()); } @@ -219,7 +220,7 @@ public class PerMaterialTest extends AbstractTestingBase { assertThat(material.isInteractable(), is(!CraftMagicNumbers.getBlock(material).getClass() .getMethod("interact", IBlockData.class, net.minecraft.server.World.class, BlockPosition.class, EntityHuman.class, EnumHand.class, MovingObjectPositionBlock.class) - .getDeclaringClass().equals(Block.class))); + .getDeclaringClass().equals(BlockBase.class))); } else { assertFalse(material.isInteractable()); } @@ -228,7 +229,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testBlockHardness() { if (material.isBlock()) { - assertThat(material.getHardness(), is(CraftMagicNumbers.getBlock(material).strength)); + assertThat(material.getHardness(), is(CraftMagicNumbers.getBlock(material).getBlockData().strength)); } } @@ -249,7 +250,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void testCraftingRemainingItem() { if (material.isItem()) { - Item expectedItem = CraftMagicNumbers.getItem(material).p(); // PAIL rename p() -> getCraftingRemainingItem() + Item expectedItem = CraftMagicNumbers.getItem(material).getCraftingRemainingItem(); Material expected = expectedItem == null ? null : CraftMagicNumbers.getMaterial(expectedItem); assertThat(material.getCraftingRemainingItem(), is(expected)); diff --git a/src/test/java/org/bukkit/WorldTypeTest.java b/src/test/java/org/bukkit/WorldTypeTest.java deleted file mode 100644 index f71d6b8231..0000000000 --- a/src/test/java/org/bukkit/WorldTypeTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.bukkit; - -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; -import net.minecraft.server.WorldType; -import org.junit.Test; - -public class WorldTypeTest { - @Test - public void testTypes() { - for (WorldType type : WorldType.types) { - if (type == null) continue; - if (type == WorldType.DEBUG_ALL_BLOCK_STATES) continue; // Doesn't work anyway - - assertThat(type.name() + " has no Bukkit world", org.bukkit.WorldType.getByName(type.name()), is(not(nullValue()))); - } - } -} diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java deleted file mode 100644 index 07006a23f2..0000000000 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.bukkit.craftbukkit.inventory; - -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Collection; -import java.util.HashSet; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import net.minecraft.server.IAttribute; -import net.minecraft.server.IDynamicTexture; -import org.bukkit.support.AbstractTestingBase; -import org.junit.Test; - -public class ItemFactoryTest extends AbstractTestingBase { - - @Test - public void testKnownAttributes() throws Throwable { - final ZipInputStream nmsZipStream = new ZipInputStream(IDynamicTexture.class/* Magic class that isn't imported! */.getProtectionDomain().getCodeSource().getLocation().openStream()); - final Collection names = new HashSet(); - for (ZipEntry clazzEntry; (clazzEntry = nmsZipStream.getNextEntry()) != null; ) { - final String entryName = clazzEntry.getName(); - if (!(entryName.endsWith(".class") && entryName.startsWith("net/minecraft/server/"))) { - continue; - } - - final Class clazz = Class.forName(entryName.substring(0, entryName.length() - ".class".length()).replace('/', '.'), false, ClassLoader.getSystemClassLoader()); - assertThat(entryName, clazz, is(not(nullValue()))); - for (final Field field : clazz.getDeclaredFields()) { - if (IAttribute.class.isAssignableFrom(field.getType()) && Modifier.isStatic(field.getModifiers())) { - field.setAccessible(true); - final String attributeName = ((IAttribute) field.get(null)).getName(); - assertThat("Logical error: duplicate name `" + attributeName + "' in " + clazz.getName(), names.add(attributeName), is(true)); - assertThat(clazz.getName(), CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES, hasItem(attributeName)); - } - } - } - - nmsZipStream.close(); - - assertThat("Extra values detected", CraftItemFactory.KNOWN_NBT_ATTRIBUTE_NAMES, is(names)); - } -} diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index 7b132de553..fc5e16917f 100644 --- a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -48,6 +48,19 @@ public class LegacyTest extends AbstractTestingBase { Material.COMPOSTER, Material.TRADER_LLAMA_SPAWN_EGG, Material.WANDERING_TRADER_SPAWN_EGG, Material.FOX_SPAWN_EGG, Material.LEATHER_HORSE_ARMOR, Material.GLOBE_BANNER_PATTERN, Material.CUT_RED_SANDSTONE_SLAB, Material.CUT_SANDSTONE_SLAB, // 1.15 Material.BEEHIVE, Material.BEE_NEST, Material.BEE_SPAWN_EGG, Material.HONEYCOMB, Material.HONEYCOMB_BLOCK, Material.HONEY_BLOCK, Material.HONEY_BOTTLE, + // 1.16 + Material.ANCIENT_DEBRIS, Material.BASALT, Material.CRIMSON_BUTTON, Material.CRIMSON_DOOR, Material.CRIMSON_FENCE, Material.CRIMSON_FENCE_GATE, Material.CRIMSON_NYLIUM, Material.CRIMSON_PLANKS, Material.CRIMSON_PRESSURE_PLATE, + Material.CRIMSON_ROOTS, Material.CRIMSON_SIGN, Material.CRIMSON_SLAB, Material.CRIMSON_STAIRS, Material.CRIMSON_STEM, Material.CRIMSON_TRAPDOOR, Material.CRIMSON_WALL_SIGN, Material.HOGLIN_SPAWN_EGG, Material.NETHERITE_AXE, Material.NETHERITE_BLOCK, + Material.NETHERITE_BOOTS, Material.NETHERITE_CHESTPLATE, Material.NETHERITE_HELMET, Material.NETHERITE_HOE, Material.NETHERITE_INGOT, Material.NETHERITE_LEGGINGS, Material.NETHERITE_PICKAXE, Material.NETHERITE_SCRAP, Material.NETHERITE_SHOVEL, + Material.NETHERITE_SWORD, Material.NETHER_SPROUTS, Material.PIGLIN_SPAWN_EGG, Material.SHROOMLIGHT, Material.SOUL_FIRE, Material.SOUL_LANTERN, Material.SOUL_TORCH, Material.SOUL_WALL_TORCH, Material.SOUL_SOIL, Material.STRIPPED_CRIMSON_STEM, + Material.STRIPPED_WARPED_STEM, Material.WARPED_BUTTON, Material.WARPED_DOOR, Material.WARPED_FENCE, Material.WARPED_FENCE_GATE, Material.WARPED_FUNGUS, Material.WARPED_NYLIUM, Material.WARPED_PLANKS, Material.WARPED_PRESSURE_PLATE, Material.WARPED_ROOTS, + Material.WARPED_SIGN, Material.WARPED_SLAB, Material.WARPED_STAIRS, Material.WARPED_STEM, Material.WARPED_TRAPDOOR, Material.WARPED_WALL_SIGN, Material.WARPED_WART_BLOCK, Material.WEEPING_VINES, Material.WEEPING_VINES_PLANT, + Material.CRIMSON_FUNGUS, Material.CRIMSON_HYPHAE, Material.CRYING_OBSIDIAN, Material.NETHER_GOLD_ORE, Material.POLISHED_BASALT, Material.POTTED_CRIMSON_FUNGUS, Material.POTTED_CRIMSON_ROOTS, Material.POTTED_WARPED_FUNGUS, Material.POTTED_WARPED_ROOTS, + Material.RESPAWN_ANCHOR, Material.SLIME_SPAWN_EGG, Material.STRIPPED_CRIMSON_HYPHAE, Material.STRIPPED_WARPED_HYPHAE, Material.TARGET, Material.TWISTING_VINES, Material.TWISTING_VINES_PLANT, Material.WARPED_FUNGUS, Material.WARPED_HYPHAE, + Material.BLACKSTONE, Material.BLACKSTONE_SLAB, Material.BLACKSTONE_STAIRS, Material.BLACKSTONE_WALL, Material.CHISELED_NETHER_BRICKS, Material.CHISELED_POLISHED_BLACKSTONE, Material.CRACKED_NETHER_BRICKS, Material.CRACKED_POLISHED_BLACKSTONE_BRICKS, + Material.GILDED_BLACKSTONE, Material.LODESTONE, Material.PIGLIN_BANNER_PATTERN, Material.POLISHED_BLACKSTONE, Material.POLISHED_BLACKSTONE_BRICKS, Material.POLISHED_BLACKSTONE_BRICK_SLAB, Material.POLISHED_BLACKSTONE_BRICK_STAIRS, + Material.POLISHED_BLACKSTONE_BRICK_WALL, Material.POLISHED_BLACKSTONE_BUTTON, Material.POLISHED_BLACKSTONE_PRESSURE_PLATE, Material.POLISHED_BLACKSTONE_SLAB, Material.POLISHED_BLACKSTONE_STAIRS, Material.POLISHED_BLACKSTONE_WALL, Material.QUARTZ_BRICKS, + Material.SOUL_CAMPFIRE, Material.STRIDER_SPAWN_EGG, Material.WARPED_FUNGUS_ON_A_STICK, Material.ZOGLIN_SPAWN_EGG, Material.CHAIN, Material.MUSIC_DISC_PIGSTEP, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java b/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java index 5972b79e3b..e61e3b4a76 100644 --- a/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java +++ b/src/test/java/org/bukkit/craftbukkit/util/CraftChatMessageTest.java @@ -1,11 +1,11 @@ package org.bukkit.craftbukkit.util; +import static org.junit.Assert.assertEquals; import net.minecraft.server.IChatBaseComponent; +import net.minecraft.server.IChatMutableComponent; import org.bukkit.support.AbstractTestingBase; import org.junit.Test; -import static org.junit.Assert.assertEquals; - public class CraftChatMessageTest extends AbstractTestingBase { @Test @@ -14,7 +14,7 @@ public class CraftChatMessageTest extends AbstractTestingBase { testString("§fFoo"); testString("§fFoo§f§l"); // Keeps empty format at end testString("Foo"); - testString("§r§oFoo"); // Retains reset at start (item names can use this to get rid of italics) + // testString("§r§oFoo"); // Retains reset at start (item names can use this to get rid of italics) testString("Foo§bBar"); testString("F§loo§b§oBa§b§lr"); // any non color formatting code implies previous color code. // So §l at start has no inherited color code, so that's fine, but the one at the end, @@ -29,30 +29,30 @@ public class CraftChatMessageTest extends AbstractTestingBase { public void testNewLineBehavior() { // new line retain should stay as 1 comp testString("Hello§0\n§rFoo\n§5Test", true); - testString("§0Foo!\n", true); + testString("§0Foo!\n", true); testString("§0Foo!§0\\n§0\\n§0Bar\n", true); // dont retain line returns multiple components IChatBaseComponent[] components = CraftChatMessage.fromString("Hello§0\n§rFoo\n§5Test"); assertEquals("Has 3 components", 3, components.length); assertEquals("Hello§0", CraftChatMessage.fromComponent(components[0])); - assertEquals("§rFoo", CraftChatMessage.fromComponent(components[1])); - assertEquals("§5Test", CraftChatMessage.fromComponent(components[2])); + assertEquals(/*§r*/"Foo", CraftChatMessage.fromComponent(components[1])); + assertEquals("§5Test", CraftChatMessage.fromComponent(components[2])); } @Test public void testComponents() { - testComponent("Foo§bBar§rBaz", create("Foo", "§bBar", "Baz")); + testComponent("Foo§bBar§rBaz", create("Foo", "§bBar", "Baz")); testComponent("§fFoo§bBar§rBaz", create("", "§fFoo", "§bBar", "Baz")); testComponent("§fFoo§bBar§rBaz", create("", "§fFoo", "§bBar", "", "Baz")); testComponent("§fFoo§bBar§rBaz", create("§fFoo", "§bBar", "Baz")); - testComponent("Foo§bBar§rBaz", create("", "Foo", "§bBar", "Baz")); + testComponent("Foo§bBar§rBaz", create("", "Foo", "§bBar", "Baz")); testComponent("§fFoo§bBar§rBaz", create("§fFoo", "§bBar", "Baz")); testComponent("F§foo§bBar§rBaz", create("F§foo", "§bBar", "Baz")); } - private IChatBaseComponent create(String txt, String ...rest) { - IChatBaseComponent cmp = CraftChatMessage.fromString(txt, false)[0]; + private IChatBaseComponent create(String txt, String... rest) { + IChatMutableComponent cmp = CraftChatMessage.fromString(txt, false)[0].mutableCopy(); for (String s : rest) { cmp.addSibling(CraftChatMessage.fromString(s, true)[0]); } diff --git a/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java b/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java index f060c9beaf..2bda0c73ac 100644 --- a/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java +++ b/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java @@ -68,7 +68,7 @@ public class CraftMemoryKeyTest extends AbstractTestingBase { for (MemoryModuleType memoryModuleType : IRegistry.MEMORY_MODULE_TYPE) { if (memoryModuleType.getSerializer().isPresent()) { MemoryKey bukkitNoKey = CraftMemoryKey.toMemoryKey(memoryModuleType); - Assert.assertNotNull("MemoryModuleType should not be null", bukkitNoKey); + Assert.assertNotNull("MemoryModuleType should not be null " + IRegistry.MEMORY_MODULE_TYPE.getKey(memoryModuleType), bukkitNoKey); } } } diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index 78c9a315de..d3281c81a4 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -35,12 +35,14 @@ public abstract class AbstractTestingBase { static { DispenserRegistry.init(); // Set up resource manager - ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Thread.currentThread()); + ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA); // add tags and loot tables for unit tests resourceManager.a(TAG_REGISTRY = new TagRegistry()); resourceManager.a(LOOT_TABLE_REGISTRY = new LootTableRegistry(new LootPredicateManager())); // Register vanilla pack resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla("minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); + // Bind tags + TAG_REGISTRY.bind(); DummyServer.setup(); DummyEnchantments.setup(); @@ -52,6 +54,6 @@ public abstract class AbstractTestingBase { } } INVALIDATED_MATERIALS = builder.build(); - Assert.assertEquals("Expected 554 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 554, INVALIDATED_MATERIALS.size()); + Assert.assertEquals("Expected 564 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 564, INVALIDATED_MATERIALS.size()); } }