From 9a886d561cb70f94b24cd361cfaaa9dafbb58fc7 Mon Sep 17 00:00:00 2001 From: Mgazul Date: Fri, 22 Mar 2024 16:42:10 +0800 Subject: [PATCH] Fixed #2982 --- build.gradle | 2 +- .../world/server/ServerWorld.java.patch | 197 ++++++++++++------ 2 files changed, 140 insertions(+), 59 deletions(-) diff --git a/build.gradle b/build.gradle index 31c27ad8ba..517352c633 100644 --- a/build.gradle +++ b/build.gradle @@ -827,7 +827,7 @@ project(':mohist') { } tasks.withType(JavaCompile) { - options.compilerArgs << '-Xlint:-removal' + options.warnings = false } } diff --git a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch b/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch index 1bc6e7b2e3..56a01c0bce 100644 --- a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch +++ b/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/server/ServerWorld.java +++ b/net/minecraft/world/server/ServerWorld.java -@@ -1,25 +_,16 @@ +@@ -1,25 +_,19 @@ package net.minecraft.world.server; -import com.google.common.annotations.VisibleForTesting; @@ -19,6 +19,9 @@ -import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; +import com.mohistmc.forge.MohistDerivedWorldInfo; + ++import com.mohistmc.util.i18n.i18n; ++import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; ++import it.unimi.dsi.fastutil.objects.Object2IntMap; +import java.io.File; import java.io.IOException; import java.io.Writer; @@ -31,7 +34,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -@@ -33,8 +_,41 @@ +@@ -33,8 +_,65 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -40,16 +43,40 @@ import javax.annotation.Nullable; + +import com.mohistmc.util.Level2LevelStem; ++import net.minecraft.world.Explosion.Mode; ++import net.minecraft.world.biome.Biome.RainType; ++import net.minecraft.world.gen.Heightmap.Type; ++import net.minecraft.world.spawner.WorldEntitySpawner.EntityDensityManager; +import net.minecraft.world.storage.DerivedWorldInfo; ++import net.minecraft.world.storage.MapData.MapInfo; ++import net.minecraft.world.storage.SaveFormat.LevelSave; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.common.extensions.IForgeWorldServer; ++import net.minecraftforge.common.util.WorldCapabilityData; ++import net.minecraftforge.common.world.ForgeChunkManager; ++import net.minecraftforge.entity.PartEntity; ++import net.minecraftforge.event.ForgeEventFactory; ++import net.minecraftforge.event.entity.EntityJoinWorldEvent; ++import net.minecraftforge.event.entity.EntityLeaveWorldEvent; ++import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; ++import net.minecraftforge.event.world.WorldEvent.Save; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory; ++import org.bukkit.craftbukkit.v1_16_R3.generator.CustomChunkGenerator; ++import org.bukkit.craftbukkit.v1_16_R3.util.BlockStateListPopulator; +import org.bukkit.craftbukkit.v1_16_R3.util.WorldUUID; ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.entity.LightningStrike; +import org.bukkit.event.entity.CreatureSpawnEvent; ++import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.server.MapInitializeEvent; +import org.bukkit.event.weather.LightningStrikeEvent; ++import org.bukkit.event.weather.LightningStrikeEvent.Cause; ++import org.bukkit.event.world.PortalCreateEvent; ++import org.bukkit.event.world.PortalCreateEvent.CreateReason; +import org.bukkit.event.world.TimeSkipEvent; + +import com.google.common.annotations.VisibleForTesting; @@ -93,7 +120,7 @@ import net.minecraft.item.crafting.RecipeManager; import net.minecraft.network.DebugPacketSender; import net.minecraft.network.IPacket; -@@ -138,18 +_,18 @@ +@@ -138,18 +_,21 @@ import net.minecraft.world.storage.MapData; import net.minecraft.world.storage.MapIdTracker; import net.minecraft.world.storage.SaveFormat; @@ -102,10 +129,13 @@ import net.minecraftforge.api.distmarker.OnlyIn; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; ++import org.bukkit.event.world.TimeSkipEvent.SkipReason; ++import org.spigotmc.ActivationRange; +import org.spigotmc.AsyncCatcher; ++import org.spigotmc.SpigotWorldConfig; -public class ServerWorld extends World implements ISeedReader { -+public class ServerWorld extends World implements ISeedReader, net.minecraftforge.common.extensions.IForgeWorldServer { ++public class ServerWorld extends World implements ISeedReader, IForgeWorldServer { public static final BlockPos field_241108_a_ = new BlockPos(100, 50, 0); private static final Logger field_147491_a = LogManager.getLogger(); public final Int2ObjectMap field_217498_x = new Int2ObjectLinkedOpenHashMap<>(); @@ -134,14 +164,16 @@ private final DragonFightManager field_241105_O_; private final StructureManager field_241106_P_; private final boolean field_241107_Q_; -+ private net.minecraftforge.common.util.WorldCapabilityData capabilityData; -+ private final it.unimi.dsi.fastutil.ints.Int2ObjectMap> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>(); +- +- public ServerWorld(MinecraftServer p_i241885_1_, Executor p_i241885_2_, SaveFormat.LevelSave p_i241885_3_, IServerWorldInfo p_i241885_4_, RegistryKey p_i241885_5_, DimensionType p_i241885_6_, IChunkStatusListener p_i241885_7_, ChunkGenerator p_i241885_8_, boolean p_i241885_9_, long p_i241885_10_, List p_i241885_12_, boolean p_i241885_13_) { ++ private WorldCapabilityData capabilityData; ++ private final Int2ObjectMap> partEntities = new Int2ObjectOpenHashMap<>(); + + // CraftBukkit start + public ServerWorldInfo worldDataServer; -+ public final SaveFormat.LevelSave convertable; ++ public final LevelSave convertable; + public final UUID uuid; -+ public final String name; ++ public String name; + + public boolean dummyFreshEntitySpawn = false; // Mohist - Fix Pehkui Startup (#1324) + @@ -159,15 +191,15 @@ + + private final boolean ignoreEmptyTimeThis; + { -+ this.ignoreEmptyTimeThis = IGNORE_EMPTY_TIME_LIST.contains("all_worlds") || IGNORE_EMPTY_TIME_LIST.contains(this.worldDataServer.func_76065_j()); ++ this.ignoreEmptyTimeThis = IGNORE_EMPTY_TIME_LIST.contains("all_worlds") || (name != null && IGNORE_EMPTY_TIME_LIST.contains(name)); + } + // Mohist end + + public Chunk getChunkIfLoaded(int x, int z) { + return this.field_241102_C_.func_217205_a(x, z, false); + } - - public ServerWorld(MinecraftServer p_i241885_1_, Executor p_i241885_2_, SaveFormat.LevelSave p_i241885_3_, IServerWorldInfo p_i241885_4_, RegistryKey p_i241885_5_, DimensionType p_i241885_6_, IChunkStatusListener p_i241885_7_, ChunkGenerator p_i241885_8_, boolean p_i241885_9_, long p_i241885_10_, List p_i241885_12_, boolean p_i241885_13_) { ++ ++ public ServerWorld(MinecraftServer p_i241885_1_, Executor p_i241885_2_, LevelSave p_i241885_3_, IServerWorldInfo p_i241885_4_, RegistryKey p_i241885_5_, DimensionType p_i241885_6_, IChunkStatusListener p_i241885_7_, ChunkGenerator p_i241885_8_, boolean p_i241885_9_, long p_i241885_10_, List p_i241885_12_, boolean p_i241885_13_) { super(p_i241885_4_, p_i241885_5_, p_i241885_6_, p_i241885_1_::func_213185_aS, false, p_i241885_9_, p_i241885_10_); + this.pvpMode = p_i241885_1_.func_71219_W(); + convertable = p_i241885_3_; @@ -182,12 +214,12 @@ + } + + if (generator != null) { -+ p_i241885_8_ = new org.bukkit.craftbukkit.v1_16_R3.generator.CustomChunkGenerator(this, p_i241885_8_, generator); ++ p_i241885_8_ = new CustomChunkGenerator(this, p_i241885_8_, generator); + } else { + generator = getCBServer().getGenerator(p_i241885_4_.func_76065_j()); + } + worldDataServer.world = this; -+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(name); // Spigot ++ this.spigotConfig = new SpigotWorldConfig(name); // Spigot + // CraftBukkit end this.field_241107_Q_ = p_i241885_13_; this.field_73061_a = p_i241885_1_; @@ -282,7 +314,7 @@ - this.field_73068_P = false; + // CraftBukkit start + long l = this.func_72820_D() + 24000L; -+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, net.minecraftforge.event.ForgeEventFactory.onSleepFinished(this, l - l % 24000L, this.func_72820_D()) - this.func_72820_D()); ++ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), SkipReason.NIGHT_SKIP, ForgeEventFactory.onSleepFinished(this, l - l % 24000L, this.func_72820_D()) - this.func_72820_D()); if (this.func_82736_K().func_223586_b(GameRules.field_223607_j)) { - long l = this.field_72986_A.func_76073_f() + 24000L; - this.func_241114_a_(l - l % 24000L); @@ -306,7 +338,7 @@ this.field_211159_Q = false; iprofiler.func_219895_b("entities"); - boolean flag3 = !this.field_217491_A.isEmpty() || !this.func_217469_z().isEmpty(); -+ boolean flag3 = !this.field_217491_A.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones ++ boolean flag3 = !this.field_217491_A.isEmpty() || ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones if (flag3) { this.func_82742_i(); } @@ -320,7 +352,7 @@ this.field_217492_a = true; ObjectIterator> objectiterator = this.field_217498_x.int2ObjectEntrySet().iterator(); -+ org.spigotmc.ActivationRange.activateEntities(this); // Spigot ++ ActivationRange.activateEntities(this); // Spigot label164: while(true) { Entity entity1; @@ -337,7 +369,7 @@ iprofiler.func_76320_a("tick"); - if (!entity1.field_70128_L && !(entity1 instanceof EnderDragonPartEntity)) { -+ if (!entity1.field_70128_L && !(entity1 instanceof net.minecraftforge.entity.PartEntity)) { ++ if (!entity1.field_70128_L && !(entity1 instanceof PartEntity)) { this.func_217390_a(this::func_217479_a, entity1); } @@ -350,26 +382,28 @@ } iprofiler.func_76319_b(); -@@ -459,14 +_,14 @@ +@@ -459,31 +_,34 @@ SkeletonHorseEntity skeletonhorseentity = EntityType.field_200742_ah.func_200721_a(this); 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()); - this.func_217376_c(skeletonhorseentity); + skeletonhorseentity.func_70107_b((double) blockpos.func_177958_n(), (double) blockpos.func_177956_o(), (double) blockpos.func_177952_p()); -+ this.addEntity(skeletonhorseentity, CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit ++ this.addEntity(skeletonhorseentity, SpawnReason.LIGHTNING); // CraftBukkit } LightningBoltEntity lightningboltentity = EntityType.field_200728_aG.func_200721_a(this); lightningboltentity.func_233576_c_(Vector3d.func_237492_c_(blockpos)); lightningboltentity.func_233623_a_(flag1); - this.func_217376_c(lightningboltentity); -+ this.strikeLightning(lightningboltentity, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit ++ this.strikeLightning(lightningboltentity, Cause.WEATHER); // CraftBukkit } } -@@ -475,12 +_,15 @@ - BlockPos blockpos2 = this.func_205770_a(Heightmap.Type.MOTION_BLOCKING, this.func_217383_a(i, 0, j, 15)); + iprofiler.func_219895_b("iceandsnow"); + if (this.field_73012_v.nextInt(16) == 0) { +- BlockPos blockpos2 = this.func_205770_a(Heightmap.Type.MOTION_BLOCKING, this.func_217383_a(i, 0, j, 15)); ++ BlockPos blockpos2 = this.func_205770_a(Type.MOTION_BLOCKING, this.func_217383_a(i, 0, j, 15)); BlockPos blockpos3 = blockpos2.func_177977_b(); Biome biome = this.func_226691_t_(blockpos2); - if (biome.func_201848_a(this, blockpos3)) { @@ -379,15 +413,28 @@ + if (biome.func_201848_a(this, blockpos3)) { + this.callEvent.set(true); + this.func_175656_a(blockpos3, Blocks.field_150432_aD.func_176223_P()); -+ org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory.handleBlockFormEvent(this, blockpos3, this.mohist$defaultBlockState, null); // CraftBukkit // Mohist ++ CraftEventFactory.handleBlockFormEvent(this, blockpos3, this.mohist$defaultBlockState, null); // CraftBukkit // Mohist + } if (flag && biome.func_201850_b(this, blockpos2)) { - this.func_175656_a(blockpos2, Blocks.field_150433_aE.func_176223_P()); -+ org.bukkit.craftbukkit.v1_16_R3.event.CraftEventFactory.handleBlockFormEvent(this, blockpos2, Blocks.field_150433_aE.func_176223_P(), null); // CraftBukkit ++ CraftEventFactory.handleBlockFormEvent(this, blockpos2, Blocks.field_150433_aE.func_176223_P(), null); // CraftBukkit } - if (flag && this.func_226691_t_(blockpos3).func_201851_b() == Biome.RainType.RAIN) { +- if (flag && this.func_226691_t_(blockpos3).func_201851_b() == Biome.RainType.RAIN) { ++ if (flag && this.func_226691_t_(blockpos3).func_201851_b() == RainType.RAIN) { + this.func_180495_p(blockpos3).func_177230_c().func_176224_k(this, blockpos3); + } + } +@@ -517,7 +_,7 @@ + } + + protected BlockPos func_175736_a(BlockPos p_175736_1_) { +- BlockPos blockpos = this.func_205770_a(Heightmap.Type.MOTION_BLOCKING, p_175736_1_); ++ BlockPos blockpos = this.func_205770_a(Type.MOTION_BLOCKING, p_175736_1_); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockpos, new BlockPos(blockpos.func_177958_n(), this.func_217301_I(), blockpos.func_177952_p()))).func_186662_g(3.0D); + List list = this.func_175647_a(LivingEntity.class, axisalignedbb, (p_241115_1_) -> { + return p_241115_1_ != null && p_241115_1_.func_70089_S() && this.func_226660_f_(p_241115_1_.func_233580_cy_()); @@ -543,8 +_,8 @@ int i = 0; int j = 0; @@ -483,7 +530,7 @@ if (!(p_217479_1_ instanceof PlayerEntity) && !this.func_72863_F().func_217204_a(p_217479_1_)) { this.func_217464_b(p_217479_1_); } else { -+ if (!org.spigotmc.ActivationRange.checkIfActive(p_217479_1_)) { ++ if (!ActivationRange.checkIfActive(p_217479_1_)) { + p_217479_1_.field_70173_aa++; + p_217479_1_.inactiveTick(); + return; @@ -537,7 +584,7 @@ if (!p_217464_1_.func_233577_ch_() && !this.func_217354_b(i, k)) { if (p_217464_1_.field_70175_ag) { - field_147491_a.warn("Entity {} left loaded chunk area", (Object)p_217464_1_); -+ field_147491_a.warn(com.mohistmc.util.i18n.i18n.get("serverworld.1", (Object) p_217464_1_)); ++ field_147491_a.warn(i18n.get("serverworld.1", (Object) p_217464_1_)); } p_217464_1_.field_70175_ag = false; @@ -545,7 +592,7 @@ p_217445_1_.func_200209_c(new TranslationTextComponent("menu.savingChunks")); } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Save(this)); ++ MinecraftForge.EVENT_BUS.post(new Save(this)); serverchunkprovider.func_217210_a(p_217445_2_); + } @@ -562,7 +609,7 @@ return list.isEmpty() ? null : list.get(this.field_73012_v.nextInt(list.size())); } -+ public CreatureSpawnEvent.SpawnReason pehkuiSpawnReason = CreatureSpawnEvent.SpawnReason.DEFAULT; // Mohist - Fix Pehkui Startup (#1324) ++ public SpawnReason pehkuiSpawnReason = SpawnReason.DEFAULT; // Mohist - Fix Pehkui Startup (#1324) + public boolean func_217376_c(Entity p_217376_1_) { - return this.func_72838_d(p_217376_1_); @@ -570,16 +617,16 @@ + return this.addEntity0(p_217376_1_, this.pehkuiSpawnReason); // Mohist - Fix Pehkui Startup (#1324) + } + -+ public boolean addEntity(Entity entityIn, CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addEntity(Entity entityIn, SpawnReason reason) { + return this.addEntity0(entityIn, reason); } public boolean func_217470_d(Entity p_217470_1_) { - return this.func_72838_d(p_217470_1_); -+ return this.addEntitySerialized(p_217470_1_, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return this.addEntitySerialized(p_217470_1_, SpawnReason.DEFAULT); + } + -+ public boolean addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addEntitySerialized(Entity entity, SpawnReason reason) { + return this.addEntity0(entity, reason); + // CraftBukkit end } @@ -589,7 +636,7 @@ } private void func_217448_f(ServerPlayerEntity p_217448_1_) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_217448_1_, this))) return; ++ if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_217448_1_, this))) return; 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()); @@ -602,10 +649,10 @@ private boolean func_72838_d(Entity p_72838_1_) { - if (p_72838_1_.field_70128_L) { - field_147491_a.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.func_200718_a(p_72838_1_.func_200600_R())); -+ return addEntity0(p_72838_1_, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return addEntity0(p_72838_1_, SpawnReason.DEFAULT); + } + -+ private boolean addEntity0(Entity entityIn, CreatureSpawnEvent.SpawnReason spawnReason) { ++ private boolean addEntity0(Entity entityIn, SpawnReason spawnReason) { + if (entityIn.field_70128_L) { return false; - } else if (this.func_217478_l(p_72838_1_)) { @@ -613,7 +660,7 @@ return false; } else { - IChunk ichunk = this.func_217353_a(MathHelper.func_76128_c(p_72838_1_.func_226277_ct_() / 16.0D), MathHelper.func_76128_c(p_72838_1_.func_226281_cx_() / 16.0D), ChunkStatus.field_222617_m, p_72838_1_.field_98038_p); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entityIn, this))) ++ if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entityIn, this))) + return false; + if (!CraftEventFactory.doEntityAddEventCalling(this, entityIn, spawnReason)) return false; + IChunk ichunk = this.func_217353_a(MathHelper.func_76128_c(entityIn.func_226277_ct_() / 16.0D), MathHelper.func_76128_c(entityIn.func_226281_cx_() / 16.0D), ChunkStatus.field_222617_m, entityIn.field_98038_p); @@ -631,7 +678,7 @@ if (this.func_217478_l(p_217440_1_)) { return false; } else { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_217440_1_, this))) return false; ++ if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_217440_1_, this))) return false; this.func_217465_m(p_217440_1_); return true; } @@ -649,10 +696,10 @@ public boolean func_242106_g(Entity p_242106_1_) { - if (p_242106_1_.func_226276_cg_().anyMatch(this::func_217478_l)) { + // CraftBukkit start -+ return this.addAllEntitiesSafely(p_242106_1_, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ return this.addAllEntitiesSafely(p_242106_1_, SpawnReason.DEFAULT); + } + -+ public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addAllEntitiesSafely(Entity entity, SpawnReason reason) { + // CraftBukkit end + if (entity.func_226276_cg_().anyMatch(this::func_217478_l)) { return false; @@ -667,7 +714,7 @@ + // Spigot Start + for (TileEntity tileentity : p_217466_1_.func_177434_r().values()) { + if (tileentity instanceof IInventory) { -+ for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(CraftCustomInventory.getViewers((IInventory) tileentity))) { ++ for (HumanEntity h : Lists.newArrayList(CraftCustomInventory.getViewers((IInventory) tileentity))) { + h.closeInventory(); + } + } @@ -714,7 +761,7 @@ + if (o instanceof MapData) { + MapData map = (MapData) o; + map.field_76196_g.remove((PlayerEntity) p_217484_1_); -+ for (Iterator iter = map.field_76196_g.iterator(); iter.hasNext(); ) { ++ for (Iterator iter = map.field_76196_g.iterator(); iter.hasNext(); ) { + if (iter.next().field_76211_a == p_217484_1_) { + map.field_76203_h.remove(p_217484_1_.func_200200_C_().getString()); + iter.remove(); @@ -726,7 +773,7 @@ + } + // Spigot end + if (p_217484_1_.isMultipartEntity()) { -+ for(net.minecraftforge.entity.PartEntity enderdragonpartentity : p_217484_1_.getParts()) { ++ for(PartEntity enderdragonpartentity : p_217484_1_.getParts()) { + enderdragonpartentity.remove(keepData); + this.partEntities.remove(enderdragonpartentity.func_145782_y()); } @@ -757,7 +804,7 @@ + p_217484_1_.onRemovedFromWorld(); + p_217484_1_.remove(keepData); + p_217484_1_.valid = false; // CraftBukkit -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_217484_1_, this)); ++ MinecraftForge.EVENT_BUS.post(new EntityLeaveWorldEvent(p_217484_1_, this)); } private void func_217465_m(Entity p_217465_1_) { @@ -774,7 +821,7 @@ - if (p_217465_1_ instanceof EnderDragonEntity) { - for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)p_217465_1_).func_213404_dT()) { + if (p_217465_1_.isMultipartEntity()) { -+ for(net.minecraftforge.entity.PartEntity enderdragonpartentity : p_217465_1_.getParts()) { ++ for(PartEntity enderdragonpartentity : p_217465_1_.getParts()) { this.field_217498_x.put(enderdragonpartentity.func_145782_y(), enderdragonpartentity); + this.partEntities.put(enderdragonpartentity.func_145782_y(), enderdragonpartentity); } @@ -839,13 +886,13 @@ + + // CraftBukkit start + public boolean strikeLightning(Entity entitylightning) { -+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN); ++ return this.strikeLightning(entitylightning, Cause.UNKNOWN); + } + -+ public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) { ++ public boolean strikeLightning(Entity entitylightning, Cause cause) { + // Mohist start - Compat for Forge,ignore modded weather effect -+ if (!AsyncCatcher.catchAsync() && entitylightning.getBukkitEntity() instanceof org.bukkit.entity.LightningStrike) { -+ LightningStrikeEvent lightning = CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); ++ if (!AsyncCatcher.catchAsync() && entitylightning.getBukkitEntity() instanceof LightningStrike) { ++ LightningStrikeEvent lightning = CraftEventFactory.callLightningStrikeEvent((LightningStrike) entitylightning.getBukkitEntity(), cause); + this.getCBServer().getPluginManager().callEvent(lightning); + if (lightning.isCancelled()) + { @@ -883,7 +930,7 @@ } 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_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_); ++ PlaySoundAtEntityEvent event = ForgeEventFactory.onPlaySoundAtEntity(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_); + if (event.isCanceled() || event.getSound() == null) return; + p_184148_8_ = event.getSound(); + p_184148_9_ = event.getCategory(); @@ -892,7 +939,7 @@ } public void func_217384_a(@Nullable PlayerEntity p_217384_1_, Entity p_217384_2_, SoundEvent p_217384_3_, SoundCategory p_217384_4_, float p_217384_5_, float p_217384_6_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_217384_1_, p_217384_3_, p_217384_4_, p_217384_5_, p_217384_6_); ++ PlaySoundAtEntityEvent event = ForgeEventFactory.onPlaySoundAtEntity(p_217384_1_, p_217384_3_, p_217384_4_, p_217384_5_, p_217384_6_); + if (event.isCanceled() || event.getSound() == null) return; + p_217384_3_ = event.getSound(); + p_217384_4_ = event.getCategory(); @@ -900,13 +947,16 @@ 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 +_,17 @@ +@@ -996,11 +_,19 @@ + return this.field_241102_C_; } - 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_) { +- 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_); - explosion.func_77278_a(); - explosion.func_77279_a(false); +- if (p_230546_12_ == Explosion.Mode.NONE) { ++ 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_, Mode p_230546_12_) { + // CraftBukkit start + Explosion explosion = super.func_230546_a_(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_); + if (explosion.wasCanceled) { @@ -918,9 +968,10 @@ + explosion.doExplosionB(false); + */ + // CraftBukkit end - TODO: Check if explosions are still properly implemented - if (p_230546_12_ == Explosion.Mode.NONE) { ++ if (p_230546_12_ == Mode.NONE) { explosion.func_180342_d(); } + @@ -1054,12 +_,19 @@ } @@ -967,6 +1018,27 @@ }, p_217406_1_); } +@@ -1154,7 +_,7 @@ + public BlockPos func_241135_u_() { + BlockPos blockpos = new BlockPos(this.field_72986_A.func_76079_c(), this.field_72986_A.func_76075_d(), this.field_72986_A.func_76074_e()); + if (!this.func_175723_af().func_177746_a(blockpos)) { +- blockpos = this.func_205770_a(Heightmap.Type.MOTION_BLOCKING, new BlockPos(this.func_175723_af().func_230316_a_(), 0.0D, this.func_175723_af().func_230317_b_())); ++ blockpos = this.func_205770_a(Type.MOTION_BLOCKING, new BlockPos(this.func_175723_af().func_230316_a_(), 0.0D, this.func_175723_af().func_230317_b_())); + } + + return blockpos; +@@ -1261,9 +_,9 @@ + + try (Writer writer = Files.newBufferedWriter(p_225322_1_.resolve("stats.txt"))) { + writer.write(String.format("spawning_chunks: %d\n", chunkmanager.func_219246_e().func_219358_b())); +- WorldEntitySpawner.EntityDensityManager worldentityspawner$entitydensitymanager = this.func_72863_F().func_241101_k_(); ++ EntityDensityManager worldentityspawner$entitydensitymanager = this.func_72863_F().func_241101_k_(); + if (worldentityspawner$entitydensitymanager != null) { +- for(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry entry : worldentityspawner$entitydensitymanager.func_234995_b_().object2IntEntrySet()) { ++ for(Object2IntMap.Entry entry : worldentityspawner$entitydensitymanager.func_234995_b_().object2IntEntrySet()) { + writer.write(String.format("spawn_count.%s: %d\n", entry.getKey().func_220363_a(), entry.getIntValue())); + } + } @@ -1333,6 +_,11 @@ public void func_230547_a_(BlockPos p_230547_1_, Block p_230547_2_) { @@ -993,6 +1065,15 @@ } @Nullable +@@ -1390,7 +_,7 @@ + object2intopenhashmap.addTo(resourcelocation, 1); + } + +- return object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry::getIntValue).reversed()).limit(5L).map((p_244523_0_) -> { ++ return object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(Object2IntMap.Entry::getIntValue).reversed()).limit(5L).map((p_244523_0_) -> { + return p_244523_0_.getKey() + ":" + p_244523_0_.getIntValue(); + }).collect(Collectors.joining(",")); + } catch (Exception exception) { @@ -1399,15 +_,45 @@ } @@ -1010,7 +1091,7 @@ - BlockPos.func_191531_b(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((p_244430_1_) -> { - p_241121_0_.func_175656_a(p_244430_1_, Blocks.field_150350_a.func_176223_P()); + // CraftBukkit start -+ org.bukkit.craftbukkit.v1_16_R3.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.v1_16_R3.util.BlockStateListPopulator(worldserver); ++ BlockStateListPopulator blockList = new BlockStateListPopulator(worldserver); + BlockPos.func_191531_b(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((p_241122_1_) -> { + blockList.func_180501_a(p_241122_1_, Blocks.field_150350_a.func_176223_P(), 3); }); @@ -1019,7 +1100,7 @@ + blockList.func_180501_a(p_241122_1_, Blocks.field_150343_Z.func_176223_P(), 3); }); + org.bukkit.World bworld = worldserver.getWorld(); -+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); ++ PortalCreateEvent portalEvent = new PortalCreateEvent((List) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), CreateReason.END_PLATFORM); + worldserver.getCBServer().getPluginManager().callEvent(portalEvent); + if (!portalEvent.isCancelled()) { + blockList.updateList(); @@ -1029,16 +1110,16 @@ + + protected void initCapabilities() { + this.gatherCapabilities(); -+ capabilityData = this.func_217481_x().func_215752_a(() -> new net.minecraftforge.common.util.WorldCapabilityData(getCapabilities()), net.minecraftforge.common.util.WorldCapabilityData.ID); ++ capabilityData = this.func_217481_x().func_215752_a(() -> new WorldCapabilityData(getCapabilities()), WorldCapabilityData.ID); + capabilityData.setCapabilities(getCapabilities()); + } + -+ public java.util.stream.Stream getEntities() { ++ public Stream getEntities() { + return field_217498_x.values().stream(); + } + + @Override -+ public java.util.Collection> getPartEntities() { ++ public Collection> getPartEntities() { + return this.partEntities.values(); } }