diff --git a/build.gradle b/build.gradle index f3fcbb3455..e2e2276cd1 100644 --- a/build.gradle +++ b/build.gradle @@ -165,6 +165,7 @@ project(':forge') { url 'https://repo.maven.apache.org/maven2/' } maven { url 'https://hub.spigotmc.org/nexus/content/groups/public/' } + maven { url 'https://papermc.io/repo/repository/maven-public/' } } ext { @@ -383,6 +384,9 @@ project(':forge') { // spigot installer 'net.md-5:bungeecord-chat:1.16-R0.3' + // paper + //installer 'co.aikar:cleaner:1.0-SNAPSHOT' + fmllauncherImplementation 'com.google.guava:guava:21.0' fmllauncherImplementation 'com.google.code.gson:gson:2.8.0' fmllauncherImplementation 'org.lwjgl:lwjgl:3.2.2' diff --git a/patches/minecraft/net/minecraft/block/AbstractRailBlock.java.patch b/patches/minecraft/net/minecraft/block/AbstractRailBlock.java.patch index 38d083851a..cf65340e14 100644 --- a/patches/minecraft/net/minecraft/block/AbstractRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/block/AbstractRailBlock.java.patch @@ -17,7 +17,15 @@ return railshape != null && railshape.func_208092_c() ? field_190959_b : field_185590_a; } -@@ -61,7 +62,7 @@ +@@ -54,6 +55,7 @@ + p_235327_1_ = this.func_208489_a(p_235327_2_, p_235327_3_, p_235327_1_, true); + if (this.field_196277_c) { + p_235327_1_.func_215697_a(p_235327_2_, p_235327_3_, this, p_235327_3_, p_235327_4_); ++ p_235327_1_ = p_235327_2_.func_180495_p(p_235327_3_); // Paper - don't desync, update again + } + + return p_235327_1_; +@@ -61,7 +63,7 @@ public void func_220069_a(BlockState p_220069_1_, World p_220069_2_, BlockPos p_220069_3_, Block p_220069_4_, BlockPos p_220069_5_, boolean p_220069_6_) { if (!p_220069_2_.field_72995_K && p_220069_2_.func_180495_p(p_220069_3_).func_203425_a(this)) { @@ -26,7 +34,7 @@ if (func_235328_a_(p_220069_3_, p_220069_2_, railshape)) { func_220075_c(p_220069_1_, p_220069_2_, p_220069_3_); p_220069_2_.func_217377_a(p_220069_3_, p_220069_6_); -@@ -110,7 +111,7 @@ +@@ -110,7 +112,7 @@ public void func_196243_a(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) { if (!p_196243_5_) { super.func_196243_a(p_196243_1_, p_196243_2_, p_196243_3_, p_196243_4_, p_196243_5_); @@ -35,7 +43,7 @@ p_196243_2_.func_195593_d(p_196243_3_.func_177984_a(), this); } -@@ -129,5 +130,20 @@ +@@ -129,5 +131,20 @@ return blockstate.func_206870_a(this.func_176560_l(), flag ? RailShape.EAST_WEST : RailShape.NORTH_SOUTH); } diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index ebcc0b26bc..710f7fddf7 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -31,7 +31,15 @@ this.field_176227_L = builder.func_235882_a_(Block::func_176223_P, BlockState::new); this.func_180632_j(this.field_176227_L.func_177621_b()); } -@@ -261,19 +266,46 @@ +@@ -240,6 +245,7 @@ + + } + ++ public static void dropNaturally(BlockState state, IWorld worldIn, BlockPos pos, @Nullable TileEntity tileEntityIn) { func_220059_a(state, worldIn, pos, tileEntityIn); } + public static void func_220059_a(BlockState p_220059_0_, IWorld p_220059_1_, BlockPos p_220059_2_, @Nullable TileEntity p_220059_3_) { + if (p_220059_1_ instanceof ServerWorld) { + func_220070_a(p_220059_0_, (ServerWorld)p_220059_1_, p_220059_2_, p_220059_3_).forEach((p_220061_2_) -> { +@@ -261,19 +267,46 @@ } public static void func_180635_a(World p_180635_0_, BlockPos p_180635_1_, ItemStack p_180635_2_) { @@ -81,7 +89,7 @@ while(p_180637_3_ > 0) { int i = ExperienceOrbEntity.func_70527_a(p_180637_3_); p_180637_3_ -= i; -@@ -283,6 +315,7 @@ +@@ -283,6 +316,7 @@ } @@ -89,7 +97,7 @@ public float func_149638_a() { return this.field_235689_au_; } -@@ -332,6 +365,7 @@ +@@ -332,6 +366,7 @@ p_176216_2_.func_213317_d(p_176216_2_.func_213322_ci().func_216372_d(1.0D, 0.0D, 1.0D)); } @@ -97,7 +105,7 @@ public ItemStack func_185473_a(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { return new ItemStack(this); } -@@ -363,6 +397,7 @@ +@@ -363,6 +398,7 @@ public void func_176224_k(World p_176224_1_, BlockPos p_176224_2_) { } @@ -105,7 +113,7 @@ public boolean func_149659_a(Explosion p_149659_1_) { return true; } -@@ -382,6 +417,7 @@ +@@ -382,6 +418,7 @@ return this.field_196275_y; } @@ -113,7 +121,7 @@ public SoundType func_220072_p(BlockState p_220072_1_) { return this.field_149762_H; } -@@ -391,7 +427,7 @@ +@@ -391,7 +428,7 @@ this.field_220086_i = Item.func_150898_a(this); } @@ -122,7 +130,7 @@ } public boolean func_208619_r() { -@@ -399,7 +435,7 @@ +@@ -399,7 +436,7 @@ } public String toString() { @@ -131,7 +139,7 @@ } @OnlyIn(Dist.CLIENT) -@@ -410,6 +446,83 @@ +@@ -410,6 +447,83 @@ return this; } diff --git a/patches/minecraft/net/minecraft/block/DetectorRailBlock.java.patch b/patches/minecraft/net/minecraft/block/DetectorRailBlock.java.patch index 2c21db47b8..451bffd82b 100644 --- a/patches/minecraft/net/minecraft/block/DetectorRailBlock.java.patch +++ b/patches/minecraft/net/minecraft/block/DetectorRailBlock.java.patch @@ -8,7 +8,14 @@ public class DetectorRailBlock extends AbstractRailBlock { public static final EnumProperty field_176573_b = BlockStateProperties.field_208166_S; -@@ -72,6 +73,14 @@ +@@ -66,12 +67,21 @@ + + private void func_176570_e(World p_176570_1_, BlockPos p_176570_2_, BlockState p_176570_3_) { + if (this.func_196260_a(p_176570_3_, p_176570_1_, p_176570_2_)) { ++ if (p_176570_3_.func_177230_c() != this) { return; } // Paper - not our block, don't do anything + boolean flag = p_176570_3_.func_177229_b(field_176574_M); + boolean flag1 = false; + List list = this.func_200878_a(p_176570_1_, p_176570_2_, AbstractMinecartEntity.class, (Predicate)null); if (!list.isEmpty()) { flag1 = true; } @@ -23,7 +30,7 @@ if (flag1 && !flag) { BlockState blockstate = p_176570_3_.func_206870_a(field_176574_M, Boolean.valueOf(true)); -@@ -131,6 +140,8 @@ +@@ -131,6 +141,8 @@ } List list1 = this.func_200878_a(p_180641_2_, p_180641_3_, AbstractMinecartEntity.class, EntityPredicates.field_96566_b); diff --git a/patches/minecraft/net/minecraft/block/RailState.java.patch b/patches/minecraft/net/minecraft/block/RailState.java.patch index 59bee3cd91..769665c4e4 100644 --- a/patches/minecraft/net/minecraft/block/RailState.java.patch +++ b/patches/minecraft/net/minecraft/block/RailState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/block/RailState.java +++ b/net/minecraft/block/RailState.java -@@ -15,14 +15,16 @@ +@@ -15,17 +15,31 @@ private BlockState field_196923_d; private final boolean field_208513_e; private final List field_196924_e = Lists.newArrayList(); @@ -19,7 +19,34 @@ this.func_208509_a(railshape); } -@@ -178,7 +180,7 @@ ++ public final World getWorld() { return this.field_196920_a; } // Paper - OBFHELPER ++ ++ public final BlockPos getPos() { return this.field_196921_b; } // Paper - OBFHELPER ++ ++ public final BlockState getRailState() { return this.field_196923_d; } // Paper - OBFHELPER ++ ++ // Paper start - prevent desync ++ public boolean isValid() { ++ return this.getWorld().func_180495_p(this.getPos()).func_177230_c() == this.getRailState().func_177230_c(); ++ } ++ // Paper end - prevent desync ++ + public List func_196907_a() { + return this.field_196924_e; + } +@@ -142,6 +156,11 @@ + } + + private void func_208510_c(RailState p_208510_1_) { ++ // Paper start - prevent desync ++ if (!this.isValid() || !p_208510_1_.isValid()) { ++ return; ++ } ++ // Paper end - prevent desync + this.field_196924_e.add(p_208510_1_.field_196921_b); + BlockPos blockpos = this.field_196921_b.func_177978_c(); + BlockPos blockpos1 = this.field_196921_b.func_177968_d(); +@@ -178,7 +197,7 @@ } } @@ -28,7 +55,7 @@ if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos.func_177984_a())) { railshape = RailShape.ASCENDING_NORTH; } -@@ -188,7 +190,7 @@ +@@ -188,7 +207,7 @@ } } @@ -37,7 +64,7 @@ if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos3.func_177984_a())) { railshape = RailShape.ASCENDING_EAST; } -@@ -304,7 +306,7 @@ +@@ -304,7 +323,7 @@ } } @@ -46,7 +73,7 @@ if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos.func_177984_a())) { railshape = RailShape.ASCENDING_NORTH; } -@@ -314,7 +316,7 @@ +@@ -314,7 +333,7 @@ } } @@ -55,3 +82,28 @@ if (AbstractRailBlock.func_208488_a(this.field_196920_a, blockpos3.func_177984_a())) { railshape = RailShape.ASCENDING_EAST; } +@@ -332,10 +351,14 @@ + this.field_196923_d = this.field_196923_d.func_206870_a(this.field_196922_c.func_176560_l(), railshape); + if (p_226941_2_ || this.field_196920_a.func_180495_p(this.field_196921_b) != this.field_196923_d) { + this.field_196920_a.func_180501_a(this.field_196921_b, this.field_196923_d, 3); +- ++ // Paper start - prevent desync ++ if (!this.isValid()) { ++ return this; ++ } ++ // Paper end - prevent desync + for(int i = 0; i < this.field_196924_e.size(); ++i) { + RailState railstate = this.func_196908_a(this.field_196924_e.get(i)); +- if (railstate != null) { ++ if (railstate != null && railstate.isValid()) { // Paper - prevent desync + railstate.func_196903_f(); + if (railstate.func_196905_c(this)) { + railstate.func_208510_c(this); +@@ -348,6 +371,6 @@ + } + + public BlockState func_196916_c() { +- return this.field_196923_d; ++ return this.getWorld().func_180495_p(this.getPos()); // Paper - prevent desync + } + } diff --git a/patches/minecraft/net/minecraft/block/SpongeBlock.java.patch b/patches/minecraft/net/minecraft/block/SpongeBlock.java.patch index 270a3dff1b..cf9abbfa73 100644 --- a/patches/minecraft/net/minecraft/block/SpongeBlock.java.patch +++ b/patches/minecraft/net/minecraft/block/SpongeBlock.java.patch @@ -62,7 +62,7 @@ ++i; if (j < 6) { queue.add(new Tuple<>(blockpos1, j + 1)); -@@ -80,6 +88,36 @@ +@@ -80,6 +88,40 @@ } } @@ -88,7 +88,11 @@ + // NOP + } else if (material == Material.field_203243_f || material == Material.field_204868_h) { + TileEntity tileentity = blockState.hasTileEntity() ? p_176312_1_.func_175625_s(blockposition2) : null; -+ func_220059_a(blockState, p_176312_1_, blockposition2, tileentity); ++ // Paper start ++ if (block.getHandle().func_185904_a() == Material.field_151579_a) { ++ dropNaturally(blockState, p_176312_1_, blockposition2, tileentity); ++ } ++ // Paper end + } + } + p_176312_1_.func_180501_a(blockposition2, block.getHandle(), block.getFlag()); diff --git a/patches/minecraft/net/minecraft/command/impl/DifficultyCommand.java.patch b/patches/minecraft/net/minecraft/command/impl/DifficultyCommand.java.patch new file mode 100644 index 0000000000..8fa10089b3 --- /dev/null +++ b/patches/minecraft/net/minecraft/command/impl/DifficultyCommand.java.patch @@ -0,0 +1,24 @@ +--- a/net/minecraft/command/impl/DifficultyCommand.java ++++ b/net/minecraft/command/impl/DifficultyCommand.java +@@ -9,6 +9,7 @@ + import net.minecraft.server.MinecraftServer; + import net.minecraft.util.text.TranslationTextComponent; + import net.minecraft.world.Difficulty; ++import net.minecraft.world.server.ServerWorld; + + public class DifficultyCommand { + private static final DynamicCommandExceptionType field_198349_a = new DynamicCommandExceptionType((p_208823_0_) -> { +@@ -35,10 +36,11 @@ + + public static int func_198345_a(CommandSource p_198345_0_, Difficulty p_198345_1_) throws CommandSyntaxException { + MinecraftServer minecraftserver = p_198345_0_.func_197028_i(); +- if (minecraftserver.func_240793_aU_().func_176130_y() == p_198345_1_) { ++ ServerWorld world = p_198345_0_.func_197023_e(); // Paper ++ if (world.field_241103_E_.func_176130_y() == p_198345_1_) { + throw field_198349_a.create(p_198345_1_.func_151526_b()); + } else { +- minecraftserver.func_147139_a(p_198345_1_, true); ++ minecraftserver.setDifficultyForAllWorlds(world, p_198345_1_, true); + p_198345_0_.func_197030_a(new TranslationTextComponent("commands.difficulty.success", p_198345_1_.func_199285_b()), true); + return 0; + } diff --git a/patches/minecraft/net/minecraft/dispenser/IDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/dispenser/IDispenseItemBehavior.java.patch index 738d5f68f0..fca4f3f720 100644 --- a/patches/minecraft/net/minecraft/dispenser/IDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/dispenser/IDispenseItemBehavior.java.patch @@ -106,6 +106,7 @@ DispenserBlock.func_199774_a(Items.field_196152_dE, new DefaultDispenseItemBehavior() { public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) { Direction direction = p_82487_1_.func_189992_e().func_177229_b(DispenserBlock.field_176441_a); +- FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(p_82487_1_.func_197524_h(), p_82487_2_, p_82487_1_.func_82615_a(), p_82487_1_.func_82617_b(), p_82487_1_.func_82615_a(), true); + double d0 = (double)direction.func_82601_c(); + double d1 = (double)direction.func_96559_d(); + double d2 = (double)direction.func_82599_e(); @@ -137,7 +138,7 @@ + } + } + itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); - FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(p_82487_1_.func_197524_h(), p_82487_2_, p_82487_1_.func_82615_a(), p_82487_1_.func_82617_b(), p_82487_1_.func_82615_a(), true); ++ FireworkRocketEntity fireworkrocketentity = new FireworkRocketEntity(p_82487_1_.func_197524_h(), itemstack1, p_82487_1_.func_82615_a(), p_82487_1_.func_82617_b(), p_82487_1_.func_82615_a(), true); // Paper - GH-2871 - fix last firework in stack having no effects when dispensed IDispenseItemBehavior.func_239785_a_(p_82487_1_, fireworkrocketentity, direction); fireworkrocketentity.func_70186_c((double)direction.func_82601_c(), (double)direction.func_96559_d(), (double)direction.func_82599_e(), 0.5F, 1.0F); p_82487_1_.func_197524_h().func_217376_c(fireworkrocketentity); diff --git a/patches/minecraft/net/minecraft/entity/AreaEffectCloudEntity.java.patch b/patches/minecraft/net/minecraft/entity/AreaEffectCloudEntity.java.patch index 363d3862ac..f25091ef95 100644 --- a/patches/minecraft/net/minecraft/entity/AreaEffectCloudEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/AreaEffectCloudEntity.java.patch @@ -62,7 +62,7 @@ public int func_184492_k() { return this.func_184212_Q().func_187225_a(field_184499_b); } -@@ -146,6 +166,17 @@ +@@ -146,10 +166,27 @@ this.field_184505_h = p_184486_1_; } @@ -80,7 +80,17 @@ public void func_70071_h_() { super.func_70071_h_(); boolean flag = this.func_184497_n(); -@@ -217,6 +248,7 @@ + float f = this.func_184490_j(); ++ // Paper start - fix MC-114618 ++ if (f < 0.0F) { ++ this.func_70106_y(); ++ return; ++ } ++ // Paper end + if (this.field_70170_p.field_72995_K) { + IParticleData iparticledata = this.func_195058_l(); + if (flag) { +@@ -217,6 +254,7 @@ if (this.field_70173_aa % 5 == 0) { Iterator> iterator = this.field_184504_g.entrySet().iterator(); @@ -88,7 +98,7 @@ while(iterator.hasNext()) { Entry entry = iterator.next(); if (this.field_70173_aa >= entry.getValue()) { -@@ -242,13 +274,24 @@ +@@ -242,13 +280,24 @@ double d1 = livingentity.func_226281_cx_() - this.func_226281_cx_(); double d2 = d0 * d0 + d1 * d1; if (d2 <= (double)(f * f)) { diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index 11c7bccb7d..5da3c73452 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -16,7 +16,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.fluid.Fluid; -@@ -108,17 +108,62 @@ +@@ -108,17 +108,63 @@ import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -51,6 +51,7 @@ + + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; ++ boolean preserveMotion = true; // Paper - keep initial motion on first setPositionRotation + static boolean isLevelAtLeast(CompoundNBT tag, int level) { + return tag.func_74764_b("Bukkit.updateLevel") && tag.func_74762_e("Bukkit.updateLevel") >= level; + } @@ -81,7 +82,7 @@ protected int field_184245_j; @Nullable private Entity field_184239_as; -@@ -135,11 +180,12 @@ +@@ -135,11 +181,12 @@ public float field_70126_B; public float field_70127_C; private AxisAlignedBB field_70121_D = field_174836_a; @@ -95,7 +96,7 @@ public boolean field_70128_L; public float field_70141_P; public float field_70140_Q; -@@ -155,8 +201,8 @@ +@@ -155,8 +202,8 @@ public float field_70144_Y; protected final Random field_70146_Z = new Random(); public int field_70173_aa; @@ -106,7 +107,7 @@ protected Object2DoubleMap> field_233554_M_ = new Object2DoubleArrayMap<>(2); protected boolean field_205013_W; @Nullable -@@ -179,14 +225,14 @@ +@@ -179,14 +226,14 @@ private Vector3d field_242272_av; public boolean field_70158_ak; public boolean field_70160_al; @@ -123,7 +124,7 @@ private final Set field_184236_aF = Sets.newHashSet(); private boolean field_184237_aG; private final double[] field_191505_aI = new double[]{0.0D, 0.0D, 0.0D}; -@@ -194,7 +240,32 @@ +@@ -194,7 +241,32 @@ private EntitySize field_213325_aI; private float field_213326_aJ; @@ -156,7 +157,7 @@ this.field_200606_g = p_i48580_1_; this.field_70170_p = p_i48580_2_; this.field_213325_aI = p_i48580_1_.func_220334_j(); -@@ -202,6 +273,13 @@ +@@ -202,6 +274,13 @@ this.field_233558_ap_ = BlockPos.field_177992_a; this.field_242272_av = Vector3d.field_186680_a; this.func_70107_b(0.0D, 0.0D, 0.0D); @@ -170,7 +171,7 @@ this.field_70180_af = new EntityDataManager(this); this.field_70180_af.func_187214_a(field_184240_ax, (byte)0); this.field_70180_af.func_187214_a(field_184241_ay, this.func_205010_bg()); -@@ -211,7 +289,11 @@ +@@ -211,7 +290,11 @@ this.field_70180_af.func_187214_a(field_189655_aD, false); this.field_70180_af.func_187214_a(field_213330_X, Pose.STANDING); this.func_70088_a(); @@ -183,7 +184,7 @@ } @OnlyIn(Dist.CLIENT) -@@ -317,10 +399,22 @@ +@@ -317,10 +400,22 @@ } public void func_70106_y() { @@ -206,7 +207,7 @@ this.field_70180_af.func_187227_b(field_213330_X, p_213301_1_); } -@@ -330,12 +424,36 @@ +@@ -330,12 +425,36 @@ public boolean func_233562_a_(Entity p_233562_1_, double p_233562_2_) { double d0 = p_233562_1_.field_233557_ao_.field_72450_a - this.field_233557_ao_.field_72450_a; @@ -243,7 +244,7 @@ this.field_70177_z = p_70101_1_ % 360.0F; this.field_70125_A = p_70101_2_ % 360.0F; } -@@ -343,6 +461,7 @@ +@@ -343,6 +462,7 @@ public void func_70107_b(double p_70107_1_, double p_70107_3_, double p_70107_5_) { this.func_226288_n_(p_70107_1_, p_70107_3_, p_70107_5_); this.func_174826_a(this.field_213325_aI.func_242285_a(p_70107_1_, p_70107_3_, p_70107_5_)); @@ -251,7 +252,7 @@ } protected void func_226264_Z_() { -@@ -373,6 +492,15 @@ +@@ -373,6 +493,15 @@ this.func_70030_z(); } @@ -267,7 +268,7 @@ public void func_70030_z() { this.field_70170_p.func_217381_Z().func_76320_a("entityBaseTick"); if (this.func_184218_aH() && this.func_184187_bx().field_70128_L) { -@@ -386,7 +514,7 @@ +@@ -386,7 +515,7 @@ this.field_70141_P = this.field_70140_Q; this.field_70127_C = this.field_70125_A; this.field_70126_B = this.field_70177_z; @@ -276,7 +277,7 @@ if (this.func_230269_aK_()) { this.func_233569_aL_(); } -@@ -449,13 +577,42 @@ +@@ -449,13 +578,42 @@ protected void func_70044_A() { if (!this.func_230279_az_()) { @@ -321,7 +322,7 @@ if (this instanceof LivingEntity) { i = ProtectionEnchantment.func_92093_a((LivingEntity)this, i); } -@@ -499,6 +656,7 @@ +@@ -499,6 +657,7 @@ } public void func_213315_a(MoverType p_213315_1_, Vector3d p_213315_2_) { @@ -329,7 +330,7 @@ if (this.field_70145_X) { this.func_174826_a(this.func_174813_aQ().func_191194_a(p_213315_2_)); this.func_174829_m(); -@@ -546,6 +704,26 @@ +@@ -546,6 +705,26 @@ block.func_176216_a(this.field_70170_p, this); } @@ -356,7 +357,7 @@ if (this.field_70122_E && !this.func_226271_bk_()) { block.func_176199_a(this.field_70170_p, blockpos, this); } -@@ -560,7 +738,7 @@ +@@ -560,7 +739,7 @@ this.field_70140_Q = (float)((double)this.field_70140_Q + (double)MathHelper.func_76133_a(func_213296_b(vector3d)) * 0.6D); this.field_82151_R = (float)((double)this.field_82151_R + (double)MathHelper.func_76133_a(d0 * d0 + d1 * d1 + d2 * d2) * 0.6D); @@ -365,7 +366,7 @@ this.field_70150_b = this.func_203009_ad(); if (this.func_70090_H()) { Entity entity = this.func_184207_aI() && this.func_184179_bs() != null ? this.func_184179_bs() : this; -@@ -575,7 +753,7 @@ +@@ -575,7 +754,7 @@ } else { this.func_180429_a(blockpos, blockstate); } @@ -374,7 +375,7 @@ this.field_191959_ay = this.func_191954_d(this.field_82151_R); } } -@@ -591,8 +769,9 @@ +@@ -591,8 +770,9 @@ float f2 = this.func_225515_ai_(); this.func_213317_d(this.func_213322_ci().func_216372_d((double)f2, 1.0D, (double)f2)); @@ -386,7 +387,7 @@ }) && this.field_190534_ay <= 0) { this.func_241209_g_(-this.func_190531_bD()); } -@@ -604,6 +783,7 @@ +@@ -604,6 +784,7 @@ this.field_70170_p.func_217381_Z().func_76319_b(); } @@ -394,7 +395,7 @@ } protected BlockPos func_226268_ag_() { -@@ -611,11 +791,10 @@ +@@ -611,11 +792,10 @@ int j = MathHelper.func_76128_c(this.field_233557_ao_.field_72448_b - (double)0.2F); int k = MathHelper.func_76128_c(this.field_233557_ao_.field_72449_c); BlockPos blockpos = new BlockPos(i, j, k); @@ -408,7 +409,7 @@ return blockpos1; } } -@@ -801,6 +980,7 @@ +@@ -801,6 +981,7 @@ public void func_174829_m() { AxisAlignedBB axisalignedbb = this.func_174813_aQ(); this.func_226288_n_((axisalignedbb.field_72340_a + axisalignedbb.field_72336_d) / 2.0D, axisalignedbb.field_72338_b, (axisalignedbb.field_72339_c + axisalignedbb.field_72334_f) / 2.0D); @@ -416,7 +417,7 @@ } protected SoundEvent func_184184_Z() { -@@ -849,7 +1029,7 @@ +@@ -849,7 +1030,7 @@ protected void func_180429_a(BlockPos p_180429_1_, BlockState p_180429_2_) { if (!p_180429_2_.func_185904_a().func_76224_d()) { BlockState blockstate = this.field_70170_p.func_180495_p(p_180429_1_.func_177984_a()); @@ -425,7 +426,7 @@ this.func_184185_a(soundtype.func_185844_d(), soundtype.func_185843_a() * 0.15F, soundtype.func_185847_b()); } } -@@ -1056,9 +1236,10 @@ +@@ -1056,9 +1237,10 @@ int k = MathHelper.func_76128_c(this.func_226281_cx_()); BlockPos blockpos = new BlockPos(i, j, k); BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); @@ -437,7 +438,7 @@ } } -@@ -1099,6 +1280,13 @@ +@@ -1099,6 +1281,13 @@ } public void func_70029_a(World p_70029_1_) { @@ -451,7 +452,7 @@ this.field_70170_p = p_70029_1_; } -@@ -1117,6 +1305,7 @@ +@@ -1117,6 +1306,7 @@ this.field_70167_r = p_242281_3_; this.field_70166_s = d1; this.func_70107_b(d0, p_242281_3_, d1); @@ -459,7 +460,21 @@ } public void func_233576_c_(Vector3d p_233576_1_) { -@@ -1297,6 +1486,12 @@ +@@ -1132,6 +1322,13 @@ + } + + public void func_70012_b(double p_70012_1_, double p_70012_3_, double p_70012_5_, float p_70012_7_, float p_70012_8_) { ++ // Paper - cancel entity velocity if teleported ++ if (!preserveMotion) { ++ this.field_213327_at = Vector3d.field_186680_a; ++ } else { ++ this.preserveMotion = false; ++ } ++ // Paper end + this.func_226286_f_(p_70012_1_, p_70012_3_, p_70012_5_); + this.field_70177_z = p_70012_7_; + this.field_70125_A = p_70012_8_; +@@ -1297,6 +1494,12 @@ return false; } @@ -472,7 +487,7 @@ public void func_191956_a(Entity p_191956_1_, int p_191956_2_, DamageSource p_191956_3_) { if (p_191956_1_ instanceof ServerPlayerEntity) { CriteriaTriggers.field_192123_c.func_192211_a((ServerPlayerEntity)p_191956_1_, this, p_191956_3_); -@@ -1326,7 +1521,7 @@ +@@ -1326,7 +1529,7 @@ public boolean func_184198_c(CompoundNBT p_184198_1_) { String s = this.func_70022_Q(); @@ -481,7 +496,7 @@ p_184198_1_.func_74778_a("id", s); this.func_189511_e(p_184198_1_); return true; -@@ -1349,6 +1544,17 @@ +@@ -1349,6 +1552,17 @@ Vector3d vector3d = this.func_213322_ci(); p_189511_1_.func_218657_a("Motion", this.func_70087_a(vector3d.field_72450_a, vector3d.field_72448_b, vector3d.field_72449_c)); @@ -499,7 +514,7 @@ p_189511_1_.func_218657_a("Rotation", this.func_70049_a(this.field_70177_z, this.field_70125_A)); p_189511_1_.func_74776_a("FallDistance", this.field_70143_R); p_189511_1_.func_74777_a("Fire", (short)this.field_190534_ay); -@@ -1357,6 +1563,19 @@ +@@ -1357,6 +1571,19 @@ p_189511_1_.func_74757_a("Invulnerable", this.field_83001_bt); p_189511_1_.func_74768_a("PortalCooldown", this.field_242273_aw); p_189511_1_.func_186854_a("UUID", this.func_110124_au()); @@ -519,7 +534,7 @@ ITextComponent itextcomponent = this.func_200201_e(); if (itextcomponent != null) { p_189511_1_.func_74778_a("CustomName", ITextComponent.Serializer.func_150696_a(itextcomponent)); -@@ -1377,6 +1596,7 @@ +@@ -1377,6 +1604,7 @@ if (this.field_184238_ar) { p_189511_1_.func_74757_a("Glowing", this.field_184238_ar); } @@ -527,7 +542,7 @@ if (!this.field_184236_aF.isEmpty()) { ListNBT listnbt = new ListNBT(); -@@ -1388,6 +1608,10 @@ +@@ -1388,6 +1616,10 @@ p_189511_1_.func_218657_a("Tags", listnbt); } @@ -538,7 +553,7 @@ this.func_213281_b(p_189511_1_); if (this.func_184207_aI()) { ListNBT listnbt1 = new ListNBT(); -@@ -1404,6 +1628,12 @@ +@@ -1404,6 +1636,12 @@ } } @@ -551,7 +566,7 @@ return p_189511_1_; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.func_85055_a(throwable, "Saving entity NBT"); -@@ -1458,6 +1688,9 @@ +@@ -1458,6 +1696,9 @@ this.func_174810_b(p_70020_1_.func_74767_n("Silent")); this.func_189654_d(p_70020_1_.func_74767_n("NoGravity")); this.func_184195_f(p_70020_1_.func_74767_n("Glowing")); @@ -561,7 +576,7 @@ if (p_70020_1_.func_150297_b("Tags", 9)) { this.field_184236_aF.clear(); ListNBT listnbt3 = p_70020_1_.func_150295_c("Tags", 8); -@@ -1479,6 +1712,47 @@ +@@ -1479,6 +1720,47 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -609,17 +624,19 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.func_85055_a(throwable, "Loading entity NBT"); CrashReportCategory crashreportcategory = crashreport.func_85058_a("Entity being loaded"); -@@ -1544,8 +1818,23 @@ +@@ -1544,8 +1826,24 @@ } else if (this.field_70170_p.field_72995_K) { return null; } else { +- ItemEntity itementity = new ItemEntity(this.field_70170_p, this.func_226277_ct_(), this.func_226278_cu_() + (double)p_70099_2_, this.func_226281_cx_(), p_70099_1_); + // CraftBukkit start - Capture drops for death event + if (this instanceof LivingEntity && !((LivingEntity) this).forceDrops) { -+ ((LivingEntity) this).drops.add(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack.asBukkitCopy(p_70099_1_)); ++ ((LivingEntity) this).drops.add(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack.asCraftMirror(p_70099_1_)); + return null; + } + // CraftBukkit end - ItemEntity itementity = new ItemEntity(this.field_70170_p, this.func_226277_ct_(), this.func_226278_cu_() + (double)p_70099_2_, this.func_226281_cx_(), p_70099_1_); ++ ItemEntity itementity = new ItemEntity(this.field_70170_p, this.func_226277_ct_(), this.func_226278_cu_() + (double)p_70099_2_, this.func_226281_cx_(), p_70099_1_.func_77946_l()); ++ p_70099_1_.func_190920_e(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe itementity.func_174869_p(); + // CraftBukkit start + EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itementity.getBukkitEntity()); @@ -633,7 +650,7 @@ this.field_70170_p.func_217376_c(itementity); return itementity; } -@@ -1582,6 +1871,7 @@ +@@ -1582,6 +1880,7 @@ public void func_70098_U() { this.func_213317_d(Vector3d.field_186680_a); @@ -641,7 +658,7 @@ this.func_70071_h_(); if (this.func_184218_aH()) { this.func_184187_bx().func_184232_k(this); -@@ -1627,6 +1917,7 @@ +@@ -1627,6 +1926,7 @@ } } @@ -649,7 +666,7 @@ if (p_184205_2_ || this.func_184228_n(p_184205_1_) && p_184205_1_.func_184219_q(this)) { if (this.func_184218_aH()) { this.func_184210_p(); -@@ -1634,7 +1925,7 @@ +@@ -1634,7 +1934,7 @@ this.func_213301_b(Pose.STANDING); this.field_184239_as = p_184205_1_; @@ -658,7 +675,7 @@ return true; } else { return false; -@@ -1659,8 +1950,9 @@ +@@ -1659,8 +1959,9 @@ public void func_233575_bb_() { if (this.field_184239_as != null) { Entity entity = this.field_184239_as; @@ -669,7 +686,7 @@ } } -@@ -1669,26 +1961,84 @@ +@@ -1669,26 +1970,84 @@ this.func_233575_bb_(); } @@ -763,7 +780,7 @@ } protected boolean func_184219_q(Entity p_184219_1_) { -@@ -1743,11 +2093,17 @@ +@@ -1743,11 +2102,17 @@ MinecraftServer minecraftserver = serverworld.func_73046_m(); RegistryKey registrykey = this.field_70170_p.func_234923_W_() == World.field_234919_h_ ? World.field_234918_g_ : World.field_234919_h_; ServerWorld serverworld1 = minecraftserver.func_71218_a(registrykey); @@ -783,7 +800,7 @@ this.field_70170_p.func_217381_Z().func_76319_b(); } -@@ -1816,6 +2172,7 @@ +@@ -1816,6 +2181,7 @@ return !this.func_184188_bt().isEmpty(); } @@ -791,7 +808,7 @@ public boolean func_205710_ba() { return true; } -@@ -1870,6 +2227,13 @@ +@@ -1870,6 +2236,13 @@ } public void func_204711_a(boolean p_204711_1_) { @@ -805,7 +822,7 @@ this.func_70052_a(4, p_204711_1_); } -@@ -1912,15 +2276,19 @@ +@@ -1912,15 +2285,19 @@ return this.func_96124_cp() != null ? this.func_96124_cp().func_142054_a(p_184194_1_) : false; } @@ -828,7 +845,7 @@ byte b0 = this.field_70180_af.func_187225_a(field_184240_ax); if (p_70052_2_) { this.field_70180_af.func_187227_b(field_184240_ax, (byte)(b0 | 1 << p_70052_1_)); -@@ -1939,16 +2307,53 @@ +@@ -1939,16 +2316,53 @@ } public void func_70050_g(int p_70050_1_) { @@ -885,7 +902,7 @@ } public void func_203002_i(boolean p_203002_1_) { -@@ -2032,7 +2437,7 @@ +@@ -2032,7 +2446,7 @@ } protected ITextComponent func_225513_by_() { @@ -894,7 +911,7 @@ } public boolean func_70028_i(Entity p_70028_1_) { -@@ -2087,32 +2492,67 @@ +@@ -2087,32 +2501,71 @@ @Nullable public Entity func_241206_a_(ServerWorld p_241206_1_) { @@ -913,6 +930,10 @@ + + @Nullable + public Entity changeDimension(ServerWorld server, net.minecraftforge.common.util.ITeleporter teleporter, BlockPos location) { ++ if (!func_70089_S() || !valid) { ++ field_184243_a.warn("Illegal Entity Teleport " + this + " to " + server + ":" + location, new Throwable()); ++ return null; ++ } if (this.field_70170_p instanceof ServerWorld && !this.field_70128_L) { this.field_70170_p.func_217381_Z().func_76320_a("changeDimension"); - this.func_213319_R(); @@ -952,7 +973,7 @@ + this.getBukkitEntity().setHandle(entity); + entity.bukkitEntity = this.getBukkitEntity(); + if (this instanceof MobEntity) { -+ ((MobEntity)this).func_110160_i(true, false); // Unleash to prevent duping of leads. ++ ((MobEntity)this).func_110160_i(true, true); // Paper drop lead + } + // CraftBukkit end } @@ -970,7 +991,7 @@ } } else { return null; -@@ -2125,8 +2565,13 @@ +@@ -2125,8 +2578,13 @@ @Nullable protected PortalInfo func_241829_a(ServerWorld p_241829_1_) { @@ -984,7 +1005,7 @@ if (!flag && !flag1) { boolean flag2 = p_241829_1_.func_234923_W_() == World.field_234919_h_; if (this.field_70170_p.func_234923_W_() != World.field_234919_h_ && !flag2) { -@@ -2139,7 +2584,16 @@ +@@ -2139,7 +2597,16 @@ double d3 = Math.min(2.9999872E7D, worldborder.func_177733_e() - 16.0D); double d4 = DimensionType.func_242715_a(this.field_70170_p.func_230315_m_(), p_241829_1_.func_230315_m_()); BlockPos blockpos1 = new BlockPos(MathHelper.func_151237_a(this.func_226277_ct_() * d4, d0, d2), this.func_226278_cu_(), MathHelper.func_151237_a(this.func_226281_cx_() * d4, d1, d3)); @@ -1002,7 +1023,7 @@ BlockState blockstate = this.field_70170_p.func_180495_p(this.field_242271_ac); Direction.Axis direction$axis; Vector3d vector3d; -@@ -2154,7 +2608,7 @@ +@@ -2154,7 +2621,7 @@ vector3d = new Vector3d(0.5D, 0.0D, 0.0D); } @@ -1011,7 +1032,7 @@ }).orElse((PortalInfo)null); } } else { -@@ -2165,7 +2619,16 @@ +@@ -2165,7 +2632,16 @@ blockpos = p_241829_1_.func_205770_a(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, p_241829_1_.func_241135_u_()); } @@ -1029,7 +1050,7 @@ } } -@@ -2173,6 +2636,25 @@ +@@ -2173,12 +2649,31 @@ return PortalSize.func_242973_a(p_241839_2_, p_241839_1_, this.func_213303_ch(), this.func_213305_a(this.func_213283_Z())); } @@ -1055,7 +1076,14 @@ protected Optional func_241830_a(ServerWorld p_241830_1_, BlockPos p_241830_2_, boolean p_241830_3_) { return p_241830_1_.func_85176_s().func_242957_a(p_241830_2_, p_241830_3_); } -@@ -2320,9 +2802,10 @@ + + public boolean func_184222_aU() { +- return true; ++ return func_70089_S() && valid; // Paper + } + + public float func_180428_a(Explosion p_180428_1_, IBlockReader p_180428_2_, BlockPos p_180428_3_, BlockState p_180428_4_, FluidState p_180428_5_, float p_180428_6_) { +@@ -2320,9 +2815,10 @@ public void func_213323_x_() { EntitySize entitysize = this.field_213325_aI; Pose pose = this.func_213283_Z(); @@ -1068,7 +1096,7 @@ if (entitysize1.field_220315_a < entitysize.field_220315_a) { double d0 = (double)entitysize1.field_220315_a / 2.0D; this.func_174826_a(new AxisAlignedBB(this.func_226277_ct_() - d0, this.func_226278_cu_(), this.func_226281_cx_() - d0, this.func_226277_ct_() + d0, this.func_226278_cu_() + (double)entitysize1.field_220316_b, this.func_226281_cx_() + d0)); -@@ -2371,7 +2854,31 @@ +@@ -2371,7 +2867,31 @@ } public void func_174826_a(AxisAlignedBB p_174826_1_) { @@ -1101,7 +1129,16 @@ } protected float func_213316_a(Pose p_213316_1_, EntitySize p_213316_2_) { -@@ -2594,7 +3101,7 @@ +@@ -2513,7 +3033,7 @@ + } + + public Stream func_226276_cg_() { +- return Stream.concat(Stream.of(this), this.field_184244_h.stream().flatMap(Entity::func_226276_cg_)); ++ return Stream.concat(Stream.of(this), com.google.common.collect.ImmutableList.copyOf(this.field_184244_h).stream().flatMap(Entity::func_226276_cg_)); // Paper + } + + public boolean func_200601_bK() { +@@ -2594,7 +3114,7 @@ return SoundCategory.NEUTRAL; } @@ -1110,7 +1147,7 @@ return 1; } -@@ -2796,6 +3303,7 @@ +@@ -2796,6 +3316,7 @@ this.field_233555_aA_ = true; } @@ -1118,7 +1155,7 @@ } -@@ -2811,4 +3319,63 @@ +@@ -2811,4 +3332,63 @@ public interface IMoveCallback { void accept(Entity p_accept_1_, double p_accept_2_, double p_accept_4_, double p_accept_6_); } diff --git a/patches/minecraft/net/minecraft/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/entity/LivingEntity.java.patch index 12f242ca49..1ff937fc60 100644 --- a/patches/minecraft/net/minecraft/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/LivingEntity.java.patch @@ -1053,7 +1053,15 @@ if (!this.field_82175_bq || this.field_110158_av >= this.func_82166_i() / 2 || this.field_110158_av < 0) { this.field_110158_av = -1; this.field_82175_bq = true; -@@ -1848,15 +2296,16 @@ +@@ -1733,6 +2181,7 @@ + return p_233634_1_.test(this.func_184614_ca().func_77973_b()) || p_233634_1_.test(this.func_184592_cb().func_77973_b()); + } + ++ public final ItemStack getItemInHand(Hand enumhand) { return this.func_184586_b(enumhand); } // Paper - OBFHELPER + public ItemStack func_184586_b(Hand p_184586_1_) { + if (p_184586_1_ == Hand.MAIN_HAND) { + return this.func_184582_a(EquipmentSlotType.MAINHAND); +@@ -1848,15 +2297,16 @@ } this.field_70160_al = true; @@ -1072,7 +1080,7 @@ } protected float func_189749_co() { -@@ -1870,11 +2319,15 @@ +@@ -1870,11 +2320,15 @@ public void func_213352_e(Vector3d p_213352_1_) { if (this.func_70613_aW() || this.func_184186_bw()) { double d0 = 0.08D; @@ -1089,7 +1097,7 @@ FluidState fluidstate = this.field_70170_p.func_204610_c(this.func_233580_cy_()); if (this.func_70090_H() && this.func_241208_cS_() && !this.func_230285_a_(fluidstate.func_206886_c())) { -@@ -1899,6 +2352,7 @@ +@@ -1899,6 +2353,7 @@ f5 = 0.96F; } @@ -1097,7 +1105,7 @@ this.func_213309_a(f6, p_213352_1_); this.func_213315_a(MoverType.SELF, this.func_213322_ci()); Vector3d vector3d6 = this.func_213322_ci(); -@@ -1973,11 +2427,12 @@ +@@ -1973,11 +2428,12 @@ } if (this.field_70122_E && !this.field_70170_p.field_72995_K) { @@ -1112,7 +1120,7 @@ float f4 = this.field_70122_E ? f3 * 0.91F : 0.91F; Vector3d vector3d5 = this.func_233633_a_(p_213352_1_, f3); double d2 = vector3d5.field_72448_b; -@@ -2049,7 +2504,7 @@ +@@ -2049,7 +2505,7 @@ double d0 = MathHelper.func_151237_a(p_213362_1_.field_72450_a, (double)-0.15F, (double)0.15F); double d1 = MathHelper.func_151237_a(p_213362_1_.field_72449_c, (double)-0.15F, (double)0.15F); double d2 = Math.max(p_213362_1_.field_72448_b, (double)-0.15F); @@ -1121,7 +1129,7 @@ d2 = 0.0D; } -@@ -2077,6 +2532,8 @@ +@@ -2077,6 +2533,8 @@ } public void func_70071_h_() { @@ -1130,7 +1138,7 @@ super.func_70071_h_(); this.func_184608_ct(); this.func_205014_p(); -@@ -2122,7 +2579,9 @@ +@@ -2122,7 +2580,9 @@ } } @@ -1140,7 +1148,7 @@ double d0 = this.func_226277_ct_() - this.field_70169_q; double d1 = this.func_226281_cx_() - this.field_70166_s; float f = (float)(d0 * d0 + d1 * d1); -@@ -2200,6 +2659,7 @@ +@@ -2200,6 +2660,7 @@ this.field_70125_A = 0.0F; } @@ -1148,7 +1156,7 @@ } private void func_241353_q_() { -@@ -2232,6 +2692,7 @@ +@@ -2232,6 +2693,7 @@ ItemStack itemstack1 = this.func_184582_a(equipmentslottype); if (!ItemStack.func_77989_b(itemstack1, itemstack)) { @@ -1156,7 +1164,7 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlotType.class); } -@@ -2368,6 +2829,7 @@ +@@ -2368,6 +2830,7 @@ this.func_213293_j(d1, d3, d5); this.field_70170_p.func_217381_Z().func_76320_a("ai"); @@ -1164,7 +1172,7 @@ if (this.func_70610_aX()) { this.field_70703_bu = false; this.field_70702_br = 0.0F; -@@ -2377,6 +2839,7 @@ +@@ -2377,6 +2840,7 @@ this.func_70626_be(); this.field_70170_p.func_217381_Z().func_76319_b(); } @@ -1172,7 +1180,7 @@ this.field_70170_p.func_217381_Z().func_76319_b(); this.field_70170_p.func_217381_Z().func_76320_a("jump"); -@@ -2412,7 +2875,9 @@ +@@ -2412,7 +2876,9 @@ this.field_191988_bg *= 0.98F; this.func_184616_r(); AxisAlignedBB axisalignedbb = this.func_174813_aQ(); @@ -1182,7 +1190,7 @@ this.field_70170_p.func_217381_Z().func_76319_b(); this.field_70170_p.func_217381_Z().func_76320_a("push"); if (this.field_204807_bs > 0) { -@@ -2420,7 +2885,9 @@ +@@ -2420,7 +2886,9 @@ this.func_204801_a(axisalignedbb, this.func_174813_aQ()); } @@ -1192,7 +1200,7 @@ this.field_70170_p.func_217381_Z().func_76319_b(); if (!this.field_70170_p.field_72995_K && this.func_230270_dK_() && this.func_203008_ap()) { this.func_70097_a(DamageSource.field_76369_e, 1.0F); -@@ -2436,6 +2903,8 @@ +@@ -2436,6 +2904,8 @@ boolean flag = this.func_70083_f(7); if (flag && !this.field_70122_E && !this.func_184218_aH() && !this.func_70644_a(Effects.field_188424_y)) { ItemStack itemstack = this.func_184582_a(EquipmentSlotType.CHEST); @@ -1201,7 +1209,7 @@ if (itemstack.func_77973_b() == Items.field_185160_cR && ElytraItem.func_185069_d(itemstack)) { flag = true; if (!this.field_70170_p.field_72995_K && (this.field_184629_bo + 1) % 20 == 0) { -@@ -2451,7 +2920,8 @@ +@@ -2451,7 +2921,8 @@ } if (!this.field_70170_p.field_72995_K) { @@ -1211,7 +1219,7 @@ } } -@@ -2579,6 +3049,7 @@ +@@ -2579,6 +3050,7 @@ } public boolean func_70685_l(Entity p_70685_1_) { @@ -1219,7 +1227,7 @@ Vector3d vector3d = new Vector3d(this.func_226277_ct_(), this.func_226280_cw_(), this.func_226281_cx_()); Vector3d vector3d1 = new Vector3d(p_70685_1_.func_226277_ct_(), p_70685_1_.func_226280_cw_(), p_70685_1_.func_226281_cx_()); return this.field_70170_p.func_217299_a(new RayTraceContext(vector3d, vector3d1, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, this)).func_216346_c() == RayTraceResult.Type.MISS; -@@ -2603,13 +3074,20 @@ +@@ -2603,13 +3075,20 @@ } public boolean func_70067_L() { @@ -1242,7 +1250,7 @@ protected void func_70018_K() { this.field_70133_I = this.field_70146_Z.nextDouble() >= this.func_233637_b_(Attributes.field_233820_c_); } -@@ -2668,8 +3146,16 @@ +@@ -2668,8 +3147,16 @@ private void func_184608_ct() { if (this.func_184587_cr()) { @@ -1261,7 +1269,7 @@ this.field_184627_bm.func_222121_b(this.field_70170_p, this, this.func_184605_cv()); if (this.func_226299_p_()) { this.func_226293_b_(this.field_184627_bm, 5); -@@ -2717,8 +3203,10 @@ +@@ -2717,8 +3204,10 @@ public void func_184598_c(Hand p_184598_1_) { ItemStack itemstack = this.func_184586_b(p_184598_1_); if (!itemstack.func_190926_b() && !this.func_184587_cr()) { @@ -1273,7 +1281,7 @@ if (!this.field_70170_p.field_72995_K) { this.func_204802_c(1, true); this.func_204802_c(2, p_184598_1_ == Hand.OFF_HAND); -@@ -2778,6 +3266,9 @@ +@@ -2778,6 +3267,9 @@ vector3d1 = vector3d1.func_178789_a(-this.field_70125_A * ((float)Math.PI / 180F)); vector3d1 = vector3d1.func_178785_b(-this.field_70177_z * ((float)Math.PI / 180F)); vector3d1 = vector3d1.func_72441_c(this.func_226277_ct_(), this.func_226280_cw_(), this.func_226281_cx_()); @@ -1283,7 +1291,7 @@ this.field_70170_p.func_195594_a(new ItemParticleData(ParticleTypes.field_197591_B, p_195062_1_), vector3d1.field_72450_a, vector3d1.field_72448_b, vector3d1.field_72449_c, vector3d.field_72450_a, vector3d.field_72448_b + 0.05D, vector3d.field_72449_c); } -@@ -2790,7 +3281,28 @@ +@@ -2790,7 +3282,28 @@ } else { if (!this.field_184627_bm.func_190926_b() && this.func_184587_cr()) { this.func_226293_b_(this.field_184627_bm, 16); @@ -1313,7 +1321,7 @@ if (itemstack != this.field_184627_bm) { this.func_184611_a(hand, itemstack); } -@@ -2815,7 +3327,11 @@ +@@ -2815,7 +3328,11 @@ public void func_184597_cx() { if (!this.field_184627_bm.func_190926_b()) { @@ -1325,7 +1333,7 @@ if (this.field_184627_bm.func_222122_m()) { this.func_184608_ct(); } -@@ -2886,10 +3402,18 @@ +@@ -2886,10 +3403,18 @@ } if (flag1) { @@ -1347,7 +1355,7 @@ } } -@@ -2964,8 +3488,8 @@ +@@ -2964,8 +3489,8 @@ } BlockState blockstate = this.field_70170_p.func_180495_p(p_213342_1_); @@ -1358,7 +1366,7 @@ } this.func_213301_b(Pose.SLEEPING); -@@ -2981,15 +3505,15 @@ +@@ -2981,15 +3506,15 @@ private boolean func_213359_p() { return this.func_213374_dv().map((p_241350_1_) -> { @@ -1377,7 +1385,7 @@ Vector3d vector3d1 = BedBlock.func_242652_a(this.func_200600_R(), this.field_70170_p, p_241348_1_, this.field_70177_z).orElseGet(() -> { BlockPos blockpos = p_241348_1_.func_177984_a(); return new Vector3d((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.1D, (double)blockpos.func_177952_p() + 0.5D); -@@ -3012,7 +3536,9 @@ +@@ -3012,7 +3537,9 @@ @OnlyIn(Dist.CLIENT) public Direction func_213376_dz() { BlockPos blockpos = this.func_213374_dv().orElse((BlockPos)null); @@ -1388,7 +1396,7 @@ } public boolean func_70094_T() { -@@ -3048,7 +3574,7 @@ +@@ -3048,7 +3575,7 @@ if (item.func_219971_r()) { for(Pair pair : item.func_219967_s().func_221464_f()) { if (!p_213349_2_.field_72995_K && pair.getFirst() != null && p_213349_2_.field_73012_v.nextFloat() < pair.getSecond()) { @@ -1397,7 +1405,7 @@ } } } -@@ -3082,6 +3608,60 @@ +@@ -3082,6 +3609,60 @@ this.func_213361_c(p_213334_1_ == Hand.MAIN_HAND ? EquipmentSlotType.MAINHAND : EquipmentSlotType.OFFHAND); } @@ -1458,7 +1466,7 @@ @OnlyIn(Dist.CLIENT) public AxisAlignedBB func_184177_bl() { if (this.func_184582_a(EquipmentSlotType.HEAD).func_77973_b() == Items.field_196151_dA) { -@@ -3091,4 +3671,5 @@ +@@ -3091,4 +3672,5 @@ return super.func_184177_bl(); } } diff --git a/patches/minecraft/net/minecraft/entity/ai/brain/task/MultiTask.java.patch b/patches/minecraft/net/minecraft/entity/ai/brain/task/MultiTask.java.patch new file mode 100644 index 0000000000..a8adc81c24 --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/ai/brain/task/MultiTask.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/entity/ai/brain/task/MultiTask.java ++++ b/net/minecraft/entity/ai/brain/task/MultiTask.java +@@ -16,7 +16,7 @@ + private final Set> field_220416_b; + private final MultiTask.Ordering field_220417_c; + private final MultiTask.RunType field_220418_d; +- private final WeightedList> field_220419_e = new WeightedList<>(); ++ private final WeightedList> field_220419_e = new WeightedList<>(false); // Paper - don't use a clone + + public MultiTask(Map, MemoryModuleStatus> p_i51503_1_, Set> p_i51503_2_, MultiTask.Ordering p_i51503_3_, MultiTask.RunType p_i51503_4_, List, Integer>> p_i51503_5_) { + super(p_i51503_1_); diff --git a/patches/minecraft/net/minecraft/entity/boss/WitherEntity.java.patch b/patches/minecraft/net/minecraft/entity/boss/WitherEntity.java.patch index f869d70eca..1902fcf9f4 100644 --- a/patches/minecraft/net/minecraft/entity/boss/WitherEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/boss/WitherEntity.java.patch @@ -20,7 +20,7 @@ import net.minecraft.tags.BlockTags; import net.minecraft.util.DamageSource; import net.minecraft.util.SoundEvent; -@@ -48,11 +51,15 @@ +@@ -48,11 +51,16 @@ import net.minecraft.world.BossInfo; import net.minecraft.world.Difficulty; import net.minecraft.world.Explosion; @@ -31,13 +31,14 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory; ++import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; @OnlyIn( value = Dist.CLIENT, -@@ -71,7 +78,7 @@ +@@ -71,7 +79,7 @@ private final int[] field_82223_h = new int[2]; private final int[] field_82224_i = new int[2]; private int field_82222_j; @@ -46,7 +47,7 @@ private static final Predicate field_82219_bJ = (p_213797_0_) -> { return p_213797_0_.func_70668_bt() != CreatureAttribute.field_223223_b_ && p_213797_0_.func_190631_cK(); }; -@@ -213,16 +220,36 @@ +@@ -213,16 +221,36 @@ if (this.func_82212_n() > 0) { int j1 = this.func_82212_n() - 1; if (j1 <= 0) { @@ -88,7 +89,7 @@ } } else { -@@ -268,9 +295,11 @@ +@@ -268,9 +296,11 @@ if (livingentity != this && livingentity.func_70089_S() && this.func_70685_l(livingentity)) { if (livingentity instanceof PlayerEntity) { if (!((PlayerEntity)livingentity).field_71075_bZ.field_75102_a) { @@ -100,7 +101,7 @@ this.func_82211_c(i, livingentity.func_145782_y()); } break; -@@ -290,7 +319,7 @@ +@@ -290,7 +320,7 @@ if (this.field_82222_j > 0) { --this.field_82222_j; @@ -109,7 +110,7 @@ int i1 = MathHelper.func_76128_c(this.func_226278_cu_()); int l1 = MathHelper.func_76128_c(this.func_226277_ct_()); int i2 = MathHelper.func_76128_c(this.func_226281_cx_()); -@@ -304,7 +333,12 @@ +@@ -304,7 +334,12 @@ int l = i2 + l2; BlockPos blockpos = new BlockPos(i3, k, l); BlockState blockstate = this.field_70170_p.func_180495_p(blockpos); @@ -123,8 +124,18 @@ flag = this.field_70170_p.func_225521_a_(blockpos, true, this) || flag; } } -@@ -325,6 +359,7 @@ +@@ -318,13 +353,15 @@ + } + + if (this.field_70173_aa % 20 == 0) { +- this.func_70691_i(1.0F); ++ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit + } + +- this.field_184744_bE.func_186735_a(this.func_110143_aJ() / this.func_110138_aP()); ++ //this.bossInfo.setPercent(this.getHealth() / this.getMaxHealth()); // Paper - Moved down } ++ this.field_184744_bE.func_186735_a(this.func_110143_aJ() / this.func_110138_aP()); // Paper - Fix MC-99259 (Boss bar does not update until Wither invulnerability period ends) } + @Deprecated //Forge: DO NOT USE use BlockState.canEntityDestroy diff --git a/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonEntity.java.patch b/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonEntity.java.patch index cc8d60dbbb..86d6670980 100644 --- a/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/boss/dragon/EnderDragonEntity.java.patch @@ -184,3 +184,20 @@ } } +@@ -712,6 +796,7 @@ + public void func_213281_b(CompoundNBT p_213281_1_) { + super.func_213281_b(p_213281_1_); + p_213281_1_.func_74768_a("DragonPhase", this.field_184677_bJ.func_188756_a().func_188652_i().func_188740_b()); ++ p_213281_1_.func_74768_a("Paper.DeathTick", this.field_70995_bG); // Paper + } + + public void func_70037_a(CompoundNBT p_70037_1_) { +@@ -719,7 +804,7 @@ + if (p_70037_1_.func_74764_b("DragonPhase")) { + this.field_184677_bJ.func_188758_a(PhaseType.func_188738_a(p_70037_1_.func_74762_e("DragonPhase"))); + } +- ++ this.field_70995_bG = p_70037_1_.func_74762_e("Paper.DeathTick"); // Paper + } + + public void func_70623_bb() { diff --git a/patches/minecraft/net/minecraft/entity/boss/dragon/phase/FlamingSittingPhase.java.patch b/patches/minecraft/net/minecraft/entity/boss/dragon/phase/FlamingSittingPhase.java.patch new file mode 100644 index 0000000000..954761c0a7 --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/boss/dragon/phase/FlamingSittingPhase.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/entity/boss/dragon/phase/FlamingSittingPhase.java ++++ b/net/minecraft/entity/boss/dragon/phase/FlamingSittingPhase.java +@@ -59,7 +59,7 @@ + double d3 = d2; + BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(d0, d2, d1); + +- while(this.field_188661_a.field_70170_p.func_175623_d(blockpos$mutable)) { ++ while(this.field_188661_a.field_70170_p.func_175623_d(blockpos$mutable) && d2 > 0) { //Paper + --d3; + if (d3 < 0.0D) { + d3 = d2; diff --git a/patches/minecraft/net/minecraft/entity/item/ArmorStandEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/ArmorStandEntity.java.patch index a1b7ade755..f7f0ce92eb 100644 --- a/patches/minecraft/net/minecraft/entity/item/ArmorStandEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/ArmorStandEntity.java.patch @@ -136,7 +136,7 @@ ItemStack itemstack = this.field_184799_bw.get(i); if (!itemstack.func_190926_b()) { - Block.func_180635_a(this.field_70170_p, this.func_233580_cy_().func_177984_a(), itemstack); -+ drops.add(CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops ++ drops.add(CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops this.field_184799_bw.set(i, ItemStack.field_190927_a); } } @@ -145,7 +145,7 @@ ItemStack itemstack1 = this.field_184800_bx.get(j); if (!itemstack1.func_190926_b()) { - Block.func_180635_a(this.field_70170_p, this.func_233580_cy_().func_177984_a(), itemstack1); -+ drops.add(CraftItemStack.asBukkitCopy(itemstack1)); // CraftBukkit - add to drops ++ drops.add(CraftItemStack.asCraftMirror(itemstack1)); // CraftBukkit - add to drops this.field_184800_bx.set(j, ItemStack.field_190927_a); } } diff --git a/patches/minecraft/net/minecraft/entity/item/FallingBlockEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/FallingBlockEntity.java.patch index 6c2a3d2498..fbffa82ba8 100644 --- a/patches/minecraft/net/minecraft/entity/item/FallingBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/FallingBlockEntity.java.patch @@ -24,7 +24,18 @@ private int field_145815_h = 40; private float field_145816_i = 2.0F; public CompoundNBT field_145810_d; -@@ -100,7 +100,7 @@ +@@ -94,13 +94,18 @@ + } + + public void func_70071_h_() { ++ // Paper start - fix sand duping ++ if (this.field_70128_L) { ++ return; ++ } ++ // Paper end - fix sand duping + if (this.field_175132_d.func_196958_f()) { + this.func_70106_y(); + } else { Block block = this.field_175132_d.func_177230_c(); if (this.field_145812_b++ == 0) { BlockPos blockpos = this.func_233580_cy_(); @@ -33,7 +44,19 @@ this.field_70170_p.func_217377_a(blockpos, false); } else if (!this.field_70170_p.field_72995_K) { this.func_70106_y(); -@@ -148,12 +148,18 @@ +@@ -113,6 +118,11 @@ + } + + this.func_213315_a(MoverType.SELF, this.func_213322_ci()); ++ // Paper start - fix sand duping ++ if (this.field_70128_L) { ++ return; ++ } ++ // Paper end - fix sand duping + if (!this.field_70170_p.field_72995_K) { + BlockPos blockpos1 = this.func_233580_cy_(); + boolean flag = this.field_175132_d.func_177230_c() instanceof ConcretePowderBlock; +@@ -148,12 +158,18 @@ this.field_175132_d = this.field_175132_d.func_206870_a(BlockStateProperties.field_208198_y, Boolean.valueOf(true)); } @@ -53,7 +76,7 @@ TileEntity tileentity = this.field_70170_p.func_175625_s(blockpos1); if (tileentity != null) { CompoundNBT compoundnbt = tileentity.func_189515_b(new CompoundNBT()); -@@ -195,7 +201,9 @@ +@@ -195,7 +211,9 @@ DamageSource damagesource = flag ? DamageSource.field_82728_o : DamageSource.field_82729_p; for(Entity entity : list) { diff --git a/patches/minecraft/net/minecraft/entity/item/ItemEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/ItemEntity.java.patch index ad53f354ce..266d3d970f 100644 --- a/patches/minecraft/net/minecraft/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/ItemEntity.java.patch @@ -63,6 +63,15 @@ this.field_70169_q = this.func_226277_ct_(); this.field_70167_r = this.func_226278_cu_(); +@@ -104,7 +118,7 @@ + } + } + +- if (!this.field_70122_E || func_213296_b(this.func_213322_ci()) > (double)1.0E-5F || (this.field_70173_aa + this.func_145782_y()) % 4 == 0) { ++ if (!this.field_70122_E || func_213296_b(this.func_213322_ci()) > (double)1.0E-5F || this.field_70173_aa % 4 == 0) { // Paper - Ensure checking item movement is always offset from Spigot's entity activation range check + this.func_213315_a(MoverType.SELF, this.func_213322_ci()); + float f1 = 0.98F; + if (this.field_70122_E) { @@ -132,9 +146,11 @@ } } diff --git a/patches/minecraft/net/minecraft/entity/item/ItemFrameEntity.java.patch b/patches/minecraft/net/minecraft/entity/item/ItemFrameEntity.java.patch index a9dc228205..859db3738e 100644 --- a/patches/minecraft/net/minecraft/entity/item/ItemFrameEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/ItemFrameEntity.java.patch @@ -130,7 +130,7 @@ - this.func_184212_Q().func_187227_b(field_184525_c, p_174864_1_); - if (!p_174864_1_.func_190926_b()) { + this.func_184212_Q().func_187227_b(field_184525_c, stack); -+ if (!stack.func_190926_b() && playSound) { // CraftBukkit ++ if (!stack.func_190926_b() && p_174864_2_ && playSound) { // CraftBukkit this.func_184185_a(SoundEvents.field_187620_cL, 1.0F, 1.0F); } diff --git a/patches/minecraft/net/minecraft/entity/player/PlayerEntity.java.patch b/patches/minecraft/net/minecraft/entity/player/PlayerEntity.java.patch index fa53062345..fabd513777 100644 --- a/patches/minecraft/net/minecraft/entity/player/PlayerEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/PlayerEntity.java.patch @@ -1,14 +1,16 @@ --- a/net/minecraft/entity/player/PlayerEntity.java +++ b/net/minecraft/entity/player/PlayerEntity.java -@@ -48,7 +48,6 @@ +@@ -48,8 +48,8 @@ import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.item.ArmorItem; -import net.minecraft.item.AxeItem; import net.minecraft.item.ElytraItem; ++import net.minecraft.item.FilledMapItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -@@ -69,7 +68,6 @@ + import net.minecraft.item.MerchantOffers; +@@ -69,7 +69,6 @@ import net.minecraft.potion.Effects; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; @@ -16,8 +18,11 @@ import net.minecraft.stats.Stat; import net.minecraft.stats.Stats; import net.minecraft.tags.FluidTags; -@@ -108,8 +106,20 @@ +@@ -106,10 +105,23 @@ + import net.minecraft.world.GameType; + import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; ++import net.minecraft.world.storage.MapData; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity; @@ -37,7 +42,7 @@ public static final EntitySize field_213835_bs = EntitySize.func_220314_b(0.6F, 1.8F); private static final Map field_213836_b = ImmutableMap.builder().put(Pose.STANDING, field_213835_bs).put(Pose.SLEEPING, field_213377_as).put(Pose.FALL_FLYING, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.SWIMMING, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.SPIN_ATTACK, EntitySize.func_220314_b(0.6F, 0.6F)).put(Pose.CROUCHING, EntitySize.func_220314_b(0.6F, 1.5F)).put(Pose.DYING, EntitySize.func_220311_c(0.2F, 0.2F)).build(); private static final DataParameter field_184829_a = EntityDataManager.func_187226_a(PlayerEntity.class, DataSerializers.field_187193_c); -@@ -120,10 +130,10 @@ +@@ -120,10 +132,10 @@ protected static final DataParameter field_192033_bu = EntityDataManager.func_187226_a(PlayerEntity.class, DataSerializers.field_192734_n); private long field_223730_e; public final PlayerInventory field_71071_by = new PlayerInventory(this); @@ -51,7 +56,7 @@ protected int field_71101_bC; public float field_71107_bF; public float field_71109_bG; -@@ -134,7 +144,7 @@ +@@ -134,7 +146,7 @@ public double field_71094_bP; public double field_71095_bQ; public double field_71085_bR; @@ -60,7 +65,7 @@ protected boolean field_204230_bP; public final PlayerAbilities field_71075_bZ = new PlayerAbilities(); public int field_71068_ca; -@@ -150,7 +160,20 @@ +@@ -150,7 +162,20 @@ private final CooldownTracker field_184832_bU = this.func_184815_l(); @Nullable public FishingBobberEntity field_71104_cf; @@ -81,7 +86,7 @@ public PlayerEntity(World p_i241920_1_, BlockPos p_i241920_2_, float p_i241920_3_, GameProfile p_i241920_4_) { super(EntityType.field_200729_aH, p_i241920_1_); this.func_184221_a(func_146094_a(p_i241920_4_)); -@@ -175,7 +198,7 @@ +@@ -175,7 +200,7 @@ } public static AttributeModifierMap.MutableAttribute func_234570_el_() { @@ -90,7 +95,7 @@ } protected void func_70088_a() { -@@ -189,6 +212,7 @@ +@@ -189,6 +214,7 @@ } public void func_70071_h_() { @@ -98,7 +103,7 @@ this.field_70145_X = this.func_175149_v(); if (this.func_175149_v()) { this.field_70122_E = false; -@@ -204,7 +228,7 @@ +@@ -204,7 +230,7 @@ this.field_71076_b = 100; } @@ -107,7 +112,7 @@ this.func_225652_a_(false, true); } } else if (this.field_71076_b > 0) { -@@ -258,6 +282,7 @@ +@@ -258,6 +284,7 @@ this.func_203041_m(); this.field_184832_bU.func_185144_a(); this.func_213832_dB(); @@ -115,7 +120,7 @@ } public boolean func_226563_dT_() { -@@ -280,7 +305,7 @@ +@@ -280,7 +307,7 @@ private void func_203041_m() { ItemStack itemstack = this.func_184582_a(EquipmentSlotType.HEAD); if (itemstack.func_77973_b() == Items.field_203179_ao && !this.func_208600_a(FluidTags.field_206959_a)) { @@ -124,7 +129,7 @@ } } -@@ -333,6 +358,10 @@ +@@ -333,6 +360,10 @@ } protected void func_213832_dB() { @@ -135,7 +140,7 @@ if (this.func_213298_c(Pose.SWIMMING)) { Pose pose; if (this.func_184613_cA()) { -@@ -395,7 +424,7 @@ +@@ -395,7 +426,7 @@ return SoundCategory.PLAYERS; } @@ -144,7 +149,7 @@ return 20; } -@@ -466,7 +495,8 @@ +@@ -466,7 +497,8 @@ if (this.field_70170_p.func_175659_aa() == Difficulty.PEACEFUL && this.field_70170_p.func_82736_K().func_223586_b(GameRules.field_223606_i)) { if (this.func_110143_aJ() < this.func_110138_aP() && this.field_70173_aa % 20 == 0) { @@ -154,7 +159,7 @@ } if (this.field_71100_bB.func_75121_c() && this.field_70173_aa % 10 == 0) { -@@ -550,6 +580,7 @@ +@@ -550,6 +582,7 @@ } public void func_70645_a(DamageSource p_70645_1_) { @@ -162,7 +167,7 @@ super.func_70645_a(p_70645_1_); this.func_226264_Z_(); if (!this.func_175149_v()) { -@@ -603,12 +634,14 @@ +@@ -603,12 +636,14 @@ } public boolean func_225609_n_(boolean p_225609_1_) { @@ -179,7 +184,7 @@ } @Nullable -@@ -642,11 +675,38 @@ +@@ -642,11 +677,44 @@ itementity.func_213293_j((double)(-f3 * f2 * 0.3F) + Math.cos((double)f5) * (double)f6, (double)(-f8 * 0.3F + 0.1F + (this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.1F), (double)(f4 * f2 * 0.3F) + Math.sin((double)f5) * (double)f6); } @@ -204,6 +209,12 @@ + return null; + } + // CraftBukkit end ++ // Paper start - remove player from map on drop ++ if (p_146097_1_.func_77973_b() == Items.field_151098_aY) { ++ MapData worldmap = FilledMapItem.func_195950_a(p_146097_1_, this.field_70170_p); ++ worldmap.updateSeenPlayers(this, p_146097_1_); ++ } ++ // Paper end + return itementity; } @@ -218,7 +229,7 @@ float f = this.field_71071_by.func_184438_a(p_184813_1_); if (f > 1.0F) { int i = EnchantmentHelper.func_185293_e(this); -@@ -688,11 +748,12 @@ +@@ -688,11 +756,12 @@ f /= 5.0F; } @@ -232,7 +243,7 @@ } public void func_70037_a(CompoundNBT p_70037_1_) { -@@ -767,16 +828,18 @@ +@@ -767,16 +836,18 @@ } public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { @@ -252,7 +263,7 @@ if (p_70097_1_.func_76350_n()) { if (this.field_70170_p.func_175659_aa() == Difficulty.PEACEFUL) { p_70097_2_ = 0.0F; -@@ -791,27 +854,49 @@ +@@ -791,27 +862,49 @@ } } @@ -309,7 +320,7 @@ } protected void func_230294_b_(DamageSource p_230294_1_, float p_230294_2_) { -@@ -819,7 +904,7 @@ +@@ -819,7 +912,7 @@ } protected void func_184590_k(float p_184590_1_) { @@ -318,7 +329,7 @@ if (!this.field_70170_p.field_72995_K) { this.func_71029_a(Stats.field_75929_E.func_199076_b(this.field_184627_bm.func_77973_b())); } -@@ -829,6 +914,7 @@ +@@ -829,6 +922,7 @@ Hand hand = this.func_184600_cs(); this.field_184627_bm.func_222118_a(i, this, (p_213833_1_) -> { p_213833_1_.func_213334_d(hand); @@ -326,7 +337,7 @@ }); if (this.field_184627_bm.func_190926_b()) { if (hand == Hand.MAIN_HAND) { -@@ -846,28 +932,45 @@ +@@ -846,28 +940,45 @@ } protected void func_70665_d(DamageSource p_70665_1_, float p_70665_2_) { @@ -380,7 +391,7 @@ protected boolean func_230296_cM_() { return !this.field_71075_bZ.field_75100_b && super.func_230296_cM_(); -@@ -909,6 +1012,8 @@ +@@ -909,6 +1020,8 @@ return ActionResultType.PASS; } else { @@ -389,7 +400,7 @@ ItemStack itemstack = this.func_184586_b(p_190775_2_); ItemStack itemstack1 = itemstack.func_77946_l(); ActionResultType actionresulttype = p_190775_1_.func_184230_a(this, p_190775_2_); -@@ -917,6 +1022,9 @@ +@@ -917,6 +1030,9 @@ itemstack.func_190920_e(itemstack1.func_190916_E()); } @@ -399,7 +410,7 @@ return actionresulttype; } else { if (!itemstack.func_190926_b() && p_190775_1_ instanceof LivingEntity) { -@@ -927,6 +1035,7 @@ +@@ -927,6 +1043,7 @@ ActionResultType actionresulttype1 = itemstack.func_111282_a_(this, (LivingEntity)p_190775_1_, p_190775_2_); if (actionresulttype1.func_226246_a_()) { if (itemstack.func_190926_b() && !this.field_71075_bZ.field_75098_d) { @@ -407,7 +418,7 @@ this.func_184611_a(p_190775_2_, ItemStack.field_190927_a); } -@@ -1011,6 +1120,7 @@ +@@ -1011,6 +1128,7 @@ } public void func_71059_n(Entity p_71059_1_) { @@ -415,7 +426,7 @@ if (p_71059_1_.func_70075_an()) { if (!p_71059_1_.func_85031_j(this)) { float f = (float)this.func_233637_b_(Attributes.field_233823_f_); -@@ -1024,7 +1134,7 @@ +@@ -1024,7 +1142,7 @@ float f2 = this.func_184825_o(0.5F); f = f * (0.2F + f2 * f2 * 0.8F); f1 = f1 * f2; @@ -424,7 +435,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -1038,8 +1148,10 @@ +@@ -1038,8 +1156,10 @@ boolean flag2 = flag && this.field_70143_R > 0.0F && !this.field_70122_E && !this.func_70617_f_() && !this.func_70090_H() && !this.func_70644_a(Effects.field_76440_q) && !this.func_184218_aH() && p_71059_1_ instanceof LivingEntity; flag2 = flag2 && !this.func_70051_ag(); @@ -436,7 +447,7 @@ } f = f + f1; -@@ -1058,8 +1170,14 @@ +@@ -1058,8 +1178,14 @@ if (p_71059_1_ instanceof LivingEntity) { f4 = ((LivingEntity)p_71059_1_).func_110143_aJ(); if (j > 0 && !p_71059_1_.func_70027_ad()) { @@ -452,7 +463,7 @@ } } -@@ -1082,8 +1200,11 @@ +@@ -1082,8 +1208,11 @@ for(LivingEntity livingentity : this.field_70170_p.func_217357_a(LivingEntity.class, p_71059_1_.func_174813_aQ().func_72314_b(1.0D, 0.25D, 1.0D))) { if (livingentity != this && livingentity != p_71059_1_ && !this.func_184191_r(livingentity) && (!(livingentity instanceof ArmorStandEntity) || !((ArmorStandEntity)livingentity).func_181026_s()) && this.func_70068_e(livingentity) < 9.0D) { @@ -466,7 +477,7 @@ } } -@@ -1092,9 +1213,23 @@ +@@ -1092,9 +1221,23 @@ } if (p_71059_1_ instanceof ServerPlayerEntity && p_71059_1_.field_70133_I) { @@ -491,7 +502,7 @@ } if (flag2) { -@@ -1127,8 +1262,10 @@ +@@ -1127,8 +1270,10 @@ } if (!this.field_70170_p.field_72995_K && !itemstack1.func_190926_b() && entity instanceof LivingEntity) { @@ -502,7 +513,7 @@ this.func_184611_a(Hand.MAIN_HAND, ItemStack.field_190927_a); } } -@@ -1137,7 +1274,13 @@ +@@ -1137,7 +1282,13 @@ float f5 = f4 - ((LivingEntity)p_71059_1_).func_110143_aJ(); this.func_195067_a(Stats.field_188111_y, Math.round(f5 * 10.0F)); if (j > 0) { @@ -517,7 +528,7 @@ } if (this.field_70170_p instanceof ServerWorld && f5 > 2.0F) { -@@ -1146,12 +1289,17 @@ +@@ -1146,12 +1297,17 @@ } } @@ -536,7 +547,7 @@ } } -@@ -1170,7 +1318,7 @@ +@@ -1170,7 +1326,7 @@ } if (this.field_70146_Z.nextFloat() < f) { @@ -545,7 +556,7 @@ this.func_184602_cy(); this.field_70170_p.func_72960_a(this, (byte)30); } -@@ -1196,8 +1344,9 @@ +@@ -1196,8 +1352,9 @@ public void func_71004_bE() { } @@ -557,7 +568,7 @@ this.field_71069_bz.func_75134_a(this); if (this.field_71070_bA != null) { this.field_71070_bA.func_75134_a(this); -@@ -1214,17 +1363,39 @@ +@@ -1214,17 +1371,39 @@ } public Either func_213819_a(BlockPos p_213819_1_) { @@ -598,7 +609,7 @@ this.field_71076_b = p_225652_1_ ? 0 : 100; } -@@ -1242,8 +1413,8 @@ +@@ -1242,8 +1421,8 @@ } return optional; @@ -609,7 +620,7 @@ } else if (!p_242374_3_) { return Optional.empty(); } else { -@@ -1297,9 +1468,9 @@ +@@ -1297,9 +1476,9 @@ super.func_70664_aZ(); this.func_195066_a(Stats.field_75953_u); if (this.func_70051_ag()) { @@ -621,7 +632,7 @@ } } -@@ -1326,7 +1497,11 @@ +@@ -1326,7 +1505,11 @@ this.func_213293_j(vector3d.field_72450_a, d5 * 0.6D, vector3d.field_72449_c); this.field_70747_aH = f; this.field_70143_R = 0.0F; @@ -634,7 +645,7 @@ } else { super.func_213352_e(p_213352_1_); } -@@ -1357,19 +1532,19 @@ +@@ -1357,19 +1540,19 @@ int i = Math.round(MathHelper.func_76133_a(p_71000_1_ * p_71000_1_ + p_71000_3_ * p_71000_3_ + p_71000_5_ * p_71000_5_) * 100.0F); if (i > 0) { this.func_195067_a(Stats.field_75946_m, i); @@ -657,7 +668,7 @@ } } else if (this.func_70617_f_()) { if (p_71000_3_ > 0.0D) { -@@ -1380,13 +1555,13 @@ +@@ -1380,13 +1563,13 @@ if (l > 0) { if (this.func_70051_ag()) { this.func_195067_a(Stats.field_188102_l, l); @@ -674,7 +685,7 @@ } } } else if (this.func_184613_cA()) { -@@ -1425,6 +1600,7 @@ +@@ -1425,6 +1608,7 @@ public boolean func_225503_b_(float p_225503_1_, float p_225503_2_) { if (this.field_71075_bZ.field_75101_c) { @@ -682,7 +693,7 @@ return false; } else { if (p_225503_1_ >= 2.0F) { -@@ -1438,7 +1614,7 @@ +@@ -1438,7 +1622,7 @@ public boolean func_226566_ei_() { if (!this.field_70122_E && !this.func_184613_cA() && !this.func_70090_H() && !this.func_70644_a(Effects.field_188424_y)) { ItemStack itemstack = this.func_184582_a(EquipmentSlotType.CHEST); @@ -691,7 +702,7 @@ this.func_226567_ej_(); return true; } -@@ -1448,12 +1624,24 @@ +@@ -1448,12 +1632,24 @@ } public void func_226567_ej_() { @@ -719,7 +730,7 @@ } protected void func_71061_d_() { -@@ -1479,6 +1667,10 @@ +@@ -1479,6 +1675,10 @@ } public void func_195068_e(int p_195068_1_) { @@ -730,7 +741,7 @@ this.func_85039_t(p_195068_1_); this.field_71106_cc += (float)p_195068_1_ / (float)this.func_71050_bK(); this.field_71067_cb = MathHelper.func_76125_a(this.field_71067_cb + p_195068_1_, 0, Integer.MAX_VALUE); -@@ -1507,7 +1699,7 @@ +@@ -1507,7 +1707,7 @@ } public void func_192024_a(ItemStack p_192024_1_, int p_192024_2_) { @@ -739,7 +750,7 @@ if (this.field_71068_ca < 0) { this.field_71068_ca = 0; this.field_71106_cc = 0.0F; -@@ -1518,6 +1710,10 @@ +@@ -1518,6 +1718,10 @@ } public void func_82242_a(int p_82242_1_) { @@ -750,7 +761,7 @@ this.field_71068_ca += p_82242_1_; if (this.field_71068_ca < 0) { this.field_71068_ca = 0; -@@ -1669,26 +1865,34 @@ +@@ -1669,26 +1873,34 @@ protected void func_192030_dh() { if (this.field_223730_e + 20L < this.field_70170_p.func_82737_E()) { @@ -792,7 +803,7 @@ } public abstract boolean func_175149_v(); -@@ -1708,7 +1912,11 @@ +@@ -1708,7 +1920,11 @@ } public ITextComponent func_145748_c_() { @@ -805,7 +816,7 @@ return this.func_208016_c(iformattabletextcomponent); } -@@ -1841,7 +2049,7 @@ +@@ -1841,7 +2057,7 @@ return this.field_70180_af.func_187225_a(field_192032_bt); } @@ -814,7 +825,7 @@ this.field_70180_af.func_187227_b(field_192032_bt, p_192029_1_); } -@@ -1849,7 +2057,7 @@ +@@ -1849,7 +2065,7 @@ return this.field_70180_af.func_187225_a(field_192033_bu); } @@ -823,7 +834,7 @@ this.field_70180_af.func_187227_b(field_192033_bu, p_192031_1_); } -@@ -1987,4 +2195,62 @@ +@@ -1987,4 +2203,62 @@ return this.field_221260_g; } } diff --git a/patches/minecraft/net/minecraft/entity/player/ServerPlayerEntity.java.patch b/patches/minecraft/net/minecraft/entity/player/ServerPlayerEntity.java.patch index a4036c1848..c242e7949d 100644 --- a/patches/minecraft/net/minecraft/entity/player/ServerPlayerEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/ServerPlayerEntity.java.patch @@ -158,7 +158,15 @@ int i = Math.max(0, this.field_71133_b.func_184108_a(p_205734_1_)); int j = MathHelper.func_76128_c(p_205734_1_.func_175723_af().func_177729_b((double)blockpos.func_177958_n(), (double)blockpos.func_177952_p())); if (j < i) { -@@ -251,11 +320,20 @@ +@@ -234,6 +303,7 @@ + + public void func_70037_a(CompoundNBT p_70037_1_) { + super.func_70037_a(p_70037_1_); ++ if (this.func_226278_cu_() > 300) this.func_226288_n_(func_226277_ct_(), 257, func_226281_cx_()); // Paper - bring down to a saner Y level if out of world + if (p_70037_1_.func_150297_b("playerGameType", 99)) { + if (this.func_184102_h().func_104056_am()) { + this.field_71134_c.func_241820_a(this.func_184102_h().func_71265_f(), GameType.NOT_SET); +@@ -251,11 +321,20 @@ if (p_70037_1_.func_150297_b("recipeBook", 10)) { this.field_192041_cq.func_192825_a(p_70037_1_.func_74775_l("recipeBook"), this.field_71133_b.func_199529_aN()); } @@ -179,7 +187,7 @@ if (p_70037_1_.func_150297_b("SpawnX", 99) && p_70037_1_.func_150297_b("SpawnY", 99) && p_70037_1_.func_150297_b("SpawnZ", 99)) { this.field_241138_cr_ = new BlockPos(p_70037_1_.func_74762_e("SpawnX"), p_70037_1_.func_74762_e("SpawnY"), p_70037_1_.func_74762_e("SpawnZ")); this.field_241139_cs_ = p_70037_1_.func_74767_n("SpawnForced"); -@@ -282,7 +360,19 @@ +@@ -282,7 +361,19 @@ Entity entity1 = this.func_184208_bv(); Entity entity = this.func_184187_bx(); @@ -200,7 +208,7 @@ CompoundNBT compoundnbt1 = new CompoundNBT(); CompoundNBT compoundnbt2 = new CompoundNBT(); entity1.func_70039_c(compoundnbt2); -@@ -303,8 +393,31 @@ +@@ -303,8 +394,31 @@ p_213281_1_.func_218657_a("SpawnDimension", p_241148_1_); }); } @@ -232,7 +240,7 @@ public void func_195394_a(int p_195394_1_) { float f = (float)this.func_71050_bK(); -@@ -351,6 +464,11 @@ +@@ -351,6 +465,11 @@ } public void func_70071_h_() { @@ -244,7 +252,7 @@ this.field_71134_c.func_73075_a(); --this.field_147101_bU; if (this.field_70172_ad > 0) { -@@ -415,7 +533,7 @@ +@@ -415,7 +534,7 @@ } if (this.func_110143_aJ() != this.field_71149_ch || this.field_71146_ci != this.field_71100_bB.func_75116_a() || this.field_71100_bB.func_75115_e() == 0.0F != this.field_71147_cj) { @@ -253,7 +261,7 @@ this.field_71149_ch = this.func_110143_aJ(); this.field_71146_ci = this.field_71100_bB.func_75116_a(); this.field_71147_cj = this.field_71100_bB.func_75115_e() == 0.0F; -@@ -446,6 +564,12 @@ +@@ -446,6 +565,12 @@ this.func_184849_a(ScoreCriteria.field_186701_k, MathHelper.func_76123_f((float)this.field_184856_bZ)); } @@ -266,7 +274,7 @@ if (this.field_71068_ca != this.field_184855_bY) { this.field_184855_bY = this.field_71068_ca; this.func_184849_a(ScoreCriteria.field_186702_l, MathHelper.func_76123_f((float)this.field_184855_bY)); -@@ -460,6 +584,16 @@ +@@ -460,6 +585,16 @@ CriteriaTriggers.field_192135_o.func_192215_a(this); } @@ -283,7 +291,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.func_85055_a(throwable, "Ticking player"); CrashReportCategory crashreportcategory = crashreport.func_85058_a("Player being ticked"); -@@ -469,15 +603,48 @@ +@@ -469,15 +604,48 @@ } private void func_184849_a(ScoreCriteria p_184849_1_, int p_184849_2_) { @@ -335,7 +343,7 @@ this.field_71135_a.func_211148_a(new SCombatPacket(this.func_110142_aN(), SCombatPacket.Event.ENTITY_DIED, itextcomponent), (p_212356_2_) -> { if (!p_212356_2_.isSuccess()) { int i = 256; -@@ -509,11 +676,20 @@ +@@ -509,11 +677,20 @@ this.func_241157_eT_(); } @@ -359,7 +367,7 @@ LivingEntity livingentity = this.func_94060_bK(); if (livingentity != null) { this.func_71029_a(Stats.field_199091_i.func_199076_b(livingentity.func_200600_R())); -@@ -545,10 +721,12 @@ +@@ -545,10 +722,12 @@ this.func_85039_t(p_191956_2_); String s = this.func_195047_I_(); String s1 = p_191956_1_.func_195047_I_(); @@ -374,7 +382,7 @@ } else { this.func_195066_a(Stats.field_188070_B); } -@@ -564,7 +742,8 @@ +@@ -564,7 +743,8 @@ if (scoreplayerteam != null) { int i = scoreplayerteam.func_178775_l().func_175746_b(); if (i >= 0 && i < p_195398_3_.length) { @@ -384,7 +392,7 @@ } } -@@ -603,28 +782,44 @@ +@@ -603,28 +783,44 @@ } private boolean func_175400_cq() { @@ -435,7 +443,7 @@ if (!this.field_71136_j) { this.field_71136_j = true; this.field_71135_a.func_147359_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241768_e_, this.field_192040_cp ? 0.0F : 1.0F)); -@@ -633,36 +828,46 @@ +@@ -633,36 +829,46 @@ return this; } else { @@ -502,10 +510,11 @@ this.field_71135_a.func_147359_a(new SPlayEntityEffectPacket(this.func_145782_y(), effectinstance)); } -@@ -670,6 +875,11 @@ +@@ -670,6 +876,12 @@ this.field_71144_ck = -1; this.field_71149_ch = -1.0F; this.field_71146_ci = -1; ++ func_226284_e_(false); // Paper - fix MC-10657 + net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerChangedDimensionEvent(this, registrykey, server.func_234923_W_()); + // CraftBukkit start + PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), serverworld.getCBWorld()); @@ -514,7 +523,7 @@ } return this; -@@ -690,22 +900,22 @@ +@@ -690,22 +902,22 @@ } @@ -541,7 +550,7 @@ RegistryKey registrykey = p_213846_1_.func_234923_W_(); RegistryKey registrykey1 = this.field_70170_p.func_234923_W_(); CriteriaTriggers.field_193134_u.func_233551_a_(this, registrykey, registrykey1); -@@ -742,43 +952,80 @@ +@@ -742,43 +954,80 @@ this.field_71070_bA.func_75142_b(); } @@ -636,7 +645,7 @@ } public void func_213342_e(BlockPos p_213342_1_) { -@@ -787,6 +1034,7 @@ +@@ -787,6 +1036,7 @@ } private boolean func_241147_a_(BlockPos p_241147_1_, Direction p_241147_2_) { @@ -644,7 +653,7 @@ return this.func_241158_g_(p_241147_1_) || this.func_241158_g_(p_241147_1_.func_177972_a(p_241147_2_.func_176734_d())); } -@@ -801,6 +1049,7 @@ +@@ -801,6 +1051,7 @@ } public void func_225652_a_(boolean p_225652_1_, boolean p_225652_2_) { @@ -652,7 +661,7 @@ if (this.func_70608_bn()) { this.func_71121_q().func_72863_F().func_217216_a(this, new SAnimateHandPacket(this, 2)); } -@@ -866,6 +1115,13 @@ +@@ -866,6 +1117,13 @@ this.field_71139_cq = this.field_71139_cq % 100 + 1; } @@ -666,7 +675,7 @@ public OptionalInt func_213829_a(@Nullable INamedContainerProvider p_213829_1_) { if (p_213829_1_ == null) { return OptionalInt.empty(); -@@ -876,16 +1132,37 @@ +@@ -876,16 +1134,37 @@ this.func_71117_bO(); Container container = p_213829_1_.createMenu(this.field_71139_cq, this.field_71071_by, this); @@ -707,7 +716,7 @@ return OptionalInt.of(this.field_71139_cq); } } -@@ -896,14 +1173,26 @@ +@@ -896,14 +1175,26 @@ } public void func_184826_a(AbstractHorseEntity p_184826_1_, IInventory p_184826_2_) { @@ -736,7 +745,7 @@ } public void func_184814_a(ItemStack p_184814_1_, Hand p_184814_2_) { -@@ -942,6 +1231,11 @@ +@@ -942,6 +1233,11 @@ public void func_71110_a(Container p_71110_1_, NonNullList p_71110_2_) { this.field_71135_a.func_147359_a(new SWindowItemsPacket(p_71110_1_.field_75152_c, p_71110_2_)); this.field_71135_a.func_147359_a(new SSetSlotPacket(-1, -1, this.field_71071_by.func_70445_o())); @@ -748,7 +757,7 @@ } public void func_71112_a(Container p_71112_1_, int p_71112_2_, int p_71112_3_) { -@@ -949,6 +1243,7 @@ +@@ -949,6 +1245,7 @@ } public void func_71053_j() { @@ -756,7 +765,7 @@ this.field_71135_a.func_147359_a(new SCloseWindowPacket(this.field_71070_bA.field_75152_c)); this.func_71128_l(); } -@@ -961,6 +1256,7 @@ +@@ -961,6 +1258,7 @@ public void func_71128_l() { this.field_71070_bA.func_75134_a(this); @@ -764,7 +773,7 @@ this.field_71070_bA = this.field_71069_bz; } -@@ -982,14 +1278,14 @@ +@@ -982,14 +1280,14 @@ public void func_71064_a(Stat p_71064_1_, int p_71064_2_) { this.field_147103_bO.func_150871_b(this, p_71064_1_, p_71064_2_); @@ -781,7 +790,7 @@ } public int func_195065_a(Collection> p_195065_1_) { -@@ -1030,8 +1326,17 @@ +@@ -1030,8 +1328,17 @@ public void func_71118_n() { this.field_71149_ch = -1.0E8F; @@ -799,7 +808,7 @@ public void func_146105_b(ITextComponent p_146105_1_, boolean p_146105_2_) { this.field_71135_a.func_147359_a(new SChatPacket(p_146105_1_, p_146105_2_ ? ChatType.GAME_INFO : ChatType.CHAT, Util.field_240973_b_)); } -@@ -1079,12 +1384,19 @@ +@@ -1079,12 +1386,19 @@ this.field_71144_ck = -1; this.field_71149_ch = -1.0F; this.field_71146_ci = -1; @@ -820,7 +829,7 @@ } protected void func_70670_a(EffectInstance p_70670_1_) { -@@ -1143,6 +1455,8 @@ +@@ -1143,6 +1457,8 @@ } public void func_71033_a(GameType p_71033_1_) { @@ -829,7 +838,7 @@ this.field_71134_c.func_73076_a(p_71033_1_); this.field_71135_a.func_147359_a(new SChangeGameStatePacket(SChangeGameStatePacket.field_241767_d_, (float)p_71033_1_.func_77148_a())); if (p_71033_1_ == GameType.SPECTATOR) { -@@ -1187,10 +1501,22 @@ +@@ -1187,10 +1503,22 @@ } public void func_147100_a(CClientSettingsPacket p_147100_1_) { @@ -852,7 +861,7 @@ } public ChatVisibility func_147096_v() { -@@ -1249,7 +1575,7 @@ +@@ -1249,7 +1577,7 @@ this.field_175401_bS = (Entity)(p_175399_1_ == null ? this : p_175399_1_); if (entity != this.field_175401_bS) { this.field_71135_a.func_147359_a(new SCameraPacket(this.field_175401_bS)); @@ -861,7 +870,7 @@ } } -@@ -1276,7 +1602,7 @@ +@@ -1276,7 +1604,7 @@ @Nullable public ITextComponent func_175396_E() { @@ -870,7 +879,7 @@ } public void func_184609_a(Hand p_184609_1_) { -@@ -1296,27 +1622,34 @@ +@@ -1296,27 +1624,34 @@ return this.field_192042_bX; } @@ -918,7 +927,7 @@ } } -@@ -1339,6 +1672,7 @@ +@@ -1339,6 +1674,7 @@ } public void func_242111_a(RegistryKey p_242111_1_, @Nullable BlockPos p_242111_2_, float p_242111_3_, boolean p_242111_4_, boolean p_242111_5_) { @@ -926,7 +935,7 @@ if (p_242111_2_ != null) { boolean flag = p_242111_2_.equals(this.field_241138_cr_) && p_242111_1_.equals(this.field_241137_cq_); if (p_242111_5_ && !flag) { -@@ -1391,6 +1725,8 @@ +@@ -1391,6 +1727,8 @@ if (itementity == null) { return null; } else { @@ -935,7 +944,7 @@ this.field_70170_p.func_217376_c(itementity); ItemStack itemstack = itementity.func_92059_d(); if (p_146097_3_) { -@@ -1405,8 +1741,136 @@ +@@ -1405,8 +1743,136 @@ } } @@ -1028,8 +1037,8 @@ + this.field_71135_a.func_184342_d(); + } + @Override -+ public boolean func_70610_aX() { // protected->public CraftBukkit -+ return super.func_70610_aX() || !getBukkitEntity().isOnline(); ++ public boolean func_70610_aX() { ++ return super.func_70610_aX() || (this.field_71135_a != null && this.field_71135_a.isDisconnected()); // Paper + } + @Override + public Scoreboard func_96123_co() { diff --git a/patches/minecraft/net/minecraft/entity/projectile/AbstractArrowEntity.java.patch b/patches/minecraft/net/minecraft/entity/projectile/AbstractArrowEntity.java.patch index 7df9b961c4..86ad6ae786 100644 --- a/patches/minecraft/net/minecraft/entity/projectile/AbstractArrowEntity.java.patch +++ b/patches/minecraft/net/minecraft/entity/projectile/AbstractArrowEntity.java.patch @@ -46,7 +46,15 @@ VoxelShape voxelshape = blockstate.func_196952_d(this.field_70170_p, blockpos); if (!voxelshape.func_197766_b()) { Vector3d vector3d1 = this.func_213303_ch(); -@@ -184,7 +191,7 @@ +@@ -161,6 +168,7 @@ + + ++this.field_184552_b; + } else { ++ if (field_70173_aa > 200) this.tickDespawnCounter(); // Paper - tick despawnCounter regardless after 10 seconds + this.field_184552_b = 0; + Vector3d vector3d2 = this.func_213303_ch(); + Vector3d vector3d3 = vector3d2.func_178787_e(vector3d); +@@ -184,7 +192,7 @@ } } @@ -55,8 +63,11 @@ this.func_70227_a(raytraceresult); this.field_70160_al = true; } -@@ -262,7 +269,7 @@ +@@ -260,9 +268,10 @@ + + } ++ protected final void tickDespawnCounter() { this.func_225516_i_(); } // Paper - OBFHELPER protected void func_225516_i_() { ++this.field_70252_j; - if (this.field_70252_j >= 1200) { @@ -64,7 +75,7 @@ this.func_70106_y(); } -@@ -320,7 +327,13 @@ +@@ -320,7 +329,13 @@ boolean flag = entity.func_200600_R() == EntityType.field_200803_q; int k = entity.func_223314_ad(); if (this.func_70027_ad() && !flag) { @@ -79,7 +90,7 @@ } if (entity.func_70097_a(damagesource, (float)i)) { -@@ -477,8 +490,20 @@ +@@ -477,8 +492,20 @@ public void func_70100_b_(PlayerEntity p_70100_1_) { if (!this.field_70170_p.field_72995_K && (this.field_70254_i || this.func_203047_q()) && this.field_70249_b <= 0) { diff --git a/patches/minecraft/net/minecraft/inventory/container/HorseInventoryContainer.java.patch b/patches/minecraft/net/minecraft/inventory/container/HorseInventoryContainer.java.patch index 9bbe4c6ad1..b06ff19cee 100644 --- a/patches/minecraft/net/minecraft/inventory/container/HorseInventoryContainer.java.patch +++ b/patches/minecraft/net/minecraft/inventory/container/HorseInventoryContainer.java.patch @@ -32,3 +32,12 @@ int i = 3; p_i50077_3_.func_174889_b(p_i50077_2_.field_70458_d); int j = -18; +@@ -66,7 +82,7 @@ + } + + public boolean func_75145_c(PlayerEntity p_75145_1_) { +- return this.field_111243_a.func_70300_a(p_75145_1_) && this.field_111242_f.func_70089_S() && this.field_111242_f.func_70032_d(p_75145_1_) < 8.0F; ++ return this.field_111243_a.func_70300_a(p_75145_1_) && (this.field_111242_f.func_70089_S() && this.field_111242_f.valid) && this.field_111242_f.func_70032_d(p_75145_1_) < 8.0F; // Paper - Fix MC-161754 + } + + public ItemStack func_82846_b(PlayerEntity p_82846_1_, int p_82846_2_) { diff --git a/patches/minecraft/net/minecraft/item/FilledMapItem.java.patch b/patches/minecraft/net/minecraft/item/FilledMapItem.java.patch index d4b1d2eeb1..fc1eae0eae 100644 --- a/patches/minecraft/net/minecraft/item/FilledMapItem.java.patch +++ b/patches/minecraft/net/minecraft/item/FilledMapItem.java.patch @@ -47,3 +47,12 @@ return mapdata; } +@@ -226,7 +243,7 @@ + + for(int l = 0; l < 128 * i; ++l) { + for(int i1 = 0; i1 < 128 * i; ++i1) { +- abiome[l * 128 * i + i1] = p_226642_0_.func_226691_t_(new BlockPos((j / i - 64) * i + i1, 0, (k / i - 64) * i + l)); ++ abiome[l * 128 * i + i1] = p_226642_0_.getBiomeBySeed((j / i - 64) * i + i1, 0, (k / i - 64) * i + l); // Paper + } + } + diff --git a/patches/minecraft/net/minecraft/item/MerchantOffer.java.patch b/patches/minecraft/net/minecraft/item/MerchantOffer.java.patch index 78c09d64e4..91b50c4744 100644 --- a/patches/minecraft/net/minecraft/item/MerchantOffer.java.patch +++ b/patches/minecraft/net/minecraft/item/MerchantOffer.java.patch @@ -50,6 +50,15 @@ ItemStack itemstack = this.field_222223_a.func_77946_l(); int j = Math.max(0, MathHelper.func_76141_d((float)(i * this.field_222230_h) * this.field_222231_i)); itemstack.func_190920_e(MathHelper.func_76125_a(i + j + this.field_222229_g, 1, this.field_222223_a.func_77973_b().func_77639_j())); +@@ -87,7 +102,7 @@ + } + + public void func_222222_e() { +- this.field_222230_h = this.field_222230_h + this.field_222226_d - (this.field_222227_e - this.field_222226_d); ++ this.field_222230_h = Math.max(0, this.field_222230_h + this.field_222226_d - (this.field_222227_e - this.field_222226_d)); // Paper + } + + public ItemStack func_222206_f() { @@ -178,7 +193,7 @@ return true; } else { diff --git a/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipe.java.patch b/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipe.java.patch index 4f804f5452..f6ca02fcfa 100644 --- a/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipe.java.patch +++ b/patches/minecraft/net/minecraft/item/crafting/ShapelessRecipe.java.patch @@ -1,6 +1,14 @@ --- a/net/minecraft/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/item/crafting/ShapelessRecipe.java -@@ -11,20 +11,38 @@ +@@ -4,6 +4,7 @@ + import com.google.gson.JsonObject; + import com.google.gson.JsonParseException; + import it.unimi.dsi.fastutil.ints.IntList; ++import java.util.Iterator; + import net.minecraft.inventory.CraftingInventory; + import net.minecraft.item.ItemStack; + import net.minecraft.network.PacketBuffer; +@@ -11,20 +12,38 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; @@ -39,7 +47,7 @@ public ResourceLocation func_199560_c() { return this.field_199562_a; } -@@ -33,7 +51,7 @@ +@@ -33,7 +52,7 @@ return IRecipeSerializer.field_222158_b; } @@ -48,29 +56,67 @@ return this.field_194138_c; } -@@ -47,17 +65,20 @@ +@@ -47,17 +66,56 @@ public boolean func_77569_a(CraftingInventory p_77569_1_, World p_77569_2_) { RecipeItemHelper recipeitemhelper = new RecipeItemHelper(); + java.util.List inputs = new java.util.ArrayList<>(); int i = 0; ++ // Paper start ++ java.util.List providedItems = new java.util.ArrayList<>(); ++ co.aikar.util.Counter matchedProvided = new co.aikar.util.Counter<>(); ++ co.aikar.util.Counter matchedIngredients = new co.aikar.util.Counter<>(); ++ // Paper end for(int j = 0; j < p_77569_1_.func_70302_i_(); ++j) { ItemStack itemstack = p_77569_1_.func_70301_a(j); if (!itemstack.func_190926_b()) { - ++i; -+ if (isSimple) - recipeitemhelper.func_221264_a(itemstack, 1); -+ else inputs.add(itemstack); +- ++i; +- recipeitemhelper.func_221264_a(itemstack, 1); ++ if (isSimple) { ++ // Paper start ++ itemstack = itemstack.func_77946_l(); ++ providedItems.add(itemstack); ++ for (Ingredient ingredient : field_77579_b) { ++ if (ingredient.test(itemstack)) { ++ matchedProvided.increment(itemstack); ++ matchedIngredients.increment(ingredient); ++ } ++ } ++ // Paper end ++ } else { ++ inputs.add(itemstack); ++ } } } - return i == this.field_77579_b.size() && recipeitemhelper.func_194116_a(this, (IntList)null); -+ return i == this.field_77579_b.size() && (isSimple ? recipeitemhelper.func_194116_a(this, (IntList)null) : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.field_77579_b) != null); ++ //return i == this.recipeItems.size() && (isSimple ? recipeitemhelper.canCraft(this, (IntList)null) : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.recipeItems) != null); ++ // Paper start ++ if (matchedProvided.isEmpty() || matchedIngredients.isEmpty()) { ++ return false; ++ } ++ java.util.List ingredients = new java.util.ArrayList<>(this.field_77579_b); ++ providedItems.sort(java.util.Comparator.comparingInt((ItemStack c) -> (int) matchedProvided.getCount(c)).reversed()); ++ ingredients.sort(java.util.Comparator.comparingInt((Ingredient c) -> (int) matchedIngredients.getCount(c))); ++ ++ PROVIDED: ++ for (ItemStack provided : providedItems) { ++ for (Iterator itIngredient = ingredients.iterator(); itIngredient.hasNext(); ) { ++ Ingredient ingredient = itIngredient.next(); ++ if (ingredient.test(provided)) { ++ itIngredient.remove(); ++ continue PROVIDED; ++ } ++ } ++ return false; ++ } ++ return isSimple ? ingredients.isEmpty() : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.field_77579_b) != null; ++ // Paper end } public ItemStack func_77572_b(CraftingInventory p_77572_1_) { -@@ -68,14 +89,15 @@ +@@ -68,14 +126,15 @@ return p_194133_1_ * p_194133_2_ >= this.field_77579_b.size(); } diff --git a/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch b/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch index 8baa9d687c..336d4cb39d 100644 --- a/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch +++ b/patches/minecraft/net/minecraft/network/PacketBuffer.java.patch @@ -1,6 +1,14 @@ --- a/net/minecraft/network/PacketBuffer.java +++ b/net/minecraft/network/PacketBuffer.java -@@ -38,8 +38,9 @@ +@@ -29,6 +29,7 @@ + import net.minecraft.nbt.INBT; + import net.minecraft.nbt.NBTDynamicOps; + import net.minecraft.nbt.NBTSizeTracker; ++import net.minecraft.tileentity.SkullTileEntity; + import net.minecraft.util.Direction; + import net.minecraft.util.ResourceLocation; + import net.minecraft.util.math.BlockPos; +@@ -38,8 +39,9 @@ import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -11,7 +19,7 @@ private final ByteBuf field_150794_a; public PacketBuffer(ByteBuf p_i45154_1_) { -@@ -256,7 +257,7 @@ +@@ -256,7 +258,7 @@ } else { try { CompressedStreamTools.func_74800_a(p_150786_1_, new ByteBufOutputStream(this)); @@ -20,7 +28,7 @@ throw new EncoderException(ioexception); } } -@@ -292,7 +293,16 @@ +@@ -292,7 +294,16 @@ } public PacketBuffer func_150788_a(ItemStack p_150788_1_) { @@ -38,7 +46,7 @@ this.writeBoolean(false); } else { this.writeBoolean(true); -@@ -300,8 +310,12 @@ +@@ -300,8 +311,21 @@ this.func_150787_b(Item.func_150891_b(item)); this.writeByte(p_150788_1_.func_190916_E()); CompoundNBT compoundnbt = null; @@ -47,13 +55,22 @@ + if (item.isDamageable(p_150788_1_) || item.func_77651_p()) { + // Spigot start - filter + p_150788_1_ = p_150788_1_.func_77946_l(); -+ CraftItemStack.setItemMeta(p_150788_1_, CraftItemStack.getItemMeta(p_150788_1_)); ++ //CraftItemStack.setItemMeta(stack, CraftItemStack.getItemMeta(stack)); // Paper - This is no longer needed due to NBT being supported + // Spigot end + compoundnbt = limitedTag ? p_150788_1_.getShareTag() : p_150788_1_.func_77978_p(); ++ // Paper start ++ if (compoundnbt != null && compoundnbt.func_150297_b("SkullOwner", 10)) { ++ CompoundNBT owner = compoundnbt.func_74775_l("SkullOwner"); ++ if (owner.func_186855_b("Id")) { ++ compoundnbt.func_186854_a("SkullOwnerOrig", owner.func_186857_a("Id")); ++ SkullTileEntity.sanitizeUUID(owner); ++ } ++ } ++ // Paper end } this.func_150786_a(compoundnbt); -@@ -317,7 +331,12 @@ +@@ -317,7 +341,12 @@ int i = this.func_150792_a(); int j = this.readByte(); ItemStack itemstack = new ItemStack(Item.func_150899_d(i), j); diff --git a/patches/minecraft/net/minecraft/network/play/ServerPlayNetHandler.java.patch b/patches/minecraft/net/minecraft/network/play/ServerPlayNetHandler.java.patch index ad3dbbf642..00a834b1e9 100644 --- a/patches/minecraft/net/minecraft/network/play/ServerPlayNetHandler.java.patch +++ b/patches/minecraft/net/minecraft/network/play/ServerPlayNetHandler.java.patch @@ -275,12 +275,38 @@ private void func_244533_a(T p_244533_1_, Consumer p_244533_2_, BiFunction>> p_244533_3_) { ThreadTaskExecutor threadtaskexecutor = this.field_147369_b.func_71121_q().func_73046_m(); -@@ -365,8 +482,31 @@ +@@ -352,21 +469,50 @@ + Entity entity = this.field_147369_b.func_184208_bv(); + if (entity != this.field_147369_b && entity.func_184179_bs() == this.field_147369_b && entity == this.field_184355_r) { + ServerWorld serverworld = this.field_147369_b.func_71121_q(); +- double d0 = entity.func_226277_ct_(); +- double d1 = entity.func_226278_cu_(); +- double d2 = entity.func_226281_cx_(); +- double d3 = p_184338_1_.func_187004_a(); +- double d4 = p_184338_1_.func_187002_b(); +- double d5 = p_184338_1_.func_187003_c(); ++ double d0 = entity.func_226277_ct_();double fromX = d0; // Paper - OBFHELPER ++ double d1 = entity.func_226278_cu_();double fromY = d1; // Paper - OBFHELPER ++ double d2 = entity.func_226281_cx_();double fromZ = d2; // Paper - OBFHELPER ++ double d3 = p_184338_1_.func_187004_a();double toX = d3; // Paper - OBFHELPER ++ double d4 = p_184338_1_.func_187002_b();double toY = d4; // Paper - OBFHELPER ++ double d5 = p_184338_1_.func_187003_c();double toZ = d5; // Paper - OBFHELPER + float f = p_184338_1_.func_187006_d(); + float f1 = p_184338_1_.func_187005_e(); + double d6 = d3 - this.field_184356_s; + double d7 = d4 - this.field_184357_t; double d8 = d5 - this.field_184358_u; double d9 = entity.func_213322_ci().func_189985_c(); - double d10 = d6 * d6 + d7 * d7 + d8 * d8; +- double d10 = d6 * d6 + d7 * d7 + d8 * d8; - if (d10 - d9 > 100.0D && !this.func_217264_d()) { - field_147370_c.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.func_200200_C_().getString(), this.field_147369_b.func_200200_C_().getString(), d6, d7, d8); ++ // Paper start - fix large move vectors killing the server ++ double currDeltaX = toX - fromX; ++ double currDeltaY = toY - fromY; ++ double currDeltaZ = toZ - fromZ; ++ double d10 = Math.max(d6 * d6 + d7 * d7 + d8 * d8, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1); ++ // Paper end - fix large move vectors killing the server ++ + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); @@ -309,7 +335,7 @@ this.field_147371_a.func_179290_a(new SMoveVehiclePacket(entity)); return; } -@@ -385,19 +525,80 @@ +@@ -385,19 +531,80 @@ d8 = d5 - entity.func_226281_cx_(); d10 = d6 * d6 + d7 * d7 + d8 * d8; boolean flag1 = false; @@ -392,7 +418,7 @@ this.field_147369_b.func_71121_q().func_72863_F().func_217221_a(this.field_147369_b); this.field_147369_b.func_71000_j(this.field_147369_b.func_226277_ct_() - d0, this.field_147369_b.func_226278_cu_() - d1, this.field_147369_b.func_226281_cx_() - d2); this.field_184345_D = d7 >= -0.03125D && !this.field_147367_d.func_71231_X() && this.func_241162_a_(entity); -@@ -410,12 +611,12 @@ +@@ -410,13 +617,13 @@ } private boolean func_241162_a_(Entity p_241162_1_) { @@ -403,11 +429,13 @@ public void func_184339_a(CConfirmTeleportPacket p_184339_1_) { PacketThreadUtil.func_218796_a(p_184339_1_, this, this.field_147369_b.func_71121_q()); - if (p_184339_1_.func_186987_a() == this.field_184363_z) { +- this.field_147369_b.func_70080_a(this.field_184362_y.field_72450_a, this.field_184362_y.field_72448_b, this.field_184362_y.field_72449_c, this.field_147369_b.field_70177_z, this.field_147369_b.field_70125_A); + if (p_184339_1_.func_186987_a() == this.field_184363_z && this.field_184362_y != null) { // CraftBukkit - this.field_147369_b.func_70080_a(this.field_184362_y.field_72450_a, this.field_184362_y.field_72448_b, this.field_184362_y.field_72449_c, this.field_147369_b.field_70177_z, this.field_147369_b.field_70125_A); ++ this.field_147369_b.func_70012_b(this.field_184362_y.field_72450_a, this.field_184362_y.field_72448_b, this.field_184362_y.field_72449_c, this.field_147369_b.field_70177_z, this.field_147369_b.field_70125_A); this.field_184352_o = this.field_184362_y.field_72450_a; this.field_184353_p = this.field_184362_y.field_72448_b; -@@ -425,6 +626,7 @@ + this.field_184354_q = this.field_184362_y.field_72449_c; +@@ -425,6 +632,7 @@ } this.field_184362_y = null; @@ -415,7 +443,7 @@ } } -@@ -453,6 +655,12 @@ +@@ -453,6 +661,12 @@ public void func_195518_a(CTabCompletePacket p_195518_1_) { PacketThreadUtil.func_218796_a(p_195518_1_, this, this.field_147369_b.func_71121_q()); @@ -428,7 +456,7 @@ StringReader stringreader = new StringReader(p_195518_1_.func_197707_b()); if (stringreader.canRead() && stringreader.peek() == '/') { stringreader.skip(); -@@ -460,6 +668,7 @@ +@@ -460,6 +674,7 @@ ParseResults parseresults = this.field_147367_d.func_195571_aL().func_197054_a().parse(stringreader, this.field_147369_b.func_195051_bN()); this.field_147367_d.func_195571_aL().func_197054_a().getCompletionSuggestions(parseresults).thenAccept((p_195519_2_) -> { @@ -436,7 +464,7 @@ this.field_147371_a.func_179290_a(new STabCompletePacket(p_195518_1_.func_197709_a(), p_195519_2_)); }); } -@@ -665,6 +874,7 @@ +@@ -665,6 +880,7 @@ Container container = this.field_147369_b.field_71070_bA; if (container instanceof MerchantContainer) { MerchantContainer merchantcontainer = (MerchantContainer)container; @@ -444,7 +472,7 @@ merchantcontainer.func_75175_c(i); merchantcontainer.func_217046_g(i); } -@@ -672,6 +882,13 @@ +@@ -672,6 +888,13 @@ } public void func_210156_a(CEditBookPacket p_210156_1_) { @@ -458,7 +486,7 @@ ItemStack itemstack = p_210156_1_.func_210346_a(); if (itemstack.func_77973_b() == Items.field_151099_bA) { CompoundNBT compoundnbt = itemstack.func_77978_p(); -@@ -705,7 +922,9 @@ +@@ -705,7 +928,9 @@ if (itemstack.func_77973_b() == Items.field_151099_bA) { ListNBT listnbt = new ListNBT(); p_244536_1_.stream().map(StringNBT::func_229705_a_).forEach(listnbt::add); @@ -468,7 +496,7 @@ } } -@@ -729,7 +948,7 @@ +@@ -729,7 +954,7 @@ } itemstack1.func_77983_a("pages", listnbt); @@ -477,7 +505,7 @@ } } -@@ -760,7 +979,7 @@ +@@ -760,7 +985,7 @@ this.func_194028_b(new TranslationTextComponent("multiplayer.disconnect.invalid_player_movement")); } else { ServerWorld serverworld = this.field_147369_b.func_71121_q(); @@ -486,7 +514,7 @@ if (this.field_147368_e == 0) { this.func_184342_d(); } -@@ -771,12 +990,21 @@ +@@ -771,26 +996,40 @@ this.func_147364_a(this.field_184362_y.field_72450_a, this.field_184362_y.field_72448_b, this.field_184362_y.field_72449_c, this.field_147369_b.field_70177_z, this.field_147369_b.field_70125_A); } @@ -508,7 +536,30 @@ double d0 = this.field_147369_b.func_226277_ct_(); double d1 = this.field_147369_b.func_226278_cu_(); double d2 = this.field_147369_b.func_226281_cx_(); -@@ -799,15 +1027,32 @@ + double d3 = this.field_147369_b.func_226278_cu_(); +- double d4 = p_147347_1_.func_186997_a(this.field_147369_b.func_226277_ct_()); +- double d5 = p_147347_1_.func_186996_b(this.field_147369_b.func_226278_cu_()); +- double d6 = p_147347_1_.func_187000_c(this.field_147369_b.func_226281_cx_()); ++ double d4 = p_147347_1_.func_186997_a(this.field_147369_b.func_226277_ct_());double toX = d4; // Paper - OBFHELPER ++ double d5 = p_147347_1_.func_186996_b(this.field_147369_b.func_226278_cu_());double toY = d5; // Paper - OBFHELPER ++ double d6 = p_147347_1_.func_187000_c(this.field_147369_b.func_226281_cx_());double toZ = d6; // Paper - OBFHELPER + float f = p_147347_1_.func_186999_a(this.field_147369_b.field_70177_z); + float f1 = p_147347_1_.func_186998_b(this.field_147369_b.field_70125_A); + double d7 = d4 - this.field_184349_l; + double d8 = d5 - this.field_184350_m; + double d9 = d6 - this.field_184351_n; + double d10 = this.field_147369_b.func_213322_ci().func_189985_c(); +- double d11 = d7 * d7 + d8 * d8 + d9 * d9; ++ // Paper start - fix large move vectors killing the server ++ double currDeltaX = toX - prevX; ++ double currDeltaY = toY - prevY; ++ double currDeltaZ = toZ - prevZ; ++ double d11 = Math.max(d7 * d7 + d8 * d8 + d9 * d9, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1); ++ // Paper end - fix large move vectors killing the server + if (this.field_147369_b.func_70608_bn()) { + if (d11 > 1.0D) { + this.func_147364_a(this.field_147369_b.func_226277_ct_(), this.field_147369_b.func_226278_cu_(), this.field_147369_b.func_226281_cx_(), p_147347_1_.func_186999_a(this.field_147369_b.field_70177_z), p_147347_1_.func_186998_b(this.field_147369_b.field_70125_A)); +@@ -799,15 +1038,32 @@ } else { ++this.field_184347_F; int i = this.field_184347_F - this.field_184348_G; @@ -545,7 +596,7 @@ this.func_147364_a(this.field_147369_b.func_226277_ct_(), this.field_147369_b.func_226278_cu_(), this.field_147369_b.func_226281_cx_(), this.field_147369_b.field_70177_z, this.field_147369_b.field_70125_A); return; } -@@ -823,6 +1068,7 @@ +@@ -823,6 +1079,7 @@ } this.field_147369_b.func_213315_a(MoverType.PLAYER, new Vector3d(d7, d8, d9)); @@ -553,7 +604,7 @@ d7 = d4 - this.field_147369_b.func_226277_ct_(); d8 = d5 - this.field_147369_b.func_226278_cu_(); if (d8 > -0.5D || d8 < 0.5D) { -@@ -832,17 +1078,81 @@ +@@ -832,17 +1089,81 @@ d9 = d6 - this.field_147369_b.func_226281_cx_(); d11 = d7 * d7 + d8 * d8 + d9 * d9; boolean flag1 = false; @@ -639,7 +690,7 @@ if (flag) { this.field_147369_b.field_70143_R = 0.0F; } -@@ -875,24 +1185,83 @@ +@@ -875,24 +1196,83 @@ this.func_175089_a(p_147364_1_, p_147364_3_, p_147364_5_, p_147364_7_, p_147364_8_, Collections.emptySet()); } @@ -721,7 +772,7 @@ this.field_184343_A = this.field_147368_e; - this.field_147369_b.func_70080_a(p_175089_1_, p_175089_3_, p_175089_5_, p_175089_7_, p_175089_8_); - this.field_147369_b.field_71135_a.func_147359_a(new SPlayerPositionLookPacket(p_175089_1_ - d0, p_175089_3_ - d1, p_175089_5_ - d2, p_175089_7_ - f, p_175089_8_ - f1, p_175089_9_, this.field_184363_z)); -+ this.field_147369_b.func_70080_a(x, y, z, yaw, pitch); ++ this.field_147369_b.func_70012_b(x, y, z, yaw, pitch); // Paper - use proper setPositionRotation for teleportation + this.field_147369_b.field_71135_a.func_147359_a(new SPlayerPositionLookPacket(x - d0, y - d1, z - d2, yaw - f, pitch - f1, relativeSet, this.field_184363_z)); } @@ -731,7 +782,7 @@ BlockPos blockpos = p_147345_1_.func_179715_a(); this.field_147369_b.func_143004_u(); CPlayerDiggingPacket.Action cplayerdiggingpacket$action = p_147345_1_.func_180762_c(); -@@ -900,14 +1269,45 @@ +@@ -900,14 +1280,45 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.field_147369_b.func_175149_v()) { ItemStack itemstack = this.field_147369_b.func_184586_b(Hand.OFF_HAND); @@ -780,7 +831,7 @@ this.field_147369_b.func_225609_n_(false); } -@@ -931,6 +1331,22 @@ +@@ -931,6 +1342,22 @@ } } @@ -803,7 +854,7 @@ private static boolean func_241166_a_(ServerPlayerEntity p_241166_0_, ItemStack p_241166_1_) { if (p_241166_1_.func_190926_b()) { return false; -@@ -942,6 +1358,8 @@ +@@ -942,6 +1369,8 @@ public void func_184337_a(CPlayerTryUseItemOnBlockPacket p_184337_1_) { PacketThreadUtil.func_218796_a(p_184337_1_, this, this.field_147369_b.func_71121_q()); @@ -812,7 +863,7 @@ ServerWorld serverworld = this.field_147369_b.func_71121_q(); Hand hand = p_184337_1_.func_187022_c(); ItemStack itemstack = this.field_147369_b.func_184586_b(hand); -@@ -950,7 +1368,17 @@ +@@ -950,7 +1379,17 @@ Direction direction = blockraytraceresult.func_216354_b(); this.field_147369_b.func_143004_u(); if (blockpos.func_177956_o() < this.field_147367_d.func_71207_Z()) { @@ -831,7 +882,7 @@ ActionResultType actionresulttype = this.field_147369_b.field_71134_c.func_219441_a(this.field_147369_b, serverworld, itemstack, hand, blockraytraceresult); if (direction == Direction.UP && !actionresulttype.func_226246_a_() && blockpos.func_177956_o() >= this.field_147367_d.func_71207_Z() - 1 && func_241166_a_(this.field_147369_b, itemstack)) { ITextComponent itextcomponent = (new TranslationTextComponent("build.tooHigh", this.field_147367_d.func_71207_Z())).func_240699_a_(TextFormatting.RED); -@@ -970,11 +1398,49 @@ +@@ -970,11 +1409,53 @@ public void func_147346_a(CPlayerTryUseItemPacket p_147346_1_) { PacketThreadUtil.func_218796_a(p_147346_1_, this, this.field_147369_b.func_71121_q()); @@ -878,10 +929,14 @@ + this.field_147369_b.getBukkitEntity().updateInventory(); // SPIGOT-2524 + } + // CraftBukkit end ++ // Paper start ++ itemstack = this.field_147369_b.getItemInHand(hand); ++ if (itemstack.func_190926_b()) return; ++ // Paper end ActionResultType actionresulttype = this.field_147369_b.field_71134_c.func_187250_a(this.field_147369_b, serverworld, itemstack, hand); if (actionresulttype.func_226247_b_()) { this.field_147369_b.func_226292_a_(hand, true); -@@ -989,7 +1455,7 @@ +@@ -989,7 +1470,7 @@ for(ServerWorld serverworld : this.field_147367_d.func_212370_w()) { Entity entity = p_175088_1_.func_179727_a(serverworld); if (entity != null) { @@ -890,7 +945,7 @@ return; } } -@@ -997,8 +1463,12 @@ +@@ -997,8 +1478,12 @@ } @@ -903,7 +958,7 @@ public void func_184340_a(CSteerBoatPacket p_184340_1_) { PacketThreadUtil.func_218796_a(p_184340_1_, this, this.field_147369_b.func_71121_q()); -@@ -1010,16 +1480,30 @@ +@@ -1010,16 +1495,30 @@ } public void func_147231_a(ITextComponent p_147231_1_) { @@ -940,7 +995,7 @@ if (this.func_217264_d()) { field_147370_c.info("Stopping singleplayer server as player logged out"); this.field_147367_d.func_71263_m(false); -@@ -1044,6 +1528,15 @@ +@@ -1044,6 +1543,15 @@ } } @@ -956,7 +1011,7 @@ try { this.field_147371_a.func_201058_a(p_211148_1_, p_211148_2_); } catch (Throwable throwable) { -@@ -1058,7 +1551,16 @@ +@@ -1058,7 +1566,16 @@ public void func_147355_a(CHeldItemChangePacket p_147355_1_) { PacketThreadUtil.func_218796_a(p_147355_1_, this, this.field_147369_b.func_71121_q()); @@ -973,7 +1028,7 @@ if (this.field_147369_b.field_71071_by.field_70461_c != p_147355_1_.func_149614_c() && this.field_147369_b.func_184600_cs() == Hand.MAIN_HAND) { this.field_147369_b.func_184602_cy(); } -@@ -1066,61 +1568,285 @@ +@@ -1066,61 +1583,285 @@ this.field_147369_b.field_71071_by.field_70461_c = p_147355_1_.func_149614_c(); this.field_147369_b.func_143004_u(); } else { @@ -1280,7 +1335,7 @@ this.field_147369_b.func_143004_u(); switch(p_147357_1_.func_180764_b()) { case PRESS_SHIFT_KEY: -@@ -1174,8 +1900,16 @@ +@@ -1174,8 +1915,16 @@ public void func_147340_a(CUseEntityPacket p_147340_1_) { PacketThreadUtil.func_218796_a(p_147340_1_, this, this.field_147369_b.func_71121_q()); @@ -1297,7 +1352,7 @@ this.field_147369_b.func_143004_u(); this.field_147369_b.func_226284_e_(p_147340_1_.func_241792_e_()); if (entity != null) { -@@ -1184,19 +1918,71 @@ +@@ -1184,19 +1933,71 @@ Hand hand = p_147340_1_.func_186994_b(); ItemStack itemstack = hand != null ? this.field_147369_b.func_184586_b(hand).func_77946_l() : ItemStack.field_190927_a; Optional optional = Optional.empty(); @@ -1379,7 +1434,7 @@ if (optional.isPresent() && optional.get().func_226246_a_()) { CriteriaTriggers.field_241276_P_.func_241476_a_(this.field_147369_b, itemstack, entity); -@@ -1205,8 +1991,9 @@ +@@ -1205,8 +2006,9 @@ } } } @@ -1390,7 +1445,7 @@ } public void func_147342_a(CClientStatusPacket p_147342_1_) { -@@ -1239,14 +2026,22 @@ +@@ -1239,14 +2041,22 @@ public void func_147356_a(CCloseWindowPacket p_147356_1_) { PacketThreadUtil.func_218796_a(p_147356_1_, this, this.field_147369_b.func_71121_q()); @@ -1415,7 +1470,7 @@ NonNullList nonnulllist = NonNullList.func_191196_a(); for(int i = 0; i < this.field_147369_b.field_71070_bA.field_75151_b.size(); ++i) { -@@ -1255,8 +2050,274 @@ +@@ -1255,8 +2065,274 @@ this.field_147369_b.func_71110_a(this.field_147369_b.field_71070_bA, nonnulllist); } else { @@ -1692,7 +1747,7 @@ this.field_147369_b.field_71135_a.func_147359_a(new SConfirmTransactionPacket(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), true)); this.field_147369_b.field_71137_h = true; this.field_147369_b.field_71070_bA.func_75142_b(); -@@ -1269,8 +2330,8 @@ +@@ -1269,8 +2345,8 @@ NonNullList nonnulllist1 = NonNullList.func_191196_a(); for(int j = 0; j < this.field_147369_b.field_71070_bA.field_75151_b.size(); ++j) { @@ -1703,7 +1758,7 @@ } this.field_147369_b.func_71110_a(this.field_147369_b.field_71070_bA, nonnulllist1); -@@ -1292,6 +2353,7 @@ +@@ -1292,6 +2368,7 @@ public void func_147338_a(CEnchantItemPacket p_147338_1_) { PacketThreadUtil.func_218796_a(p_147338_1_, this, this.field_147369_b.func_71121_q()); @@ -1711,7 +1766,7 @@ this.field_147369_b.func_143004_u(); if (this.field_147369_b.field_71070_bA.field_75152_c == p_147338_1_.func_149539_c() && this.field_147369_b.field_71070_bA.func_75129_b(this.field_147369_b) && !this.field_147369_b.func_175149_v()) { this.field_147369_b.field_71070_bA.func_75140_a(this.field_147369_b, p_147338_1_.func_149537_d()); -@@ -1306,7 +2368,7 @@ +@@ -1306,7 +2383,7 @@ boolean flag = p_147344_1_.func_149627_c() < 0; ItemStack itemstack = p_147344_1_.func_149625_d(); CompoundNBT compoundnbt = itemstack.func_179543_a("BlockEntityTag"); @@ -1720,7 +1775,7 @@ BlockPos blockpos = new BlockPos(compoundnbt.func_74762_e("x"), compoundnbt.func_74762_e("y"), compoundnbt.func_74762_e("z")); TileEntity tileentity = this.field_147369_b.field_70170_p.func_175625_s(blockpos); if (tileentity != null) { -@@ -1320,6 +2382,42 @@ +@@ -1320,6 +2397,42 @@ boolean flag1 = p_147344_1_.func_149627_c() >= 1 && p_147344_1_.func_149627_c() <= 45; boolean flag2 = itemstack.func_190926_b() || itemstack.func_77952_i() >= 0 && itemstack.func_190916_E() <= 64 && !itemstack.func_190926_b(); @@ -1763,7 +1818,7 @@ if (flag1 && flag2) { if (itemstack.func_190926_b()) { this.field_147369_b.field_71069_bz.func_75141_a(p_147344_1_.func_149627_c(), ItemStack.field_190927_a); -@@ -1339,6 +2437,7 @@ +@@ -1339,6 +2452,7 @@ public void func_147339_a(CConfirmTransactionPacket p_147339_1_) { PacketThreadUtil.func_218796_a(p_147339_1_, this, this.field_147369_b.func_71121_q()); @@ -1771,7 +1826,7 @@ int i = this.field_147369_b.field_71070_bA.field_75152_c; if (i == p_147339_1_.func_149532_c() && this.field_147372_n.getOrDefault(i, (short)(p_147339_1_.func_149533_d() + 1)) == p_147339_1_.func_149533_d() && !this.field_147369_b.field_71070_bA.func_75129_b(this.field_147369_b) && !this.field_147369_b.func_175149_v()) { this.field_147369_b.field_71070_bA.func_75128_a(this.field_147369_b, true); -@@ -1347,16 +2446,11 @@ +@@ -1347,16 +2461,11 @@ } public void func_147343_a(CUpdateSignPacket p_147343_1_) { @@ -1791,11 +1846,13 @@ if (serverworld.func_175667_e(blockpos)) { BlockState blockstate = serverworld.func_180495_p(blockpos); TileEntity tileentity = serverworld.func_175625_s(blockpos); -@@ -1366,14 +2460,32 @@ +@@ -1365,15 +2474,33 @@ + } SignTileEntity signtileentity = (SignTileEntity)tileentity; - if (!signtileentity.func_145914_a() || signtileentity.func_145911_b() != this.field_147369_b) { +- if (!signtileentity.func_145914_a() || signtileentity.func_145911_b() != this.field_147369_b) { - field_147370_c.warn("Player {} just tried to change non-editable sign", (Object)this.field_147369_b.func_200200_C_().getString()); ++ if (!signtileentity.func_145914_a() || signtileentity.signEditor == null || !signtileentity.signEditor.equals(this.field_147369_b.func_110124_au())) { + field_147370_c.warn("Player {} just tried to change non-editable sign", (Object)this.field_147369_b.func_195047_I_()); + this.func_147359_a(tileentity.func_189518_D_()); // CraftBukkit return; @@ -1813,7 +1870,7 @@ + String[] lines = new String[4]; + + for(int i = 0; i < astring.length; ++i) { -+ lines[i] = TextFormatting.func_110646_a(new StringTextComponent(TextFormatting.func_110646_a(astring[i])).getString()); ++ lines[i] = SharedConstants.filterAllowedChatCharacters(astring[i]); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created. } + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.craftServer.getPlayer(this.field_147369_b), lines); @@ -1827,7 +1884,7 @@ signtileentity.func_70296_d(); serverworld.func_184138_a(blockpos, blockstate, blockstate, 3); } -@@ -1381,6 +2493,7 @@ +@@ -1381,6 +2508,7 @@ } public void func_147353_a(CKeepAlivePacket p_147353_1_) { @@ -1835,7 +1892,7 @@ if (this.field_194403_g && p_147353_1_.func_149460_c() == this.field_194404_h) { int i = (int)(Util.func_211177_b() - this.field_194402_f); this.field_147369_b.field_71138_i = (this.field_147369_b.field_71138_i * 3 + i) / 4; -@@ -1393,7 +2506,17 @@ +@@ -1393,7 +2521,17 @@ public void func_147348_a(CPlayerAbilitiesPacket p_147348_1_) { PacketThreadUtil.func_218796_a(p_147348_1_, this, this.field_147369_b.func_71121_q()); @@ -1854,7 +1911,7 @@ } public void func_147352_a(CClientSettingsPacket p_147352_1_) { -@@ -1401,9 +2524,6 @@ +@@ -1401,13 +2539,10 @@ this.field_147369_b.func_147100_a(p_147352_1_); } @@ -1864,7 +1921,12 @@ public void func_217263_a(CSetDifficultyPacket p_217263_1_) { PacketThreadUtil.func_218796_a(p_217263_1_, this, this.field_147369_b.func_71121_q()); if (this.field_147369_b.func_211513_k(2) || this.func_217264_d()) { -@@ -1417,4 +2537,54 @@ +- this.field_147367_d.func_147139_a(p_217263_1_.func_218773_b(), false); ++ //this.server.setDifficultyForAllWorlds(p_217263_1_.func_218773_b(), false); // Paper - don't allow clients to change this + } + } + +@@ -1417,4 +2552,54 @@ this.field_147367_d.func_213209_d(p_217261_1_.func_218776_b()); } } @@ -1915,7 +1977,7 @@ + } + + public boolean isDisconnected() { -+ return !this.field_147369_b.joining && !this.field_147371_a.func_150724_d(); ++ return (!this.field_147369_b.joining && !this.field_147371_a.func_150724_d()) || this.processedDisconnect; // Paper; + } + // CraftBukkit end } diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index 1f663a1d8b..f580eea308 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -1,36 +1,33 @@ +@@ -1,36 +1,34 @@ package net.minecraft.server; import com.google.common.collect.ImmutableSet; @@ -13,6 +13,7 @@ -import java.awt.GraphicsEnvironment; + import java.io.File; ++import java.io.IOException; import java.net.Proxy; import java.nio.file.Path; import java.nio.file.Paths; @@ -42,7 +43,7 @@ import net.minecraft.util.Util; import net.minecraft.util.WorldOptimizer; import net.minecraft.util.datafix.DataFixesManager; -@@ -38,174 +35,156 @@ +@@ -38,174 +36,178 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.registry.Bootstrap; import net.minecraft.util.registry.DynamicRegistries; @@ -61,6 +62,8 @@ -import net.minecraft.world.storage.ServerWorldInfo; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; ++import org.bukkit.configuration.InvalidConfigurationException; ++import org.bukkit.configuration.file.YamlConfiguration; public class Main { - private static final Logger field_240759_a_ = LogManager.getLogger(); @@ -88,6 +91,8 @@ + if (optionset == null) { + return; + } ++ YamlConfiguration bukkitConfiguration = loadConfigFile((File)optionset.valueOf("bukkit-settings")); ++ YamlConfiguration spigotConfiguration = loadConfigFile((File)optionset.valueOf("spigot-settings")); + Path path1 = Paths.get("eula.txt"); + ServerEula servereula = new ServerEula(path1); @@ -138,17 +143,27 @@ - field_240759_a_.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath()); - return; - } -+ File file1 = (File) optionset.valueOf("universe"); // CraftBukkit ++ org.spigotmc.SpigotConfig.disabledAdvancements = spigotConfiguration.getStringList("advancements.disabled"); // Paper - fix SPIGOT-5885, must be set early in init ++ // Paper start - fix SPIGOT-5824 ++ File file; ++ File userCacheFile = new File("usercache.json"); ++ if (optionset.has("universe")) { ++ file = (File) optionset.valueOf("universe"); // CraftBukkit ++ userCacheFile = new File(file, "usercache.json"); ++ } else { ++ file = new File(bukkitConfiguration.getString("settings.world-container", ".")); ++ } ++ // Paper end - fix SPIGOT-5824 + YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); + MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); + GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); -+ PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(file1, MinecraftServer.field_152367_a.getName())); ++ PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, userCacheFile); // Paper - only move usercache.json into folder if --universe is used, not world-container + String s = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(serverpropertiesprovider.func_219034_a().field_219021_o); -+ if (s == null || s.isEmpty() || new File(file1, s).getAbsolutePath().equals(new File(s).getAbsolutePath())) { ++ if (s == null || s.isEmpty() || new File(file, s).getAbsolutePath().equals(new File(s).getAbsolutePath())) { + field_240759_a_.error(Message.get("nms.invalid.dir") + s); + return; + } -+ SaveFormat saveformat = SaveFormat.func_237269_a_(file1.toPath()); ++ SaveFormat saveformat = SaveFormat.func_237269_a_(file.toPath()); + SaveFormat.LevelSave saveformat$levelsave = saveformat.getLevelSave(s, Dimension.field_236053_b_); + MinecraftServer.func_240777_a_(saveformat$levelsave); + DatapackCodec datapackcodec = saveformat$levelsave.func_237297_e_(); @@ -287,21 +302,22 @@ + } - } -+ public static void func_240761_a_(SaveFormat.LevelSave p_240761_0_, DataFixer p_240761_1_, boolean p_240761_2_, BooleanSupplier p_240761_3_, ImmutableSet> p_240761_4_) { // private->public CraftBukkit -+ field_240759_a_.info(Message.get("nms.world.upgrade")); -+ WorldOptimizer worldoptimizer = new WorldOptimizer(p_240761_0_, p_240761_1_, p_240761_4_, p_240761_2_); -+ ITextComponent itextcomponent = null; ++ private static YamlConfiguration loadConfigFile(final File configFile) throws IOException, InvalidConfigurationException { ++ final YamlConfiguration config = new YamlConfiguration(); ++ if (configFile.exists()) { ++ config.load(configFile); ++ } ++ return config; ++ } - private static void func_240761_a_(SaveFormat.LevelSave p_240761_0_, DataFixer p_240761_1_, boolean p_240761_2_, BooleanSupplier p_240761_3_, ImmutableSet> p_240761_4_) { - field_240759_a_.info("Forcing world upgrade!"); - WorldOptimizer worldoptimizer = new WorldOptimizer(p_240761_0_, p_240761_1_, p_240761_4_, p_240761_2_); - ITextComponent itextcomponent = null; -+ while (!worldoptimizer.func_212218_b()) { -+ ITextComponent itextcomponent1 = worldoptimizer.func_212215_m(); -+ if (itextcomponent != itextcomponent1) { -+ itextcomponent = itextcomponent1; -+ field_240759_a_.info(worldoptimizer.func_212215_m().getString()); -+ } ++ public static void func_240761_a_(SaveFormat.LevelSave p_240761_0_, DataFixer p_240761_1_, boolean p_240761_2_, BooleanSupplier p_240761_3_, ImmutableSet> p_240761_4_) { // private->public CraftBukkit ++ field_240759_a_.info(Message.get("nms.world.upgrade")); ++ WorldOptimizer worldoptimizer = new WorldOptimizer(p_240761_0_, p_240761_1_, p_240761_4_, p_240761_2_); ++ ITextComponent itextcomponent = null; - while(!worldoptimizer.func_212218_b()) { - ITextComponent itextcomponent1 = worldoptimizer.func_212215_m(); @@ -309,10 +325,11 @@ - itextcomponent = itextcomponent1; - field_240759_a_.info(worldoptimizer.func_212215_m().getString()); - } -+ int i = worldoptimizer.func_212211_j(); -+ if (i > 0) { -+ int j = worldoptimizer.func_212208_k() + worldoptimizer.func_212209_l(); -+ field_240759_a_.info(Message.get("nms.world.update", MathHelper.func_76141_d((float) j / (float) i * 100.0F), j, i)); ++ while (!worldoptimizer.func_212218_b()) { ++ ITextComponent itextcomponent1 = worldoptimizer.func_212215_m(); ++ if (itextcomponent != itextcomponent1) { ++ itextcomponent = itextcomponent1; ++ field_240759_a_.info(worldoptimizer.func_212215_m().getString()); + } - int i = worldoptimizer.func_212211_j(); @@ -320,7 +337,12 @@ - int j = worldoptimizer.func_212208_k() + worldoptimizer.func_212209_l(); - field_240759_a_.info("{}% completed ({} / {} chunks)...", MathHelper.func_76141_d((float)j / (float)i * 100.0F), j, i); - } -- ++ int i = worldoptimizer.func_212211_j(); ++ if (i > 0) { ++ int j = worldoptimizer.func_212208_k() + worldoptimizer.func_212209_l(); ++ field_240759_a_.info(Message.get("nms.world.update", MathHelper.func_76141_d((float) j / (float) i * 100.0F), j, i)); ++ } + - if (!p_240761_3_.getAsBoolean()) { - worldoptimizer.func_212217_a(); - } else { diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index 59b368a9c6..ef14440e03 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -952,7 +952,26 @@ } public KeyPair func_71250_E() { -@@ -1158,7 +1485,7 @@ +@@ -998,6 +1325,18 @@ + } + } + ++ // Paper start - fix per world difficulty ++ public void setDifficultyForAllWorlds(ServerWorld world, Difficulty difficulty, boolean p_147139_2_) { ++ ServerWorldInfo worldInfo = world.field_241103_E_; ++ if (p_147139_2_ || !worldInfo.func_176123_z()) { ++ worldInfo.func_230409_a_(worldInfo.func_76093_s() ? Difficulty.HARD : difficulty); ++ world.func_72891_a(worldInfo.func_176130_y() != Difficulty.PEACEFUL && ((DedicatedServer)this).field_71340_o.func_219034_a().field_218992_E, this.func_230537_U_()); ++ this.func_240794_aZ_(); ++ //this.getPlayerList().getPlayers().forEach(this::sendDifficultyToPlayer); ++ // Paper end ++ } ++ } ++ + public int func_230512_b_(int p_230512_1_) { + return p_230512_1_; + } +@@ -1158,7 +1497,7 @@ @Nullable public NetworkSystem func_147137_ag() { @@ -961,7 +980,7 @@ } @OnlyIn(Dist.CLIENT) -@@ -1273,6 +1600,7 @@ +@@ -1273,6 +1612,7 @@ }).thenAcceptAsync((p_240782_2_) -> { this.field_195576_ac.close(); this.field_195576_ac = p_240782_2_; @@ -969,7 +988,7 @@ this.field_195577_ad.func_198985_a(p_240780_1_); this.field_240768_i_.func_230410_a_(func_240771_a_(this.field_195577_ad)); p_240782_2_.func_240971_i_(); -@@ -1280,6 +1608,7 @@ +@@ -1280,6 +1620,7 @@ this.func_184103_al().func_193244_w(); this.field_200258_al.func_240946_a_(this.field_195576_ac.func_240960_a_()); this.field_240765_ak_.func_195410_a(this.field_195576_ac.func_240970_h_()); @@ -977,7 +996,7 @@ }, this); if (this.func_213162_bc()) { this.func_213161_c(completablefuture::isDone); -@@ -1289,10 +1618,13 @@ +@@ -1289,10 +1630,13 @@ } public static DatapackCodec func_240772_a_(ResourcePackList p_240772_0_, DatapackCodec p_240772_1_, boolean p_240772_2_) { @@ -993,7 +1012,16 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -1366,6 +1698,11 @@ +@@ -1335,7 +1679,7 @@ + if (this.func_205744_aT()) { + PlayerList playerlist = p_205743_1_.func_197028_i().func_184103_al(); + WhiteList whitelist = playerlist.func_152599_k(); +- ++ if (!((DedicatedServer)getServer()).func_213221_d_().field_219006_S.get()) return; // Paper - white list not enabled + for(ServerPlayerEntity serverplayerentity : Lists.newArrayList(playerlist.func_181057_v())) { + if (!whitelist.func_152705_a(serverplayerentity.func_146103_bH())) { + serverplayerentity.field_71135_a.func_194028_b(new TranslationTextComponent("multiplayer.disconnect.not_whitelisted")); +@@ -1366,6 +1710,11 @@ return true; } @@ -1005,7 +1033,7 @@ public RecipeManager func_199529_aN() { return this.field_195576_ac.func_240967_e_(); } -@@ -1442,6 +1779,31 @@ +@@ -1442,6 +1791,31 @@ public abstract boolean func_213199_b(GameProfile p_213199_1_); @@ -1037,7 +1065,7 @@ public void func_223711_a(Path p_223711_1_) throws IOException { Path path = p_223711_1_.resolve("levels"); -@@ -1570,6 +1932,10 @@ +@@ -1570,6 +1944,10 @@ return this.field_240768_i_; } @@ -1048,15 +1076,15 @@ public DynamicRegistries func_244267_aX() { return this.field_240767_f_; } -@@ -1578,4 +1944,20 @@ +@@ -1578,4 +1956,20 @@ public IChatFilter func_244435_a(ServerPlayerEntity p_244435_1_) { return null; } + -+ // CraftBukkit start + @Override + public boolean func_213162_bc() { -+ return super.func_213162_bc() || this.func_71241_aa(); // CraftBukkit - MC-142590 ++ // CraftBukkit start ++ return super.func_213162_bc() /*|| this.isServerStopped()*/; // CraftBukkit - MC-142590 // Paper - causes issues elsewhere + } + + public boolean isDebugging() { diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index d30f56542d..adf9012010 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -220,6 +220,15 @@ } public boolean func_230537_U_() { +@@ -241,7 +304,7 @@ + } + + public void func_230543_p_() { +- this.func_147139_a(this.func_213221_d_().field_219019_m, true); ++ //this.setDifficultyForAllWorlds(this.getServerProperties().difficulty, true); // Paper - Don't overwrite level.dat's difficulty, keep current + } + + public boolean func_71199_h() { @@ -280,7 +343,7 @@ if (this.field_71342_m != null) { this.field_71342_m.func_219591_b(); diff --git a/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch index 0db9c1f4f0..f45a82ab63 100644 --- a/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch @@ -8,7 +8,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -@@ -9,11 +11,15 @@ +@@ -9,15 +11,20 @@ import java.io.File; import java.net.SocketAddress; import java.text.SimpleDateFormat; @@ -24,7 +24,12 @@ import javax.annotation.Nullable; import net.minecraft.advancements.PlayerAdvancements; import net.minecraft.block.BlockState; -@@ -27,10 +33,12 @@ + import net.minecraft.block.Blocks; ++import net.minecraft.block.RespawnAnchorBlock; + import net.minecraft.entity.Entity; + import net.minecraft.entity.EntityType; + import net.minecraft.entity.player.PlayerEntity; +@@ -27,10 +34,12 @@ import net.minecraft.network.IPacket; import net.minecraft.network.NetworkManager; import net.minecraft.network.PacketBuffer; @@ -37,7 +42,7 @@ import net.minecraft.network.play.server.SEntityStatusPacket; import net.minecraft.network.play.server.SHeldItemChangePacket; import net.minecraft.network.play.server.SJoinGamePacket; -@@ -38,6 +46,7 @@ +@@ -38,6 +47,7 @@ import net.minecraft.network.play.server.SPlaySoundEffectPacket; import net.minecraft.network.play.server.SPlayerAbilitiesPacket; import net.minecraft.network.play.server.SPlayerListItemPacket; @@ -45,7 +50,7 @@ import net.minecraft.network.play.server.SRespawnPacket; import net.minecraft.network.play.server.SServerDifficultyPacket; import net.minecraft.network.play.server.SSetExperiencePacket; -@@ -54,6 +63,7 @@ +@@ -54,6 +64,7 @@ import net.minecraft.scoreboard.ServerScoreboard; import net.minecraft.scoreboard.Team; import net.minecraft.server.MinecraftServer; @@ -53,7 +58,7 @@ import net.minecraft.stats.ServerStatisticsManager; import net.minecraft.stats.Stats; import net.minecraft.tags.BlockTags; -@@ -85,6 +95,19 @@ +@@ -85,6 +96,19 @@ import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -73,7 +78,7 @@ public abstract class PlayerList { public static final File field_152613_a = new File("banned-players.json"); -@@ -94,15 +117,17 @@ +@@ -94,15 +118,17 @@ private static final Logger field_148546_d = LogManager.getLogger(); private static final SimpleDateFormat field_72403_e = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer field_72400_f; @@ -95,7 +100,7 @@ private boolean field_72409_l; private final DynamicRegistries.Impl field_232639_s_; protected final int field_72405_c; -@@ -110,8 +135,18 @@ +@@ -110,8 +136,18 @@ private GameType field_72410_m; private boolean field_72407_n; private int field_72408_o; @@ -114,7 +119,7 @@ this.field_72400_f = p_i231425_1_; this.field_232639_s_ = p_i231425_2_; this.field_72405_c = p_i231425_4_; -@@ -125,6 +160,14 @@ +@@ -125,6 +161,14 @@ String s = gameprofile1 == null ? gameprofile.getName() : gameprofile1.getName(); playerprofilecache.func_152649_a(gameprofile); CompoundNBT compoundnbt = this.func_72380_a(p_72355_2_); @@ -129,7 +134,7 @@ RegistryKey registrykey = compoundnbt != null ? DimensionType.func_236025_a_(new Dynamic<>(NBTDynamicOps.field_210820_a, compoundnbt.func_74781_a("Dimension"))).resultOrPartial(field_148546_d::error).orElse(World.field_234918_g_) : World.field_234918_g_; ServerWorld serverworld = this.field_72400_f.func_71218_a(registrykey); ServerWorld serverworld1; -@@ -142,20 +185,35 @@ +@@ -142,20 +186,36 @@ s1 = p_72355_1_.func_74430_c().toString(); } @@ -163,11 +168,12 @@ serverplaynethandler.func_147359_a(new SHeldItemChangePacket(p_72355_2_.field_71071_by.field_70461_c)); serverplaynethandler.func_147359_a(new SUpdateRecipesPacket(this.field_72400_f.func_199529_aN().func_199510_b())); serverplaynethandler.func_147359_a(new STagsListPacket(this.field_72400_f.func_244266_aF())); ++ serverplaynethandler.func_147359_a(new SEntityStatusPacket(p_72355_2_, (byte) (serverworld1.func_82736_K().func_223586_b(GameRules.field_223612_o) ? 22 : 23))); // Paper - fix this rule not being initialized on the client + net.minecraftforge.fml.network.NetworkHooks.syncCustomTagTypes(p_72355_2_, this.field_72400_f.func_244266_aF()); this.func_187243_f(p_72355_2_); p_72355_2_.func_147099_x().func_150877_d(); p_72355_2_.func_192037_E().func_192826_c(p_72355_2_); -@@ -167,19 +225,55 @@ +@@ -167,19 +227,55 @@ } else { iformattabletextcomponent = new TranslationTextComponent("multiplayer.player.joined.renamed", p_72355_2_.func_145748_c_(), s); } @@ -228,7 +234,7 @@ this.func_72354_b(p_72355_2_, serverworld1); if (!this.field_72400_f.func_147133_T().isEmpty()) { p_72355_2_.func_175397_a(this.field_72400_f.func_147133_T(), this.field_72400_f.func_175581_ab()); -@@ -191,8 +285,9 @@ +@@ -191,8 +287,9 @@ if (compoundnbt != null && compoundnbt.func_150297_b("RootVehicle", 10)) { CompoundNBT compoundnbt1 = compoundnbt.func_74775_l("RootVehicle"); @@ -240,7 +246,7 @@ }); if (entity1 != null) { UUID uuid; -@@ -225,9 +320,12 @@ +@@ -225,9 +322,12 @@ } p_72355_2_.func_71116_b(); @@ -254,7 +260,7 @@ Set set = Sets.newHashSet(); for(ScorePlayerTeam scoreplayerteam : p_96456_1_.func_96525_g()) { -@@ -248,25 +346,26 @@ +@@ -248,25 +348,26 @@ } public void func_212504_a(ServerWorld p_212504_1_) { @@ -286,7 +292,7 @@ } public void func_177696_b(WorldBorder p_177696_1_, double p_177696_2_) { -@@ -285,6 +384,7 @@ +@@ -285,6 +386,7 @@ compoundnbt1 = compoundnbt; p_72380_1_.func_70020_e(compoundnbt); field_148546_d.debug("loading single player"); @@ -294,7 +300,7 @@ } else { compoundnbt1 = this.field_72412_k.func_237336_b_(p_72380_1_); } -@@ -293,28 +393,43 @@ +@@ -293,28 +395,43 @@ } protected void func_72391_b(ServerPlayerEntity p_72391_1_) { @@ -347,7 +353,7 @@ serverworld.func_217467_h(entity); entity.field_70128_L = true; -@@ -323,107 +438,181 @@ +@@ -323,107 +440,181 @@ entity1.field_70128_L = true; } @@ -572,7 +578,7 @@ serverplayerentity.func_145769_d(p_232644_1_.func_145782_y()); serverplayerentity.func_184819_a(p_232644_1_.func_184591_cq()); -@@ -431,48 +620,115 @@ +@@ -431,48 +622,128 @@ serverplayerentity.func_184211_a(s); } @@ -589,6 +595,9 @@ - } else { - Vector3d vector3d1 = Vector3d.func_237492_c_(blockpos).func_178788_d(vector3d).func_72432_b(); - f1 = (float)MathHelper.func_76138_g(MathHelper.func_181159_b(vector3d1.field_72449_c, vector3d1.field_72450_a) * (double)(180F / (float)Math.PI) - 90.0D); ++ ++ boolean isLocAltered = false; // Paper - Fix SPIGOT-5989 ++ + // CraftBukkit start - fire PlayerRespawnEvent + if (location == null) { + boolean isBedSpawn = false; @@ -596,7 +605,7 @@ + if (worldserver1 != null) { + Optional optional; + if (blockpos != null) { -+ optional = PlayerEntity.func_242374_a(worldserver1, blockpos, f, flag, conqueredEnd); ++ optional = PlayerEntity.func_242374_a(worldserver1, blockpos, f, flag, true); // Paper - Fix SPIGOT-5989 + } else { + optional = Optional.empty(); + } @@ -639,7 +648,12 @@ + return p_232644_1_; + } + // Spigot End -+ location = respawnEvent.getRespawnLocation(); ++ // Paper start - Fix SPIGOT-5989 ++ if (!location.equals(respawnEvent.getRespawnLocation()) ) { ++ location = respawnEvent.getRespawnLocation(); ++ isLocAltered = true; ++ } ++ // Paper end + if (!conqueredEnd) p_232644_1_.reset(); // SPIGOT-4785 + } else { + location.setWorld(serverWorld.getCBWorld()); @@ -685,11 +699,16 @@ + } + // serverplayerentity.addSelfToInternalCraftingInventory(); serverplayerentity.func_70606_j(serverplayerentity.func_110143_aJ()); +- if (flag2) { +- serverplayerentity.field_71135_a.func_147359_a(new SPlaySoundEffectPacket(SoundEvents.field_232818_ms_, SoundCategory.BLOCKS, (double)blockpos.func_177958_n(), (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p(), 1.0F, 1.0F)); + net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerRespawnEvent(serverplayerentity, conqueredEnd); - if (flag2) { - serverplayerentity.field_71135_a.func_147359_a(new SPlaySoundEffectPacket(SoundEvents.field_232818_ms_, SoundCategory.BLOCKS, (double)blockpos.func_177958_n(), (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p(), 1.0F, 1.0F)); ++ // Paper start - Fix SPIGOT-5989 ++ if (flag2 && !isLocAltered) { ++ BlockState data = worldserver1.func_180495_p(blockpos); ++ worldserver1.func_180501_a(blockpos, data.func_206870_a(RespawnAnchorBlock.field_235559_a_, data.func_177229_b(RespawnAnchorBlock.field_235559_a_) - 1), 3); ++ serverplayerentity.field_71135_a.func_147359_a(new SPlaySoundEffectPacket(SoundEvents.field_232818_ms_, SoundCategory.BLOCKS, (double) location.getX(), (double) location.getY(), (double) location.getZ(), 1.0F, 1.0F)); ++ // Paper end } - + // Added from changeDimension + func_72385_f(p_232644_1_); // Update health, etc... + p_232644_1_.func_71016_p(); @@ -697,6 +716,8 @@ + EffectInstance mobEffect = (EffectInstance) o1; + p_232644_1_.field_71135_a.func_147359_a(new SPlayEntityEffectPacket(p_232644_1_.func_145782_y(), mobEffect)); + } + ++ p_232644_1_.func_226284_e_(false); // Paper - fix MC-10657 + + // Fire advancement trigger + p_232644_1_.func_213846_b(((CraftWorld) fromWorld).getHandle()); @@ -715,7 +736,7 @@ return serverplayerentity; } -@@ -484,12 +740,40 @@ +@@ -484,12 +755,40 @@ public void func_72374_b() { if (++this.field_72408_o > 600) { @@ -757,7 +778,7 @@ public void func_148540_a(IPacket p_148540_1_) { for(int i = 0; i < this.field_72404_b.size(); ++i) { (this.field_72404_b.get(i)).field_71135_a.func_147359_a(p_148540_1_); -@@ -585,6 +869,7 @@ +@@ -585,6 +884,7 @@ p_187245_1_.field_71135_a.func_147359_a(new SEntityStatusPacket(p_187245_1_, b0)); } @@ -765,7 +786,7 @@ this.field_72400_f.func_195571_aL().func_197051_a(p_187245_1_); } -@@ -598,18 +883,19 @@ +@@ -598,18 +898,19 @@ @Nullable public ServerPlayerEntity func_152612_a(String p_152612_1_) { @@ -792,7 +813,7 @@ if (serverplayerentity != p_148543_1_ && serverplayerentity.field_70170_p.func_234923_W_() == p_148543_10_) { double d0 = p_148543_2_ - serverplayerentity.func_226277_ct_(); double d1 = p_148543_4_ - serverplayerentity.func_226278_cu_(); -@@ -649,22 +935,32 @@ +@@ -649,22 +950,32 @@ } public void func_72354_b(ServerPlayerEntity p_72354_1_, ServerWorld p_72354_2_) { @@ -827,7 +848,7 @@ } public int func_72394_k() { -@@ -719,7 +1015,7 @@ +@@ -719,7 +1030,7 @@ p_72381_1_.field_71134_c.func_241820_a(this.field_72410_m, GameType.NOT_SET); } @@ -836,7 +857,7 @@ } @OnlyIn(Dist.CLIENT) -@@ -728,32 +1024,50 @@ +@@ -728,32 +1039,50 @@ } public void func_72392_r() { @@ -895,7 +916,7 @@ } return serverstatisticsmanager; -@@ -761,12 +1075,12 @@ +@@ -761,12 +1090,12 @@ public PlayerAdvancements func_192054_h(ServerPlayerEntity p_192054_1_) { UUID uuid = p_192054_1_.func_110124_au(); @@ -910,7 +931,7 @@ } playeradvancements.func_192739_a(p_192054_1_); -@@ -786,7 +1100,7 @@ +@@ -786,7 +1115,7 @@ } public List func_181057_v() { @@ -919,7 +940,7 @@ } @Nullable -@@ -799,11 +1113,14 @@ +@@ -799,11 +1128,14 @@ } public void func_193244_w() { @@ -936,7 +957,7 @@ SUpdateRecipesPacket supdaterecipespacket = new SUpdateRecipesPacket(this.field_72400_f.func_199529_aN().func_199510_b()); for(ServerPlayerEntity serverplayerentity : this.field_72404_b) { -@@ -816,4 +1133,12 @@ +@@ -816,4 +1148,12 @@ public boolean func_206257_x() { return this.field_72407_n; } diff --git a/patches/minecraft/net/minecraft/tileentity/BellTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/BellTileEntity.java.patch new file mode 100644 index 0000000000..552dc477d3 --- /dev/null +++ b/patches/minecraft/net/minecraft/tileentity/BellTileEntity.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/tileentity/BellTileEntity.java ++++ b/net/minecraft/tileentity/BellTileEntity.java +@@ -23,8 +23,8 @@ + public int field_213943_a; + public boolean field_213944_b; + public Direction field_213945_c; +- private List field_213947_h; +- private boolean field_213948_i; ++ private List field_213947_h;private List getEntitiesAtRing() { return this.field_213947_h; } // Paper - OBFHELPER ++ private boolean field_213948_i;private boolean getShouldReveal() { return this.field_213948_i; } // Paper - OBFHELPER + private int field_213949_j; + + public BellTileEntity() { +@@ -51,6 +51,11 @@ + + if (this.field_213943_a >= 50) { + this.field_213944_b = false; ++ // Paper start ++ if (!this.getShouldReveal()) { ++ this.getEntitiesAtRing().clear(); ++ } ++ // Paper end + this.field_213943_a = 0; + } + +@@ -65,6 +70,7 @@ + } else { + this.func_222828_b(this.field_145850_b); + this.func_222826_c(this.field_145850_b); ++ this.getEntitiesAtRing().clear(); // Paper + this.field_213948_i = false; + } + } +@@ -102,7 +108,7 @@ + } + } + } +- ++ this.getEntitiesAtRing().removeIf(e -> !e.func_70089_S()); // Paper + } + + private boolean func_222830_f() { diff --git a/patches/minecraft/net/minecraft/tileentity/CampfireTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/CampfireTileEntity.java.patch index 3a01c438b8..0b32dda4c6 100644 --- a/patches/minecraft/net/minecraft/tileentity/CampfireTileEntity.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/CampfireTileEntity.java.patch @@ -1,6 +1,14 @@ --- a/net/minecraft/tileentity/CampfireTileEntity.java +++ b/net/minecraft/tileentity/CampfireTileEntity.java -@@ -21,11 +21,14 @@ +@@ -5,6 +5,7 @@ + import javax.annotation.Nullable; + import net.minecraft.block.BlockState; + import net.minecraft.block.CampfireBlock; ++import net.minecraft.entity.item.ItemEntity; + import net.minecraft.inventory.IClearable; + import net.minecraft.inventory.IInventory; + import net.minecraft.inventory.Inventory; +@@ -21,11 +22,14 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; @@ -17,10 +25,11 @@ public CampfireTileEntity() { super(TileEntityType.field_222488_F); -@@ -64,6 +67,19 @@ +@@ -64,7 +68,23 @@ return p_213979_1_.func_77572_b(iinventory); }).orElse(itemstack); BlockPos blockpos = this.func_174877_v(); +- InventoryHelper.func_180173_a(this.field_145850_b, (double)blockpos.func_177958_n(), (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p(), itemstack1); + + // CraftBukkit start - fire BlockCookEvent + CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); @@ -33,7 +42,11 @@ + result = blockCookEvent.getResult(); + itemstack1 = CraftItemStack.asNMSCopy(result); + // CraftBukkit end -+ - InventoryHelper.func_180173_a(this.field_145850_b, (double)blockpos.func_177958_n(), (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p(), itemstack1); ++ // Paper start ++ ItemEntity droppedItem = new ItemEntity(this.field_145850_b, blockpos.func_177958_n() + 0.5D, blockpos.func_177956_o() + 0.5D, blockpos.func_177952_p() + 0.5D, itemstack1.func_77979_a(this.field_145850_b.field_73012_v.nextInt(21) + 10)); ++ droppedItem.func_213293_j(this.field_145850_b.field_73012_v.nextGaussian() * 0.05D, this.field_145850_b.field_73012_v.nextGaussian() * 0.05D + 0.2D, this.field_145850_b.field_73012_v.nextGaussian() * 0.05D); ++ this.field_145850_b.func_217376_c(droppedItem); ++ // Paper end this.field_213987_a.set(i, ItemStack.field_190927_a); this.func_213981_s(); + } diff --git a/patches/minecraft/net/minecraft/tileentity/SignTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/SignTileEntity.java.patch index 896fc4979f..96c0471762 100644 --- a/patches/minecraft/net/minecraft/tileentity/SignTileEntity.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/SignTileEntity.java.patch @@ -8,7 +8,7 @@ import java.util.function.Function; import javax.annotation.Nullable; import net.minecraft.block.BlockState; -@@ -23,10 +24,11 @@ +@@ -23,13 +24,15 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -23,7 +23,11 @@ private PlayerEntity field_145917_k; private final IReorderingProcessor[] field_212367_h = new IReorderingProcessor[4]; private DyeColor field_214073_l = DyeColor.BLACK; -@@ -43,6 +45,12 @@ ++ public java.util.UUID signEditor; // Paper + + public SignTileEntity() { + super(TileEntityType.field_200978_i); +@@ -43,6 +46,12 @@ p_189515_1_.func_74778_a("Text" + (i + 1), s); } @@ -36,7 +40,7 @@ p_189515_1_.func_74778_a("Color", this.field_214073_l.func_176762_d()); return p_189515_1_; } -@@ -52,17 +60,36 @@ +@@ -52,17 +61,36 @@ super.func_230337_a_(p_230337_1_, p_230337_2_); this.field_214073_l = DyeColor.func_204271_a(p_230337_2_.func_74779_i("Color"), DyeColor.BLACK); @@ -58,7 +62,7 @@ + } + + try { -+ if (oldSign) { ++ if (oldSign && !isLoadingStructure) { // Paper - saved structures will be in the new format, but will not have isConverted + field_145915_a[i] = org.bukkit.craftbukkit.v1_16_R3.util.CraftChatMessage.fromString(s)[0]; + continue; + } @@ -81,7 +85,15 @@ } this.field_212367_h[i] = null; -@@ -138,10 +165,38 @@ +@@ -118,6 +146,7 @@ + + public void func_145912_a(PlayerEntity p_145912_1_) { + this.field_145917_k = p_145912_1_; ++ signEditor = p_145912_1_ != null ? p_145912_1_.func_110124_au() : null; + } + + public PlayerEntity func_145911_b() { +@@ -138,10 +167,38 @@ return true; } diff --git a/patches/minecraft/net/minecraft/tileentity/SkullTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/SkullTileEntity.java.patch index 798f2d4745..1b9307d61f 100644 --- a/patches/minecraft/net/minecraft/tileentity/SkullTileEntity.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/SkullTileEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tileentity/SkullTileEntity.java +++ b/net/minecraft/tileentity/SkullTileEntity.java -@@ -1,16 +1,32 @@ +@@ -1,16 +1,33 @@ package net.minecraft.tileentity; +import com.google.common.base.Predicate; @@ -27,13 +27,14 @@ import net.minecraft.block.Blocks; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; ++import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.network.play.server.SUpdateTileEntityPacket; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.management.PlayerProfileCache; import net.minecraft.util.StringUtils; import net.minecraftforge.api.distmarker.Dist; -@@ -22,10 +38,54 @@ +@@ -22,10 +39,54 @@ @Nullable private static MinecraftSessionService field_184299_k; @Nullable @@ -89,7 +90,46 @@ public SkullTileEntity() { super(TileEntityType.field_200985_p); } -@@ -101,32 +161,71 @@ +@@ -88,9 +149,37 @@ + + @Nullable + public SUpdateTileEntityPacket func_189518_D_() { +- return new SUpdateTileEntityPacket(this.field_174879_c, 4, this.func_189517_E_()); ++ return new SUpdateTileEntityPacket(this.field_174879_c, 4, sanitizeTileEntityUUID(this.func_189517_E_())); // Paper + } + ++ // Paper start ++ public static CompoundNBT sanitizeTileEntityUUID(CompoundNBT cmp) { ++ CompoundNBT owner = cmp.func_74775_l("Owner"); ++ if (!owner.isEmpty()) { ++ sanitizeUUID(owner); ++ } ++ return cmp; ++ } ++ ++ public static void sanitizeUUID(CompoundNBT owner) { ++ CompoundNBT properties = owner.func_74775_l("Properties"); ++ ListNBT list = null; ++ if (!properties.isEmpty()) { ++ list = properties.func_150295_c("textures", 10); ++ } ++ ++ if (list != null && !list.isEmpty()) { ++ String textures = ((CompoundNBT)list.get(0)).func_74779_i("Value"); ++ if (textures != null && textures.length() > 3) { ++ UUID uuid = UUID.nameUUIDFromBytes(textures.getBytes()); ++ owner.func_186854_a("Id", uuid); ++ return; ++ } ++ } ++ owner.func_186854_a("Id", UUID.randomUUID()); ++ } ++ // Paper end ++ + public CompoundNBT func_189517_E_() { + return this.func_189515_b(new CompoundNBT()); + } +@@ -101,32 +190,71 @@ } private void func_152109_d() { diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch index 337bc14ccd..82323fdfa7 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch @@ -12,7 +12,7 @@ import net.minecraft.network.play.server.SUpdateTileEntityPacket; import net.minecraft.util.Mirror; import net.minecraft.util.ResourceLocation; -@@ -15,20 +17,32 @@ +@@ -15,20 +17,33 @@ import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -29,6 +29,7 @@ + public CraftPersistentDataContainer persistentDataContainer; + // CraftBukkit end private static final Logger field_145852_a = LogManager.getLogger(); ++ public boolean isLoadingStructure = false; // Paper private final TileEntityType field_200663_e; @Nullable - protected World field_145850_b; @@ -48,7 +49,7 @@ } @Nullable -@@ -47,6 +61,15 @@ +@@ -47,6 +62,15 @@ public void func_230337_a_(BlockState p_230337_1_, CompoundNBT p_230337_2_) { this.field_174879_c = new BlockPos(p_230337_2_.func_74762_e("x"), p_230337_2_.func_74762_e("y"), p_230337_2_.func_74762_e("z")); @@ -64,7 +65,7 @@ } public CompoundNBT func_189515_b(CompoundNBT p_189515_1_) { -@@ -62,6 +85,13 @@ +@@ -62,6 +86,13 @@ p_189516_1_.func_74768_a("x", this.field_174879_c.func_177958_n()); p_189516_1_.func_74768_a("y", this.field_174879_c.func_177956_o()); p_189516_1_.func_74768_a("z", this.field_174879_c.func_177952_p()); @@ -78,7 +79,7 @@ return p_189516_1_; } } -@@ -94,7 +124,7 @@ +@@ -94,7 +125,7 @@ if (this.field_145850_b != null) { this.field_195045_e = this.field_145850_b.func_180495_p(this.field_174879_c); this.field_145850_b.func_175646_b(this.field_174879_c, this); @@ -87,7 +88,7 @@ this.field_145850_b.func_175666_e(this.field_174879_c, this.field_195045_e.func_177230_c()); } } -@@ -133,6 +163,8 @@ +@@ -133,6 +164,8 @@ public void func_145843_s() { this.field_145846_f = true; @@ -96,7 +97,7 @@ } public void func_145829_t() { -@@ -175,6 +207,13 @@ +@@ -175,6 +208,13 @@ return this.field_200663_e; } @@ -110,7 +111,7 @@ public void func_222814_r() { if (!this.field_222816_g) { this.field_222816_g = true; -@@ -183,4 +222,10 @@ +@@ -183,4 +223,10 @@ }, this::func_174877_v); } } diff --git a/patches/minecraft/net/minecraft/util/SharedConstants.java.patch b/patches/minecraft/net/minecraft/util/SharedConstants.java.patch index 9359753211..17daed0f71 100644 --- a/patches/minecraft/net/minecraft/util/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/util/SharedConstants.java.patch @@ -1,6 +1,14 @@ --- a/net/minecraft/util/SharedConstants.java +++ b/net/minecraft/util/SharedConstants.java -@@ -44,6 +44,7 @@ +@@ -19,6 +19,7 @@ + return p_71566_0_ != 167 && p_71566_0_ >= ' ' && p_71566_0_ != 127; + } + ++ public static String filterAllowedChatCharacters(String input) { return func_71565_a(input); } // Paper - OBFHELPER + public static String func_71565_a(String p_71565_0_) { + StringBuilder stringbuilder = new StringBuilder(); + +@@ -44,6 +45,7 @@ } static { diff --git a/patches/minecraft/net/minecraft/util/WeightedList.java.patch b/patches/minecraft/net/minecraft/util/WeightedList.java.patch new file mode 100644 index 0000000000..5b06c931b2 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/WeightedList.java.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/util/WeightedList.java ++++ b/net/minecraft/util/WeightedList.java +@@ -14,12 +14,21 @@ + public class WeightedList { + protected final List> field_220658_a; + private final Random field_220659_b = new Random(); ++ private final boolean isUnsafe; // Paper + ++ // Paper start - add useClone option + public WeightedList() { +- this(Lists.newArrayList()); ++ this(true); + } + +- private WeightedList(List> p_i231541_1_) { ++ public WeightedList(boolean isUnsafe) { ++ this(Lists.newArrayList(), isUnsafe); ++ } ++ ++ private WeightedList(List> p_i231541_1_) { this(p_i231541_1_, true); } ++ private WeightedList(List> p_i231541_1_, boolean isUnsafe) { ++ this.isUnsafe = isUnsafe; ++ // Paper end + this.field_220658_a = Lists.newArrayList(p_i231541_1_); + } + +@@ -39,13 +48,16 @@ + } + + public WeightedList func_226314_a_(Random p_226314_1_) { ++ // Paper start - make concurrent safe, work off a clone of the list ++ List> list = isUnsafe ? new java.util.ArrayList>(this.field_220658_a) : this.field_220658_a; + this.field_220658_a.forEach((p_234004_1_) -> { + p_234004_1_.func_220648_a(p_226314_1_.nextFloat()); + }); + this.field_220658_a.sort(Comparator.comparingDouble((p_234003_0_) -> { + return p_234003_0_.func_220649_a(); + })); +- return this; ++ return isUnsafe ? new WeightedList<>(list, isUnsafe) : this; ++ // Paper end + } + + public boolean func_234005_b_() { diff --git a/patches/minecraft/net/minecraft/util/registry/WorldGenRegistries.java.patch b/patches/minecraft/net/minecraft/util/registry/WorldGenRegistries.java.patch index 089b21ee6c..14544473f9 100644 --- a/patches/minecraft/net/minecraft/util/registry/WorldGenRegistries.java.patch +++ b/patches/minecraft/net/minecraft/util/registry/WorldGenRegistries.java.patch @@ -1,15 +1,19 @@ --- a/net/minecraft/util/registry/WorldGenRegistries.java +++ b/net/minecraft/util/registry/WorldGenRegistries.java -@@ -45,7 +45,7 @@ +@@ -44,16 +44,20 @@ + public static final Registry field_243655_g = func_243667_a(Registry.field_243554_aw, () -> { return ProcessorLists.field_244102_b; }); - public static final Registry field_243656_h = func_243667_a(Registry.field_243555_ax, JigsawPatternRegistry::func_244093_a); +- public static final Registry field_243656_h = func_243667_a(Registry.field_243555_ax, JigsawPatternRegistry::func_244093_a); - public static final Registry field_243657_i = func_243667_a(Registry.field_239720_u_, () -> { ++ public static final Registry field_243656_h = func_243667_a(Registry.field_243555_ax, () -> JigsawPatternRegistry.func_244093_a()); // Paper - MC-197271 + @Deprecated public static final Registry field_243657_i = forge(Registry.field_239720_u_, () -> { return BiomeRegistry.field_244200_a; }); - public static final Registry field_243658_j = func_243667_a(Registry.field_243549_ar, DimensionSettings::func_242746_i); -@@ -54,6 +54,10 @@ +- public static final Registry field_243658_j = func_243667_a(Registry.field_243549_ar, DimensionSettings::func_242746_i); ++ public static final Registry field_243658_j = func_243667_a(Registry.field_243549_ar, () -> DimensionSettings.func_242746_i()); // Paper - MC-197271 + + private static Registry func_243667_a(RegistryKey> p_243667_0_, Supplier p_243667_1_) { return func_243665_a(p_243667_0_, Lifecycle.stable(), p_243667_1_); } diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch index 8c05f6da8b..68e497dfb5 100644 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ b/patches/minecraft/net/minecraft/world/World.java.patch @@ -368,16 +368,17 @@ Block.func_220054_a(blockstate, this, p_241212_1_, tileentity, p_241212_3_, ItemStack.field_190927_a); } -@@ -259,6 +470,8 @@ +@@ -259,6 +470,9 @@ } public void func_195593_d(BlockPos p_195593_1_, Block p_195593_2_) { ++ if (captureBlockStates) { return; } // Paper - Cancel all physics during placement + if (net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_195593_1_, this.func_180495_p(p_195593_1_), java.util.EnumSet.allOf(Direction.class), false).isCanceled()) + return; this.func_190524_a(p_195593_1_.func_177976_e(), p_195593_2_, p_195593_1_); this.func_190524_a(p_195593_1_.func_177974_f(), p_195593_2_, p_195593_1_); this.func_190524_a(p_195593_1_.func_177977_b(), p_195593_2_, p_195593_1_); -@@ -268,6 +481,11 @@ +@@ -268,6 +482,11 @@ } public void func_175695_a(BlockPos p_175695_1_, Block p_175695_2_, Direction p_175695_3_) { @@ -389,7 +390,7 @@ if (p_175695_3_ != Direction.WEST) { this.func_190524_a(p_175695_1_.func_177976_e(), p_175695_2_, p_175695_1_); } -@@ -299,15 +517,29 @@ +@@ -299,15 +518,29 @@ BlockState blockstate = this.func_180495_p(p_190524_1_); try { @@ -421,7 +422,7 @@ } }); CrashReportCategory.func_175750_a(crashreportcategory, p_190524_1_, blockstate); -@@ -336,6 +568,14 @@ +@@ -336,6 +569,14 @@ } public BlockState func_180495_p(BlockPos p_180495_1_) { @@ -436,7 +437,7 @@ if (func_189509_E(p_180495_1_)) { return Blocks.field_201940_ji.func_176223_P(); } else { -@@ -391,10 +631,12 @@ +@@ -391,10 +632,12 @@ } public boolean func_175700_a(TileEntity p_175700_1_) { @@ -449,7 +450,7 @@ } boolean flag = this.field_147482_g.add(p_175700_1_); -@@ -402,6 +644,8 @@ +@@ -402,6 +645,8 @@ this.field_175730_i.add(p_175700_1_); } @@ -458,7 +459,7 @@ if (this.field_72995_K) { BlockPos blockpos = p_175700_1_.func_174877_v(); BlockState blockstate = this.func_180495_p(blockpos); -@@ -413,6 +657,7 @@ +@@ -413,6 +658,7 @@ public void func_147448_a(Collection p_147448_1_) { if (this.field_147481_N) { @@ -466,7 +467,7 @@ this.field_147484_a.addAll(p_147448_1_); } else { for(TileEntity tileentity : p_147448_1_) { -@@ -425,24 +670,39 @@ +@@ -425,24 +671,43 @@ public void func_217391_K() { IProfiler iprofiler = this.func_217381_Z(); iprofiler.func_76320_a("blockEntities"); @@ -475,7 +476,12 @@ if (!this.field_147483_b.isEmpty()) { + this.field_147483_b.forEach(e -> e.onChunkUnloaded()); this.field_175730_i.removeAll(this.field_147483_b); - this.field_147482_g.removeAll(this.field_147483_b); +- this.field_147482_g.removeAll(this.field_147483_b); ++ // Paper start - Use alternate implementation with faster contains ++ java.util.Set toRemove = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap<>()); ++ toRemove.addAll(field_147483_b); ++ this.field_147482_g.removeAll(toRemove); ++ // Paper end this.field_147483_b.clear(); } @@ -512,7 +518,7 @@ if (tileentity.func_200662_C().func_223045_a(this.func_180495_p(blockpos).func_177230_c())) { ((ITickableTileEntity)tileentity).func_73660_a(); } else { -@@ -454,35 +714,60 @@ +@@ -454,35 +719,60 @@ CrashReport crashreport = CrashReport.func_85055_a(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.func_85058_a("Block entity being ticked"); tileentity.func_145828_a(crashreportcategory); @@ -577,7 +583,7 @@ } } } -@@ -490,17 +775,24 @@ +@@ -490,17 +780,24 @@ this.field_147484_a.clear(); } @@ -602,7 +608,7 @@ } } -@@ -514,6 +806,7 @@ +@@ -514,6 +811,7 @@ public Explosion func_230546_a_(@Nullable Entity p_230546_1_, @Nullable DamageSource p_230546_2_, @Nullable ExplosionContext p_230546_3_, double p_230546_4_, double p_230546_6_, double p_230546_8_, float p_230546_10_, boolean p_230546_11_, Explosion.Mode p_230546_12_) { Explosion explosion = new Explosion(this, p_230546_1_, p_230546_2_, p_230546_3_, p_230546_4_, p_230546_6_, p_230546_8_, p_230546_10_, p_230546_11_, p_230546_12_); @@ -610,7 +616,7 @@ explosion.func_77278_a(); explosion.func_77279_a(true); return explosion; -@@ -525,22 +818,34 @@ +@@ -525,22 +823,34 @@ @Nullable public TileEntity func_175625_s(BlockPos p_175625_1_) { @@ -649,7 +655,7 @@ } return tileentity; -@@ -561,7 +866,15 @@ +@@ -561,7 +871,15 @@ public void func_175690_a(BlockPos p_175690_1_, @Nullable TileEntity p_175690_2_) { if (!func_189509_E(p_175690_1_)) { @@ -665,7 +671,7 @@ if (this.field_147481_N) { p_175690_2_.func_226984_a_(this, p_175690_1_); Iterator iterator = this.field_147484_a.iterator(); -@@ -576,7 +889,8 @@ +@@ -576,7 +894,8 @@ this.field_147484_a.add(p_175690_2_); } else { @@ -675,7 +681,7 @@ this.func_175700_a(p_175690_2_); } } -@@ -585,10 +899,12 @@ +@@ -585,10 +904,12 @@ } public void func_175713_t(BlockPos p_175713_1_) { @@ -689,7 +695,7 @@ } else { if (tileentity != null) { this.field_147484_a.remove(tileentity); -@@ -598,7 +914,7 @@ +@@ -598,7 +919,7 @@ this.func_175726_f(p_175713_1_).func_177425_e(p_175713_1_); } @@ -698,7 +704,7 @@ } public boolean func_195588_v(BlockPos p_195588_1_) { -@@ -651,10 +967,10 @@ +@@ -651,10 +972,10 @@ public List func_175674_a(@Nullable Entity p_175674_1_, AxisAlignedBB p_175674_2_, @Nullable Predicate p_175674_3_) { this.func_217381_Z().func_230035_c_("getEntities"); List list = Lists.newArrayList(); @@ -713,7 +719,7 @@ AbstractChunkProvider abstractchunkprovider = this.func_72863_F(); for(int i1 = i; i1 <= j; ++i1) { -@@ -671,10 +987,10 @@ +@@ -671,10 +992,10 @@ public List func_217394_a(@Nullable EntityType p_217394_1_, AxisAlignedBB p_217394_2_, Predicate p_217394_3_) { this.func_217381_Z().func_230035_c_("getEntities"); @@ -728,7 +734,7 @@ List list = Lists.newArrayList(); for(int i1 = i; i1 < j; ++i1) { -@@ -691,10 +1007,10 @@ +@@ -691,10 +1012,10 @@ public List func_175647_a(Class p_175647_1_, AxisAlignedBB p_175647_2_, @Nullable Predicate p_175647_3_) { this.func_217381_Z().func_230035_c_("getEntities"); @@ -743,7 +749,7 @@ List list = Lists.newArrayList(); AbstractChunkProvider abstractchunkprovider = this.func_72863_F(); -@@ -712,10 +1028,10 @@ +@@ -712,10 +1033,10 @@ public List func_225316_b(Class p_225316_1_, AxisAlignedBB p_225316_2_, @Nullable Predicate p_225316_3_) { this.func_217381_Z().func_230035_c_("getLoadedEntities"); @@ -758,7 +764,7 @@ List list = Lists.newArrayList(); AbstractChunkProvider abstractchunkprovider = this.func_72863_F(); -@@ -739,6 +1055,7 @@ +@@ -739,6 +1060,7 @@ this.func_175726_f(p_175646_1_).func_76630_e(); } @@ -766,7 +772,7 @@ } public int func_181545_F() { -@@ -783,7 +1100,7 @@ +@@ -783,7 +1105,7 @@ public int func_175651_c(BlockPos p_175651_1_, Direction p_175651_2_) { BlockState blockstate = this.func_180495_p(p_175651_1_); int i = blockstate.func_185911_a(this, p_175651_1_, p_175651_2_); @@ -775,7 +781,7 @@ } public boolean func_175640_z(BlockPos p_175640_1_) { -@@ -938,16 +1255,15 @@ +@@ -938,16 +1260,15 @@ public abstract Scoreboard func_96441_U(); public void func_175666_e(BlockPos p_175666_1_, Block p_175666_2_) { @@ -796,7 +802,7 @@ blockstate.func_215697_a(this, blockpos, p_175666_2_, p_175666_1_, false); } } -@@ -1024,7 +1340,27 @@ +@@ -1024,7 +1345,27 @@ return this.field_226689_w_; } diff --git a/patches/minecraft/net/minecraft/world/biome/provider/EndBiomeProvider.java.patch b/patches/minecraft/net/minecraft/world/biome/provider/EndBiomeProvider.java.patch new file mode 100644 index 0000000000..7ad40a4567 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/biome/provider/EndBiomeProvider.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/world/biome/provider/EndBiomeProvider.java ++++ b/net/minecraft/world/biome/provider/EndBiomeProvider.java +@@ -83,7 +83,9 @@ + int j = p_235317_2_ / 2; + int k = p_235317_1_ % 2; + int l = p_235317_2_ % 2; +- float f = 100.0F - MathHelper.func_76129_c((float)(p_235317_1_ * p_235317_1_ + p_235317_2_ * p_235317_2_)) * 8.0F; ++ // Paper start - cast ints to long to avoid integer overflow ++ float f = 100.0F - MathHelper.func_76129_c((long) p_235317_1_ * (long) p_235317_1_ + (long) p_235317_2_ * (long) p_235317_2_) * 8.0F; ++ // Paper end + f = MathHelper.func_76131_a(f, -100.0F, 80.0F); + + for(int i1 = -12; i1 <= 12; ++i1) { diff --git a/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch index 53e0fe5b28..2c7ae675ec 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/template/Template.java.patch @@ -20,7 +20,19 @@ BlockPos blockpos = template$blockinfo.field_186242_a; if (mutableboundingbox == null || mutableboundingbox.func_175898_b(blockpos)) { FluidState fluidstate = p_237146_4_.func_204763_l() ? p_237146_1_.func_204610_c(blockpos) : null; -@@ -330,7 +334,7 @@ +@@ -244,9 +248,11 @@ + template$blockinfo.field_186244_c.func_74772_a("LootTableSeed", p_237146_5_.nextLong()); + } + ++ tileentity1.isLoadingStructure = true; + tileentity1.func_230337_a_(template$blockinfo.field_186243_b, template$blockinfo.field_186244_c); + tileentity1.func_189668_a(p_237146_4_.func_186212_b()); + tileentity1.func_189667_a(p_237146_4_.func_186215_c()); ++ tileentity1.isLoadingStructure = false; + } + } + +@@ -330,7 +336,7 @@ } if (!p_237146_4_.func_186221_e()) { @@ -29,7 +41,7 @@ } return true; -@@ -359,14 +363,19 @@ +@@ -359,14 +365,19 @@ }); } @@ -50,7 +62,7 @@ } if (template$blockinfo1 != null) { -@@ -377,13 +386,30 @@ +@@ -377,13 +388,30 @@ return list; } @@ -87,7 +99,7 @@ ListNBT listnbt = new ListNBT(); listnbt.add(DoubleNBT.func_229684_a_(vector3d1.field_72450_a)); listnbt.add(DoubleNBT.func_229684_a_(vector3d1.field_72448_b)); -@@ -391,10 +417,10 @@ +@@ -391,10 +419,10 @@ compoundnbt.func_218657_a("Pos", listnbt); compoundnbt.func_82580_o("UUID"); func_215382_a(p_237143_1_, compoundnbt).ifPresent((p_242927_6_) -> { diff --git a/patches/minecraft/net/minecraft/world/gen/surfacebuilders/NetherForestsSurfaceBuilder.java.patch b/patches/minecraft/net/minecraft/world/gen/surfacebuilders/NetherForestsSurfaceBuilder.java.patch new file mode 100644 index 0000000000..6be24b3dc0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/surfacebuilders/NetherForestsSurfaceBuilder.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/gen/surfacebuilders/NetherForestsSurfaceBuilder.java ++++ b/net/minecraft/world/gen/surfacebuilders/NetherForestsSurfaceBuilder.java +@@ -33,7 +33,7 @@ + int i1 = -1; + BlockState blockstate = p_205610_14_.func_204109_b(); + +- for(int j1 = 127; j1 >= 0; --j1) { ++ for(int j1 = p_205610_6_; j1 >= 0; --j1) { + blockpos$mutable.func_181079_c(j, j1, k); + BlockState blockstate1 = p_205610_14_.func_204108_a(); + BlockState blockstate2 = p_205610_2_.func_180495_p(blockpos$mutable); diff --git a/patches/minecraft/net/minecraft/world/gen/surfacebuilders/NetherSurfaceBuilder.java.patch b/patches/minecraft/net/minecraft/world/gen/surfacebuilders/NetherSurfaceBuilder.java.patch new file mode 100644 index 0000000000..c621e4e808 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/surfacebuilders/NetherSurfaceBuilder.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/gen/surfacebuilders/NetherSurfaceBuilder.java ++++ b/net/minecraft/world/gen/surfacebuilders/NetherSurfaceBuilder.java +@@ -35,7 +35,7 @@ + BlockState blockstate = p_205610_14_.func_204108_a(); + BlockState blockstate1 = p_205610_14_.func_204109_b(); + +- for(int j1 = 127; j1 >= 0; --j1) { ++ for(int j1 = p_205610_6_; j1 >= 0; --j1) { + blockpos$mutable.func_181079_c(j, j1, k); + BlockState blockstate2 = p_205610_2_.func_180495_p(blockpos$mutable); + if (blockstate2.func_196958_f()) { diff --git a/patches/minecraft/net/minecraft/world/gen/surfacebuilders/ValleySurfaceBuilder.java.patch b/patches/minecraft/net/minecraft/world/gen/surfacebuilders/ValleySurfaceBuilder.java.patch new file mode 100644 index 0000000000..aa19673c21 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/surfacebuilders/ValleySurfaceBuilder.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/gen/surfacebuilders/ValleySurfaceBuilder.java ++++ b/net/minecraft/world/gen/surfacebuilders/ValleySurfaceBuilder.java +@@ -41,7 +41,7 @@ + BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); + BlockState blockstate2 = p_205610_2_.func_180495_p(blockpos$mutable.func_181079_c(j, 128, k)); + +- for(int j1 = 127; j1 >= 0; --j1) { ++ for(int j1 = p_205610_6_; j1 >= 0; --j1) { + blockpos$mutable.func_181079_c(j, j1, k); + BlockState blockstate3 = p_205610_2_.func_180495_p(blockpos$mutable); + if (blockstate2.func_203425_a(p_205610_9_.func_177230_c()) && (blockstate3.func_196958_f() || blockstate3 == p_205610_10_)) { diff --git a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch b/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch index 027deac96d..29bbcb69b4 100644 --- a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch +++ b/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch @@ -202,7 +202,7 @@ public void func_241113_a_(int p_241113_1_, int p_241113_2_, boolean p_241113_3_, boolean p_241113_4_) { this.field_241103_E_.func_230391_a_(p_241113_1_); this.field_241103_E_.func_76080_g(p_241113_2_); -@@ -211,6 +254,11 @@ +@@ -211,6 +254,12 @@ this.field_241103_E_.func_76069_a(p_241113_4_); } @@ -211,10 +211,11 @@ + return this; + } + ++ public Biome getBiomeBySeed(int x, int y, int z) { return func_225604_a_(x, y, z); } // Paper - OBFHELPER public Biome func_225604_a_(int p_225604_1_, int p_225604_2_, int p_225604_3_) { return this.func_72863_F().func_201711_g().func_202090_b().func_225526_b_(p_225604_1_, p_225604_2_, p_225604_3_); } -@@ -288,35 +336,70 @@ +@@ -288,35 +337,70 @@ this.field_73004_o = MathHelper.func_76131_a(this.field_73004_o, 0.0F, 1.0F); } @@ -299,7 +300,7 @@ if (this.func_82736_K().func_223586_b(GameRules.field_223617_t)) { this.func_73051_P(); } -@@ -327,23 +410,28 @@ +@@ -327,23 +411,28 @@ iprofiler.func_219895_b("chunkSource"); this.func_72863_F().func_217207_a(p_72835_1_); iprofiler.func_219895_b("tickPending"); @@ -329,7 +330,7 @@ if (this.field_241105_O_ != null) { this.field_241105_O_.func_186105_b(); } -@@ -351,18 +439,22 @@ +@@ -351,18 +440,22 @@ this.field_217492_a = true; ObjectIterator> objectiterator = this.field_217498_x.int2ObjectEntrySet().iterator(); @@ -352,7 +353,7 @@ this.func_217391_K(); break label164; } -@@ -370,13 +462,15 @@ +@@ -370,13 +463,15 @@ Entry entry = objectiterator.next(); entity1 = entry.getValue(); Entity entity2 = entity1.func_184187_bx(); @@ -372,7 +373,7 @@ iprofiler.func_76320_a("checkDespawn"); if (!entity1.field_70128_L) { -@@ -404,7 +498,7 @@ +@@ -404,7 +499,7 @@ if (entity1.field_70128_L) { this.func_217454_n(entity1); objectiterator.remove(); @@ -381,7 +382,7 @@ } iprofiler.func_76319_b(); -@@ -460,13 +554,13 @@ +@@ -460,13 +555,13 @@ skeletonhorseentity.func_190691_p(true); skeletonhorseentity.func_70873_a(0); skeletonhorseentity.func_70107_b((double)blockpos.func_177958_n(), (double)blockpos.func_177956_o(), (double)blockpos.func_177952_p()); @@ -397,7 +398,7 @@ } } -@@ -475,12 +569,13 @@ +@@ -475,12 +570,13 @@ BlockPos blockpos2 = this.func_205770_a(Heightmap.Type.MOTION_BLOCKING, this.func_217383_a(i, 0, j, 15)); BlockPos blockpos3 = blockpos2.func_177977_b(); Biome biome = this.func_226691_t_(blockpos2); @@ -413,7 +414,7 @@ } if (flag && this.func_226691_t_(blockpos3).func_201851_b() == Biome.RainType.RAIN) { -@@ -544,7 +639,7 @@ +@@ -544,7 +640,7 @@ int j = 0; for(ServerPlayerEntity serverplayerentity : this.field_217491_A) { @@ -422,7 +423,7 @@ ++i; } else if (serverplayerentity.func_70608_bn()) { ++j; -@@ -561,10 +656,22 @@ +@@ -561,10 +657,22 @@ } private void func_73051_P() { @@ -447,7 +448,7 @@ } public void func_82742_i() { -@@ -591,6 +698,14 @@ +@@ -591,6 +699,14 @@ if (!(p_217479_1_ instanceof PlayerEntity) && !this.func_72863_F().func_217204_a(p_217479_1_)) { this.func_217464_b(p_217479_1_); } else { @@ -462,7 +463,7 @@ p_217479_1_.func_226286_f_(p_217479_1_.func_226277_ct_(), p_217479_1_.func_226278_cu_(), p_217479_1_.func_226281_cx_()); p_217479_1_.field_70126_B = p_217479_1_.field_70177_z; p_217479_1_.field_70127_C = p_217479_1_.field_70125_A; -@@ -598,10 +713,12 @@ +@@ -598,10 +714,12 @@ ++p_217479_1_.field_70173_aa; IProfiler iprofiler = this.func_217381_Z(); iprofiler.func_194340_a(() -> { @@ -476,7 +477,7 @@ iprofiler.func_76319_b(); } -@@ -611,6 +728,7 @@ +@@ -611,6 +729,7 @@ this.func_217459_a(p_217479_1_, entity); } } @@ -484,7 +485,16 @@ } } -@@ -678,6 +796,7 @@ +@@ -649,7 +768,7 @@ + if (p_217464_1_.func_233578_ci_()) { + this.func_217381_Z().func_76320_a("chunkCheck"); + int i = MathHelper.func_76128_c(p_217464_1_.func_226277_ct_() / 16.0D); +- int j = MathHelper.func_76128_c(p_217464_1_.func_226278_cu_() / 16.0D); ++ int j = Math.min(15, Math.max(0, MathHelper.func_76128_c(p_217464_1_.func_226278_cu_() / 16.0D))); // Paper - stay consistent with chunk add/remove behavior + int k = MathHelper.func_76128_c(p_217464_1_.func_226281_cx_() / 16.0D); + if (!p_217464_1_.field_70175_ag || p_217464_1_.field_70176_ah != i || p_217464_1_.field_70162_ai != j || p_217464_1_.field_70164_aj != k) { + if (p_217464_1_.field_70175_ag && this.func_217354_b(p_217464_1_.field_70176_ah, p_217464_1_.field_70164_aj)) { +@@ -678,6 +797,7 @@ public void func_217445_a(@Nullable IProgressUpdate p_217445_1_, boolean p_217445_2_, boolean p_217445_3_) { ServerChunkProvider serverchunkprovider = this.func_72863_F(); if (!p_217445_3_) { @@ -492,7 +502,7 @@ if (p_217445_1_ != null) { p_217445_1_.func_200210_a(new TranslationTextComponent("menu.savingLevel")); } -@@ -687,13 +806,21 @@ +@@ -687,13 +807,21 @@ p_217445_1_.func_200209_c(new TranslationTextComponent("menu.savingChunks")); } @@ -515,7 +525,7 @@ } this.func_72863_F().func_217227_h().func_212775_b(); -@@ -742,14 +869,28 @@ +@@ -742,14 +870,28 @@ return list.isEmpty() ? null : list.get(this.field_73012_v.nextInt(list.size())); } @@ -546,7 +556,7 @@ public void func_217460_e(Entity p_217460_1_) { boolean flag = p_217460_1_.field_98038_p; p_217460_1_.field_98038_p = true; -@@ -777,6 +918,7 @@ +@@ -777,6 +919,7 @@ } private void func_217448_f(ServerPlayerEntity p_217448_1_) { @@ -554,7 +564,7 @@ Entity entity = this.field_175741_N.get(p_217448_1_.func_110124_au()); if (entity != null) { field_147491_a.warn("Force-added player with duplicate UUID {}", (Object)p_217448_1_.func_110124_au().toString()); -@@ -795,18 +937,25 @@ +@@ -795,18 +938,26 @@ } private boolean func_72838_d(Entity p_72838_1_) { @@ -565,6 +575,7 @@ + + private boolean addEntity0(Entity entityIn, CreatureSpawnEvent.SpawnReason spawnReason) { + org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot ++ if (entityIn.valid) { MinecraftServer.field_147145_h.error("Attempted Double World add on " + entityIn, new Throwable()); return true; } // Paper + if (entityIn.field_70128_L) { + // LOGGER.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.getKey(entityIn.getType())); // CraftBukkit return false; @@ -586,7 +597,7 @@ return true; } } -@@ -816,6 +965,7 @@ +@@ -816,6 +967,7 @@ if (this.func_217478_l(p_217440_1_)) { return false; } else { @@ -594,7 +605,7 @@ this.func_217465_m(p_217440_1_); return true; } -@@ -860,6 +1010,15 @@ +@@ -860,6 +1012,15 @@ } public void func_217466_a(Chunk p_217466_1_) { @@ -610,7 +621,7 @@ this.field_147483_b.addAll(p_217466_1_.func_177434_r().values()); ClassInheritanceMultiMap[] aclassinheritancemultimap = p_217466_1_.func_177429_s(); int i = aclassinheritancemultimap.length; -@@ -879,12 +1038,41 @@ +@@ -879,12 +1040,42 @@ } @@ -635,6 +646,7 @@ + { + if ( iter.next().field_76211_a == p_217484_1_ ) + { ++ map.field_76203_h.remove(p_217484_1_.func_145748_c_().getString()); // Paper + iter.remove(); + } + } @@ -653,7 +665,7 @@ this.field_175741_N.remove(p_217484_1_.func_110124_au()); this.func_72863_F().func_217226_b(p_217484_1_); -@@ -894,13 +1082,23 @@ +@@ -894,13 +1085,23 @@ } this.func_96441_U().func_181140_a(p_217484_1_); @@ -677,7 +689,7 @@ if (this.field_217492_a) { this.field_217499_z.add(p_217465_1_); } else { -@@ -913,20 +1111,31 @@ +@@ -913,20 +1114,31 @@ this.field_175741_N.put(p_217465_1_.func_110124_au(), p_217465_1_); this.func_72863_F().func_217230_c(p_217465_1_); @@ -710,7 +722,7 @@ } } -@@ -939,17 +1148,47 @@ +@@ -939,17 +1151,47 @@ } public void func_217434_e(ServerPlayerEntity p_217434_1_) { @@ -760,7 +772,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { serverplayerentity.field_71135_a.func_147359_a(new SAnimateBlockBreakPacket(p_175715_1_, p_175715_2_, p_175715_3_)); } -@@ -959,10 +1198,20 @@ +@@ -959,10 +1201,20 @@ } public void func_184148_a(@Nullable PlayerEntity p_184148_1_, double p_184148_2_, double p_184148_4_, double p_184148_6_, SoundEvent p_184148_8_, SoundCategory p_184148_9_, float p_184148_10_, float p_184148_11_) { @@ -781,7 +793,7 @@ this.field_73061_a.func_184103_al().func_148543_a(p_217384_1_, p_217384_2_.func_226277_ct_(), p_217384_2_.func_226278_cu_(), p_217384_2_.func_226281_cx_(), p_217384_5_ > 1.0F ? (double)(16.0F * p_217384_5_) : 16.0D, this.func_234923_W_(), new SSpawnMovingSoundEffectPacket(p_217384_3_, p_217384_4_, p_217384_2_, p_217384_5_, p_217384_6_)); } -@@ -997,9 +1246,17 @@ +@@ -997,9 +1249,17 @@ } public Explosion func_230546_a_(@Nullable Entity p_230546_1_, @Nullable DamageSource p_230546_2_, @Nullable ExplosionContext p_230546_3_, double p_230546_4_, double p_230546_6_, double p_230546_8_, float p_230546_10_, boolean p_230546_11_, Explosion.Mode p_230546_12_) { @@ -802,7 +814,7 @@ if (p_230546_12_ == Explosion.Mode.NONE) { explosion.func_180342_d(); } -@@ -1054,12 +1311,19 @@ +@@ -1054,12 +1314,19 @@ } public int func_195598_a(T p_195598_1_, double p_195598_2_, double p_195598_4_, double p_195598_6_, int p_195598_8_, double p_195598_9_, double p_195598_11_, double p_195598_13_, double p_195598_15_) { @@ -824,7 +836,7 @@ ++i; } } -@@ -1098,7 +1362,7 @@ +@@ -1098,7 +1365,7 @@ @Nullable public BlockPos func_241117_a_(Structure p_241117_1_, BlockPos p_241117_2_, int p_241117_3_, boolean p_241117_4_) { @@ -833,7 +845,7 @@ } @Nullable -@@ -1131,7 +1395,13 @@ +@@ -1131,7 +1398,13 @@ @Nullable public MapData func_217406_a(String p_217406_1_) { return this.func_73046_m().func_241755_D_().func_217481_x().func_215753_b(() -> { @@ -848,7 +860,7 @@ }, p_217406_1_); } -@@ -1333,6 +1603,11 @@ +@@ -1333,6 +1606,11 @@ public void func_230547_a_(BlockPos p_230547_1_, Block p_230547_2_) { if (!this.func_234925_Z_()) { @@ -860,7 +872,7 @@ this.func_195593_d(p_230547_1_, p_230547_2_); } -@@ -1352,11 +1627,11 @@ +@@ -1352,11 +1630,11 @@ } public boolean func_241109_A_() { @@ -874,7 +886,7 @@ } @Nullable -@@ -1399,15 +1674,40 @@ +@@ -1399,15 +1677,40 @@ } public static void func_241121_a_(ServerWorld p_241121_0_) { diff --git a/patches/minecraft/net/minecraft/world/storage/MapData.java.patch b/patches/minecraft/net/minecraft/world/storage/MapData.java.patch index e3cdba7304..b30e318ebf 100644 --- a/patches/minecraft/net/minecraft/world/storage/MapData.java.patch +++ b/patches/minecraft/net/minecraft/world/storage/MapData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/storage/MapData.java +++ b/net/minecraft/world/storage/MapData.java -@@ -2,10 +2,12 @@ +@@ -2,18 +2,24 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -8,12 +8,24 @@ import com.mojang.serialization.Dynamic; import java.util.Iterator; import java.util.List; ++import java.util.Locale; import java.util.Map; +import java.util.UUID; import javax.annotation.Nullable; import net.minecraft.entity.item.ItemFrameEntity; import net.minecraft.entity.player.PlayerEntity; -@@ -27,6 +29,10 @@ + import net.minecraft.item.FilledMapItem; + import net.minecraft.item.ItemStack; + import net.minecraft.nbt.CompoundNBT; ++import net.minecraft.nbt.INBT; + import net.minecraft.nbt.ListNBT; + import net.minecraft.nbt.NBTDynamicOps; ++import net.minecraft.nbt.NumberNBT; ++import net.minecraft.nbt.StringNBT; + import net.minecraft.network.IPacket; + import net.minecraft.network.play.server.SMapDataPacket; + import net.minecraft.util.RegistryKey; +@@ -27,6 +33,10 @@ import net.minecraft.world.World; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -24,9 +36,11 @@ public class MapData extends WorldSavedData { private static final Logger field_237240_k_ = LogManager.getLogger(); -@@ -44,8 +50,18 @@ +@@ -43,9 +53,21 @@ + private final Map field_204270_k = Maps.newHashMap(); public final Map field_76203_h = Maps.newLinkedHashMap(); private final Map field_212442_l = Maps.newHashMap(); ++ private org.bukkit.craftbukkit.v1_16_R3.map.RenderData vanillaRender = new org.bukkit.craftbukkit.v1_16_R3.map.RenderData(); // Paper + // CraftBukkit start + public final CraftMapView mapView; @@ -39,16 +53,37 @@ + // CraftBukkit start + mapView = new CraftMapView(this); + server = (CraftServer) org.bukkit.Bukkit.getServer(); ++ vanillaRender.buffer = field_76198_e; + // CraftBukkit end } public void func_237241_a_(int p_237241_1_, int p_237241_2_, int p_237241_3_, boolean p_237241_4_, boolean p_237241_5_, RegistryKey p_237241_6_) { -@@ -66,8 +82,25 @@ +@@ -66,8 +88,45 @@ } public void func_76184_a(CompoundNBT p_76184_1_) { - this.field_76200_c = DimensionType.func_236025_a_(new Dynamic<>(NBTDynamicOps.field_210820_a, p_76184_1_.func_74781_a("dimension"))).resultOrPartial(field_237240_k_::error).orElseThrow(() -> { - return new IllegalArgumentException("Invalid map dimension: " + p_76184_1_.func_74781_a("dimension")); ++ // Paper start - fix "Not a string" spam ++ INBT dimension = p_76184_1_.func_74781_a("dimension"); ++ if (dimension instanceof NumberNBT && ((NumberNBT)dimension).func_150287_d() >= 10) { ++ final long least = p_76184_1_.func_74763_f("UUIDLeast"); ++ final long most = p_76184_1_.func_74763_f("UUIDMost"); ++ if (least != 0L && most != 0L) { ++ this.uniqueId = new UUID(most, least); ++ final CraftWorld world = (CraftWorld)this.server.getWorld(this.uniqueId); ++ if (world != null) { ++ dimension = StringNBT.func_229705_a_("minecaft:" + world.getName().toLowerCase(Locale.ENGLISH)); ++ } ++ else { ++ dimension = StringNBT.func_229705_a_("bukkit:_invalidworld_"); ++ } ++ } ++ else { ++ dimension = StringNBT.func_229705_a_("bukkit:_invalidworld_"); ++ } ++ } ++ // Paper end - fix "Not a string" spam + // CraftBukkit start + DataResult> dataresult = DimensionType.func_236025_a_(new Dynamic(NBTDynamicOps.field_210820_a, p_76184_1_.func_74781_a("dimension"))); + this.field_76200_c = (RegistryKey) dataresult.resultOrPartial(field_237240_k_::error).orElseGet(() -> { @@ -71,7 +106,15 @@ }); this.field_76201_a = p_76184_1_.func_74762_e("xCenter"); this.field_76199_b = p_76184_1_.func_74762_e("zCenter"); -@@ -102,6 +135,27 @@ +@@ -87,6 +146,7 @@ + this.field_204270_k.put(mapbanner.func_204299_f(), mapbanner); + this.func_191095_a(mapbanner.func_204305_c(), (IWorld)null, mapbanner.func_204299_f(), (double)mapbanner.func_204304_a().func_177958_n(), (double)mapbanner.func_204304_a().func_177952_p(), 180.0D, mapbanner.func_204302_d()); + } ++ this.vanillaRender.buffer = field_76198_e; // Paper + + ListNBT listnbt1 = p_76184_1_.func_150295_c("frames", 10); + +@@ -102,6 +162,27 @@ ResourceLocation.field_240908_a_.encodeStart(NBTDynamicOps.field_210820_a, this.field_76200_c.func_240901_a_()).resultOrPartial(field_237240_k_::error).ifPresent((p_237242_1_) -> { p_189551_1_.func_218657_a("dimension", p_237242_1_); }); @@ -99,13 +142,48 @@ p_189551_1_.func_74768_a("xCenter", this.field_76201_a); p_189551_1_.func_74768_a("zCenter", this.field_76199_b); p_189551_1_.func_74774_a("scale", this.field_76197_d); -@@ -363,12 +417,22 @@ +@@ -136,6 +217,7 @@ + this.func_76185_a(); + } + ++ public void updateSeenPlayers(PlayerEntity entityhuman, ItemStack itemstack) { this.func_76191_a(entityhuman, itemstack); } // Paper - OBFHELPER + public void func_76191_a(PlayerEntity p_76191_1_, ItemStack p_76191_2_) { + if (!this.field_76202_j.containsKey(p_76191_1_)) { + MapData.MapInfo mapdata$mapinfo = new MapData.MapInfo(p_76191_1_); +@@ -348,6 +430,22 @@ + } + + public class MapInfo { ++ ++ // Paper start ++ private void addSeenPlayers(java.util.Collection icons) { ++ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.field_76211_a.getBukkitEntity(); ++ MapData.this.field_76203_h.forEach((name, mapIcon) -> { ++ // If this cursor is for a player check visibility with vanish system ++ org.bukkit.entity.Player other = org.bukkit.Bukkit.getPlayerExact(name); // Spigot ++ if (other == null || player.canSee(other)) { ++ icons.add(mapIcon); ++ } ++ }); ++ } ++ private boolean shouldUseVanillaMap() { ++ return mapView.getRenderers().size() == 1 && mapView.getRenderers().get(0).getClass() == org.bukkit.craftbukkit.v1_16_R3.map.CraftMapRenderer.class; ++ } ++ // Paper end + public final PlayerEntity field_76211_a; + private boolean field_176105_d = true; + private int field_176106_e; +@@ -363,12 +461,26 @@ @Nullable public IPacket func_176101_a(ItemStack p_176101_1_) { + // CraftBukkit start -+ org.bukkit.craftbukkit.v1_16_R3.map.RenderData render = MapData.this.mapView.render((org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) this.field_76211_a.getBukkitEntity()); // CraftBukkit ++ if (!this.field_176105_d && this.field_176109_i % 5 != 0) { this.field_176109_i++; return null; } // Paper - this won't end up sending, so don't render it! ++ boolean vanillaMaps = shouldUseVanillaMap(); // Paper ++ org.bukkit.craftbukkit.v1_16_R3.map.RenderData render = !vanillaMaps ? MapData.this.mapView.render((org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) this.field_76211_a.getBukkitEntity()) : MapData.this.vanillaRender; // CraftBukkit // Paper ++ + java.util.Collection icons = new java.util.ArrayList(); ++ if (vanillaMaps) addSeenPlayers(icons); // Paper + for ( org.bukkit.map.MapCursor cursor : render.cursors) { + if (cursor.isVisible()) { + icons.add(new MapDecoration(MapDecoration.Type.func_191159_a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); diff --git a/patches/minecraft/net/minecraft/world/storage/PlayerData.java.patch b/patches/minecraft/net/minecraft/world/storage/PlayerData.java.patch index 63fd8ad217..b8f07f6908 100644 --- a/patches/minecraft/net/minecraft/world/storage/PlayerData.java.patch +++ b/patches/minecraft/net/minecraft/world/storage/PlayerData.java.patch @@ -106,7 +106,7 @@ return astring; } + -+ public File getPlayerDir() { ++ public File getPlayerDataFolder() { + return field_237333_c_; + } } diff --git a/src/main/java/co/aikar/util/Counter.java b/src/main/java/co/aikar/util/Counter.java new file mode 100644 index 0000000000..68d4d0fb54 --- /dev/null +++ b/src/main/java/co/aikar/util/Counter.java @@ -0,0 +1,34 @@ +package co.aikar.util; + +import com.google.common.collect.ForwardingMap; +import java.util.HashMap; +import java.util.Map; + +public class Counter extends ForwardingMap { + private final Map counts = new HashMap<>(); + + public long decrement(T key) { + return increment(key, -1); + } + public long increment(T key) { + return increment(key, 1); + } + public long decrement(T key, long amount) { + return decrement(key, -amount); + } + public long increment(T key, long amount) { + Long count = this.getCount(key); + count += amount; + this.counts.put(key, count); + return count; + } + + public long getCount(T key) { + return this.counts.getOrDefault(key, 0L); + } + + @Override + protected Map delegate() { + return this.counts; + } +} diff --git a/src/main/java/co/aikar/util/JSONUtil.java b/src/main/java/co/aikar/util/JSONUtil.java new file mode 100644 index 0000000000..8bf6553e65 --- /dev/null +++ b/src/main/java/co/aikar/util/JSONUtil.java @@ -0,0 +1,125 @@ +package co.aikar.util; + +import com.google.common.base.Function; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * Provides Utility methods that assist with generating JSON Objects + */ +@SuppressWarnings({"rawtypes", "SuppressionAnnotation"}) +public final class JSONUtil { + private JSONUtil() {} + + /** + * Creates a key/value "JSONPair" object + * + * @param key Key to use + * @param obj Value to use + * @return JSONPair + */ + public static JSONPair pair(String key, Object obj) { + return new JSONPair(key, obj); + } + + public static JSONPair pair(long key, Object obj) { + return new JSONPair(String.valueOf(key), obj); + } + + /** + * Creates a new JSON object from multiple JSONPair key/value pairs + * + * @param data JSONPairs + * @return Map + */ + public static Map createObject(JSONPair... data) { + return appendObjectData(new LinkedHashMap(), data); + } + + /** + * This appends multiple key/value Obj pairs into a JSON Object + * + * @param parent Map to be appended to + * @param data Data to append + * @return Map + */ + public static Map appendObjectData(Map parent, JSONPair... data) { + for (JSONPair JSONPair : data) { + parent.put(JSONPair.key, JSONPair.val); + } + return parent; + } + + /** + * This builds a JSON array from a set of data + * + * @param data Data to build JSON array from + * @return List + */ + public static List toArray(Object... data) { + return Lists.newArrayList(data); + } + + /** + * These help build a single JSON array using a mapper function + * + * @param collection Collection to apply to + * @param mapper Mapper to apply + * @param Element Type + * @return List + */ + public static List toArrayMapper(E[] collection, Function mapper) { + return toArrayMapper(Lists.newArrayList(collection), mapper); + } + + public static List toArrayMapper(Iterable collection, Function mapper) { + List array = Lists.newArrayList(); + for (E e : collection) { + Object object = mapper.apply(e); + if (object != null) { + array.add(object); + } + } + return array; + } + + /** + * These help build a single JSON Object from a collection, using a mapper function + * + * @param collection Collection to apply to + * @param mapper Mapper to apply + * @param Element Type + * @return Map + */ + public static Map toObjectMapper(E[] collection, Function mapper) { + return toObjectMapper(Lists.newArrayList(collection), mapper); + } + + public static Map toObjectMapper(Iterable collection, Function mapper) { + Map object = Maps.newLinkedHashMap(); + for (E e : collection) { + JSONPair JSONPair = mapper.apply(e); + if (JSONPair != null) { + object.put(JSONPair.key, JSONPair.val); + } + } + return object; + } + + /** + * Simply stores a key and a value, used internally by many methods below. + */ + @SuppressWarnings("PublicInnerClass") + public static class JSONPair { + final String key; + final Object val; + + JSONPair(String key, Object val) { + this.key = key; + this.val = val; + } + } +} diff --git a/src/main/java/co/aikar/util/LoadingIntMap.java b/src/main/java/co/aikar/util/LoadingIntMap.java new file mode 100644 index 0000000000..24eae4bead --- /dev/null +++ b/src/main/java/co/aikar/util/LoadingIntMap.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015. Starlis LLC / dba Empire Minecraft + * + * This source code is proprietary software and must not be redistributed without Starlis LLC's approval + * + */ +package co.aikar.util; + + +import com.google.common.base.Function; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + +/** + * Allows you to pass a Loader function that when a key is accessed that doesn't exist, + * automatically loads the entry into the map by calling the loader Function. + * + * .get() Will only return null if the Loader can return null. + * + * You may pass any backing Map to use. + * + * This class is not thread safe and should be wrapped with Collections.synchronizedMap on the OUTSIDE of the LoadingMap if needed. + * + * Do not wrap the backing map with Collections.synchronizedMap. + * + * @param Value + */ +public class LoadingIntMap extends Int2ObjectOpenHashMap { + private final Function loader; + + public LoadingIntMap(Function loader) { + super(); + this.loader = loader; + } + + public LoadingIntMap(int expectedSize, Function loader) { + super(expectedSize); + this.loader = loader; + } + + public LoadingIntMap(int expectedSize, float loadFactor, Function loader) { + super(expectedSize, loadFactor); + this.loader = loader; + } + + + @Override + public V get(int key) { + V res = super.get(key); + if (res == null) { + res = loader.apply(key); + if (res != null) { + put(key, res); + } + } + return res; + } + + /** + * Due to java stuff, you will need to cast it to (Function) for some cases + * + * @param Type + */ + public abstract static class Feeder implements Function { + @Override + public T apply(Object input) { + return apply(); + } + + public abstract T apply(); + } +} diff --git a/src/main/java/co/aikar/util/LoadingMap.java b/src/main/java/co/aikar/util/LoadingMap.java new file mode 100644 index 0000000000..e0b55cc731 --- /dev/null +++ b/src/main/java/co/aikar/util/LoadingMap.java @@ -0,0 +1,343 @@ +/* + * This file is licensed under the MIT License (MIT). + * + * Copyright (c) 2014 Daniel Ennis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package co.aikar.util; + +import java.lang.reflect.Constructor; +import java.util.AbstractMap; +import java.util.Collection; +import java.util.HashMap; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +/** + * Allows you to pass a Loader function that when a key is accessed that doesn't exists, + * automatically loads the entry into the map by calling the loader Function. + * + * .get() Will only return null if the Loader can return null. + * + * You may pass any backing Map to use. + * + * This class is not thread safe and should be wrapped with Collections.synchronizedMap on the OUTSIDE of the LoadingMap if needed. + * + * Do not wrap the backing map with Collections.synchronizedMap. + * + * @param Key + * @param Value + */ +public class LoadingMap extends AbstractMap { + private final Map backingMap; + private final Function loader; + + /** + * Initializes an auto loading map using specified loader and backing map + * @param backingMap Map to wrap + * @param loader Loader + */ + public LoadingMap(Map backingMap, Function loader) { + this.backingMap = backingMap; + this.loader = loader; + } + + /** + * Creates a new LoadingMap with the specified map and loader + * + * @param backingMap Actual map being used. + * @param loader Loader to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map + */ + public static Map of(Map backingMap, Function loader) { + return new LoadingMap<>(backingMap, loader); + } + + /** + * Creates a LoadingMap with an auto instantiating loader. + * + * Will auto construct class of of Value when not found + * + * Since this uses Reflection, It is more effecient to define your own static loader + * than using this helper, but if performance is not critical, this is easier. + * + * @param backingMap Actual map being used. + * @param keyClass Class used for the K generic + * @param valueClass Class used for the V generic + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map that auto instantiates on .get() + */ + public static Map newAutoMap(Map backingMap, final Class keyClass, + final Class valueClass) { + return new LoadingMap<>(backingMap, new AutoInstantiatingLoader<>(keyClass, valueClass)); + } + /** + * Creates a LoadingMap with an auto instantiating loader. + * + * Will auto construct class of of Value when not found + * + * Since this uses Reflection, It is more effecient to define your own static loader + * than using this helper, but if performance is not critical, this is easier. + * + * @param backingMap Actual map being used. + * @param valueClass Class used for the V generic + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map that auto instantiates on .get() + */ + public static Map newAutoMap(Map backingMap, + final Class valueClass) { + return newAutoMap(backingMap, null, valueClass); + } + + /** + * @see #newAutoMap + * + * new Auto initializing map using a HashMap. + * + * @param keyClass Class used for the K generic + * @param valueClass Class used for the V generic + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map that auto instantiates on .get() + */ + public static Map newHashAutoMap(final Class keyClass, final Class valueClass) { + return newAutoMap(new HashMap<>(), keyClass, valueClass); + } + + /** + * @see #newAutoMap + * + * new Auto initializing map using a HashMap. + * + * @param valueClass Class used for the V generic + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map that auto instantiates on .get() + */ + public static Map newHashAutoMap(final Class valueClass) { + return newHashAutoMap(null, valueClass); + } + + /** + * @see #newAutoMap + * + * new Auto initializing map using a HashMap. + * + * @param keyClass Class used for the K generic + * @param valueClass Class used for the V generic + * @param initialCapacity Initial capacity to use + * @param loadFactor Load factor to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map that auto instantiates on .get() + */ + public static Map newHashAutoMap(final Class keyClass, final Class valueClass, int initialCapacity, float loadFactor) { + return newAutoMap(new HashMap<>(initialCapacity, loadFactor), keyClass, valueClass); + } + + /** + * @see #newAutoMap + * + * new Auto initializing map using a HashMap. + * + * @param valueClass Class used for the V generic + * @param initialCapacity Initial capacity to use + * @param loadFactor Load factor to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map that auto instantiates on .get() + */ + public static Map newHashAutoMap(final Class valueClass, int initialCapacity, float loadFactor) { + return newHashAutoMap(null, valueClass, initialCapacity, loadFactor); + } + + /** + * Initializes an auto loading map using a HashMap + * + * @param loader Loader to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map + */ + public static Map newHashMap(Function loader) { + return new LoadingMap<>(new HashMap<>(), loader); + } + + /** + * Initializes an auto loading map using a HashMap + * + * @param loader Loader to use + * @param initialCapacity Initial capacity to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map + */ + public static Map newHashMap(Function loader, int initialCapacity) { + return new LoadingMap<>(new HashMap<>(initialCapacity), loader); + } + /** + * Initializes an auto loading map using a HashMap + * + * @param loader Loader to use + * @param initialCapacity Initial capacity to use + * @param loadFactor Load factor to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map + */ + public static Map newHashMap(Function loader, int initialCapacity, float loadFactor) { + return new LoadingMap<>(new HashMap<>(initialCapacity, loadFactor), loader); + } + + /** + * Initializes an auto loading map using an Identity HashMap + * + * @param loader Loader to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map + */ + public static Map newIdentityHashMap(Function loader) { + return new LoadingMap<>(new IdentityHashMap<>(), loader); + } + + /** + * Initializes an auto loading map using an Identity HashMap + * + * @param loader Loader to use + * @param initialCapacity Initial capacity to use + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map + */ + public static Map newIdentityHashMap(Function loader, int initialCapacity) { + return new LoadingMap<>(new IdentityHashMap<>(initialCapacity), loader); + } + + @Override + public int size() {return backingMap.size();} + + @Override + public boolean isEmpty() {return backingMap.isEmpty();} + + @Override + public boolean containsKey(Object key) {return backingMap.containsKey(key);} + + @Override + public boolean containsValue(Object value) {return backingMap.containsValue(value);} + + @Override + public V get(Object key) { + V v = backingMap.get(key); + if (v != null) { + return v; + } + return backingMap.computeIfAbsent((K) key, loader); + } + + public V put(K key, V value) {return backingMap.put(key, value);} + + @Override + public V remove(Object key) {return backingMap.remove(key);} + + public void putAll(Map m) {backingMap.putAll(m);} + + @Override + public void clear() {backingMap.clear();} + + @Override + public Set keySet() {return backingMap.keySet();} + + @Override + public Collection values() {return backingMap.values();} + + @Override + public boolean equals(Object o) {return backingMap.equals(o);} + + @Override + public int hashCode() {return backingMap.hashCode();} + + @Override + public Set> entrySet() { + return backingMap.entrySet(); + } + + public LoadingMap clone() { + return new LoadingMap<>(backingMap, loader); + } + + private static class AutoInstantiatingLoader implements Function { + final Constructor constructor; + private final Class valueClass; + + AutoInstantiatingLoader(Class keyClass, Class valueClass) { + try { + this.valueClass = valueClass; + if (keyClass != null) { + constructor = valueClass.getConstructor(keyClass); + } else { + constructor = null; + } + } catch (NoSuchMethodException e) { + throw new IllegalStateException( + valueClass.getName() + " does not have a constructor for " + (keyClass != null ? keyClass.getName() : null)); + } + } + + @Override + public V apply(K input) { + try { + return (constructor != null ? constructor.newInstance(input) : valueClass.newInstance()); + } catch (Exception e) { + throw new ExceptionInInitializerError(e); + } + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object object) { + return false; + } + } + + /** + * Due to java stuff, you will need to cast it to (Function) for some cases + * + * @param Type + */ + public abstract static class Feeder implements Function { + @Override + public T apply(Object input) { + return apply(); + } + + public abstract T apply(); + } +} diff --git a/src/main/java/co/aikar/util/MRUMapCache.java b/src/main/java/co/aikar/util/MRUMapCache.java new file mode 100644 index 0000000000..aef80abefc --- /dev/null +++ b/src/main/java/co/aikar/util/MRUMapCache.java @@ -0,0 +1,102 @@ +/* + * This file is licensed under the MIT License (MIT). + * + * Copyright (c) 2014 Daniel Ennis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package co.aikar.util; + +import java.util.AbstractMap; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +/** + * Implements a Most Recently Used cache in front of a backing map, to quickly access the last accessed result. + * + * @param Key Type of the Map + * @param Value Type of the Map + */ +public class MRUMapCache extends AbstractMap { + final Map backingMap; + Object cacheKey; + V cacheValue; + public MRUMapCache(final Map backingMap) { + this.backingMap = backingMap; + } + + public int size() {return backingMap.size();} + + public boolean isEmpty() {return backingMap.isEmpty();} + + public boolean containsKey(Object key) { + return key != null && key.equals(cacheKey) || backingMap.containsKey(key); + } + + public boolean containsValue(Object value) { + return value != null && value == cacheValue || backingMap.containsValue(value); + } + + public V get(Object key) { + if (cacheKey != null && cacheKey.equals(key)) { + return cacheValue; + } + cacheKey = key; + return cacheValue = backingMap.get(key); + } + + public V put(K key, V value) { + cacheKey = key; + return cacheValue = backingMap.put(key, value); + } + + public V remove(Object key) { + if (key != null && key.equals(cacheKey)) { + cacheKey = null; + } + return backingMap.remove(key); + } + + public void putAll(Map m) {backingMap.putAll(m);} + + public void clear() { + cacheKey = null; + cacheValue = null; + backingMap.clear(); + } + + public Set keySet() {return backingMap.keySet();} + + public Collection values() {return backingMap.values();} + + public Set> entrySet() {return backingMap.entrySet();} + + /** + * Wraps the specified map with a most recently used cache + * + * @param map Map to be wrapped + * @param Key Type of the Map + * @param Value Type of the Map + * @return Map + */ + public static Map of(Map map) { + return new MRUMapCache(map); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftOfflinePlayer.java index df3bc38746..d3a806b043 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftOfflinePlayer.java @@ -198,7 +198,7 @@ private CompoundNBT getBukkitData() { } private File getDataFile() { - return new File(storage.getPlayerDir(), getUniqueId() + ".dat"); + return new File(storage.getPlayerDataFolder(), getUniqueId() + ".dat"); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java index b1463ff140..e008f39465 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftServer.java @@ -1600,7 +1600,7 @@ public File getWorldContainer() { @Override public OfflinePlayer[] getOfflinePlayers() { PlayerData storage = console.playerDataManager; - String[] files = storage.getPlayerDir().list(new DatFileFilter()); + String[] files = storage.getPlayerDataFolder().list(new DatFileFilter()); Set players = new HashSet(); for (String file : files) { @@ -1706,7 +1706,7 @@ public int getAmbientSpawnLimit() { @Override public boolean isPrimaryThread() { - return Thread.currentThread().equals(console.serverThread) || console.hasStopped() || !org.spigotmc.AsyncCatcher.enabled; // All bets are off if we have shut down (e.g. due to watchdog) + return Thread.currentThread().equals(console.serverThread); // Paper - Fix issues with detecting main thread properlyog) } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftWorld.java index ec164884b2..0ae6dc964e 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/CraftWorld.java @@ -1716,7 +1716,12 @@ public net.minecraft.entity.Entity createEntity(Location location, Class NMS + if (stack instanceof CraftItemStack) stack.setAmount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe, but don't nuke bukkit stacks of manually added items } return event; diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/map/RenderData.java index 893f2f8080..6c965e831a 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/map/RenderData.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/map/RenderData.java @@ -5,7 +5,7 @@ public class RenderData { - public final byte[] buffer; + public byte[] buffer; // Paper public final ArrayList cursors; public RenderData() { diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scheduler/CraftScheduler.java index b5008c908e..906668b3b2 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scheduler/CraftScheduler.java @@ -159,7 +159,7 @@ public void runTaskLaterAsynchronously(Plugin plugin, Consumer task, @Override public void runTaskTimerAsynchronously(Plugin plugin, Consumer task, long delay, long period) throws IllegalArgumentException { - runTaskTimerAsynchronously(plugin, (Object) task, delay, CraftTask.NO_REPEATING); + runTaskTimerAsynchronously(plugin, (Object) task, delay, period); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scoreboard/CraftTeam.java index 54e8ddd3b7..acbb0cd7de 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/scoreboard/CraftTeam.java @@ -202,7 +202,7 @@ public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, @Override public boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException { - Validate.notNull("Entry cannot be null"); + Validate.notNull(entry,"Entry cannot be null"); CraftScoreboard scoreboard = checkState(); diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/BlockStateListPopulator.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/BlockStateListPopulator.java index d1b774f17a..93b4f77414 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/BlockStateListPopulator.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/BlockStateListPopulator.java @@ -37,6 +37,11 @@ public FluidState getFluidState(BlockPos bp) { @Override public boolean setBlockState(BlockPos pos, BlockState newState, int flags) { + // Paper start + // When a LinkedHashMap entry is overwritten, it keeps its old position. Removing the entry here before adding + // a new one ensures that the nether portal blocks are placed last and are not destroyed by physics. + list.remove(pos); + // Paper end CraftBlockState state = CraftBlockState.getBlockState(world, pos, flags); state.setData(newState); list.put(pos, state); diff --git a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/CraftNBTTagConfigSerializer.java b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/CraftNBTTagConfigSerializer.java index e308a59052..57477c9caf 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/CraftNBTTagConfigSerializer.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_16_R3/util/CraftNBTTagConfigSerializer.java @@ -19,7 +19,7 @@ public class CraftNBTTagConfigSerializer { private static final Pattern ARRAY = Pattern.compile("^\\[.*]"); - private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)?i", Pattern.CASE_INSENSITIVE); + private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)i", Pattern.CASE_INSENSITIVE); // Paper - fix regex private static final Pattern DOUBLE = Pattern.compile("[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?d", Pattern.CASE_INSENSITIVE); private static final JsonToNBT MOJANGSON_PARSER = new JsonToNBT(new StringReader(""));