2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/WorldServer.java
+++ b/net/minecraft/server/WorldServer.java
2019-04-23 04:00:00 +02:00
@@ -31,6 +31,21 @@
2014-11-25 22:32:16 +01:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.util.logging.Level;
2019-04-23 04:00:00 +02:00
+import org.bukkit.Bukkit;
2014-11-25 22:32:16 +01:00
+
+import org.bukkit.WeatherType;
+import org.bukkit.block.BlockState;
2019-04-23 04:00:00 +02:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
2015-04-13 12:04:38 +02:00
+import org.bukkit.craftbukkit.util.HashTreeSet;
2014-11-25 22:32:16 +01:00
+
+import org.bukkit.event.block.BlockFormEvent;
2019-04-23 04:00:00 +02:00
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.server.MapInitializeEvent;
2014-11-25 22:32:16 +01:00
+import org.bukkit.event.weather.LightningStrikeEvent;
+// CraftBukkit end
+
2019-04-23 04:00:00 +02:00
public class WorldServer extends World {
2014-11-25 22:32:16 +01:00
2019-04-25 04:00:00 +02:00
private static final Logger LOGGER = LogManager.getLogger();
2019-04-23 04:00:00 +02:00
@@ -56,12 +71,31 @@
@Nullable
private final MobSpawnerTrader mobSpawnerTrader;
2014-11-25 22:32:16 +01:00
2019-04-23 04:00:00 +02:00
- public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener) {
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start
2018-08-26 04:00:00 +02:00
+ public final DimensionManager dimension;
2019-04-23 04:00:00 +02:00
+ private int tickPosition;
2014-11-25 22:32:16 +01:00
+
+ // Add env and gen to constructor
2019-04-23 04:00:00 +02:00
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
super(worlddata, dimensionmanager, (world, worldprovider) -> {
- return new ChunkProviderServer((WorldServer) world, worldnbtstorage.getDirectory(), worldnbtstorage.getDataFixer(), worldnbtstorage.f(), executor, worldprovider.getChunkGenerator(), minecraftserver.getPlayerList().getViewDistance(), minecraftserver.getPlayerList().getViewDistance() - 2, worldloadlistener, () -> {
+ // CraftBukkit start
+ ChunkGenerator<?> chunkGenerator;
+
+ if (gen != null) {
+ chunkGenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(world, world.getSeed(), gen);
+ } else {
+ chunkGenerator = worldprovider.getChunkGenerator();
+ }
+
+ return new ChunkProviderServer((WorldServer) world, worldnbtstorage.getDirectory(), worldnbtstorage.getDataFixer(), worldnbtstorage.f(), executor, chunkGenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.getPlayerList().getViewDistance() - 2, worldloadlistener, () -> {
return minecraftserver.getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData();
});
- }, gameprofilerfiller, false);
+ // CraftBukkit end
+ }, gameprofilerfiller, false, gen, env);
2018-08-26 04:00:00 +02:00
+ this.dimension = dimensionmanager;
2014-11-25 22:32:16 +01:00
+ this.pvpMode = minecraftserver.getPVP();
2015-02-26 23:41:06 +01:00
+ worlddata.world = this;
2014-11-25 22:32:16 +01:00
+ // CraftBukkit end
2018-12-25 22:00:00 +01:00
this.nextTickListBlock = new TickListServer<>(this, (block) -> {
2018-07-15 02:00:00 +02:00
return block == null || block.getBlockData().isAir();
2019-04-23 04:00:00 +02:00
}, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b);
2019-04-24 02:28:36 +02:00
@@ -85,6 +119,7 @@
2015-03-16 12:32:53 +01:00
}
2019-04-23 04:00:00 +02:00
this.mobSpawnerTrader = this.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD ? new MobSpawnerTrader(this) : null;
+ this.getServer().addWorld(this.getWorld()); // CraftBukkit
}
2018-08-26 04:00:00 +02:00
public void doTick(BooleanSupplier booleansupplier) {
2019-04-24 02:28:36 +02:00
@@ -161,6 +196,7 @@
2019-04-23 04:00:00 +02:00
this.m = MathHelper.a(this.m, 0.0F, 1.0F);
2014-11-25 22:32:16 +01:00
}
2019-04-23 04:00:00 +02:00
+ /* CraftBukkit start
if (this.l != this.m) {
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.m)), this.worldProvider.getDimensionManager());
2014-11-25 22:32:16 +01:00
}
2019-04-24 02:28:36 +02:00
@@ -179,13 +215,34 @@
2019-04-23 04:00:00 +02:00
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.m));
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.o));
}
+ // */
+ for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
+ ((EntityPlayer) this.players.get(idx)).tickWeather();
+ }
+ }
2015-02-26 23:41:06 +01:00
+
2019-04-23 04:00:00 +02:00
+ if (flag != this.isRaining()) {
+ // Only send weather packets to those affected
+ for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
+ ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
+ }
+ }
+ }
+ for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
+ ((EntityPlayer) this.players.get(idx)).updateWeather(this.l, this.m, this.n, this.o);
+ }
+ }
+ // CraftBukkit end
if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) {
this.getWorldData().setDifficulty(EnumDifficulty.HARD);
}
if (this.D && this.players.stream().noneMatch((entityplayer) -> {
- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping();
+ return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit
})) {
this.D = false;
if (this.getGameRules().getBoolean("doDaylightCycle")) {
2019-04-24 02:28:36 +02:00
@@ -226,7 +283,7 @@
2019-04-23 04:00:00 +02:00
this.ae();
this.ticking = false;
gameprofilerfiller.exitEnter("entities");
- boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty();
+ boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
if (flag3) {
this.resetEmptyTime();
2019-04-24 02:28:36 +02:00
@@ -240,6 +297,11 @@
2019-04-23 04:00:00 +02:00
for (i = 0; i < this.globalEntityList.size(); ++i) {
entity = (Entity) this.globalEntityList.get(i);
+ // CraftBukkit start - Fixed an NPE
+ if (entity == null) {
+ continue;
+ }
+ // CraftBukkit end
this.a((entity1) -> {
++entity1.ticksLived;
entity1.tick();
2019-04-24 02:28:36 +02:00
@@ -258,6 +320,7 @@
2019-04-23 04:00:00 +02:00
Entity entity1 = (Entity) entry.getValue();
Entity entity2 = entity1.getVehicle();
+ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed
if (!this.server.getSpawnAnimals() && (entity1 instanceof EntityAnimal || entity1 instanceof EntityWaterAnimal)) {
entity1.die();
}
2019-04-24 02:28:36 +02:00
@@ -265,6 +328,7 @@
2019-04-23 04:00:00 +02:00
if (!this.server.getSpawnNPCs() && entity1 instanceof NPC) {
entity1.die();
}
+ // CraftBukkit end */
if (entity2 != null) {
if (!entity2.dead && entity2.w(entity1)) {
2019-04-24 02:28:36 +02:00
@@ -325,10 +389,10 @@
2019-04-23 04:00:00 +02:00
entityhorseskeleton.r(true);
entityhorseskeleton.setAgeRaw(0);
entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
- this.addEntity(entityhorseskeleton);
+ this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
}
- this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag1));
+ this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag1), org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit
}
}
2019-04-24 02:28:36 +02:00
@@ -339,11 +403,11 @@
2019-04-23 04:00:00 +02:00
BiomeBase biomebase = this.getBiome(blockposition);
if (biomebase.a((IWorldReader) this, blockposition1)) {
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit
}
if (flag && biomebase.b(this, blockposition)) {
- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit
}
if (flag && this.getBiome(blockposition1).b() == BiomeBase.Precipitation.RAIN) {
2019-04-24 02:28:36 +02:00
@@ -390,7 +454,7 @@
2019-04-23 04:00:00 +02:00
protected BlockPosition a(BlockPosition blockposition) {
BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getHeight(), blockposition1.getZ()))).g(3.0D);
- List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> {
+ List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
return entityliving != null && entityliving.isAlive() && this.f(entityliving.getChunkCoordinates());
});
2014-11-25 22:32:16 +01:00
2019-04-24 02:28:36 +02:00
@@ -421,7 +485,7 @@
2014-11-25 22:32:16 +01:00
2019-04-23 04:00:00 +02:00
if (entityplayer.isSpectator()) {
2014-11-25 22:32:16 +01:00
++i;
2019-04-23 04:00:00 +02:00
- } else if (entityplayer.isSleeping()) {
+ } else if (entityplayer.isSleeping() || entityplayer.fauxSleeping) { // CraftBukkit
2014-11-25 22:32:16 +01:00
++j;
}
}
2019-04-24 02:28:36 +02:00
@@ -437,10 +501,22 @@
2014-11-25 22:32:16 +01:00
}
2019-04-23 04:00:00 +02:00
private void clearWeather() {
2014-11-25 22:32:16 +01:00
- this.worldData.setWeatherDuration(0);
2018-07-15 02:00:00 +02:00
+ // CraftBukkit start
2015-01-04 23:50:48 +01:00
this.worldData.setStorm(false);
2014-11-25 22:32:16 +01:00
- this.worldData.setThunderDuration(0);
2015-01-04 23:50:48 +01:00
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
+ // Not that everyone ever manages to get the whole server to sleep at the same time....
+ if (!this.worldData.hasStorm()) {
2014-11-25 22:32:16 +01:00
+ this.worldData.setWeatherDuration(0);
+ }
2015-01-04 23:50:48 +01:00
+ // CraftBukkit end
this.worldData.setThundering(false);
+ // CraftBukkit start
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
+ // Not that everyone ever manages to get the whole server to sleep at the same time....
+ if (!this.worldData.isThundering()) {
2014-11-25 22:32:16 +01:00
+ this.worldData.setThunderDuration(0);
+ }
+ // CraftBukkit end
}
2019-04-23 04:00:00 +02:00
public void resetEmptyTime() {
2019-04-24 02:28:36 +02:00
@@ -478,6 +554,7 @@
2019-04-23 04:00:00 +02:00
return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType()).toString();
});
entity.tick();
+ entity.postTick(); // CraftBukkit
this.getMethodProfiler().exit();
2014-11-25 22:32:16 +01:00
}
2019-04-24 02:28:36 +02:00
@@ -563,6 +640,22 @@
2018-07-15 02:00:00 +02:00
BlockPosition blockposition = worldchunkmanager.a(0, 0, 256, list, random);
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
2015-02-26 23:41:06 +01:00
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
+ if (this.generator != null) {
+ Random rand = new Random(this.getSeed());
+ org.bukkit.Location spawn = this.generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand);
+
+ if (spawn != null) {
+ if (spawn.getWorld() != ((WorldServer) this).getWorld()) {
+ throw new IllegalStateException("Cannot set spawn point for " + this.worldData.getName() + " to be in another world (" + spawn.getWorld().getName() + ")");
+ } else {
+ this.worldData.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()));
+ return;
+ }
+ }
+ }
2015-02-26 23:41:06 +01:00
+ // CraftBukkit end
+
2018-07-15 02:00:00 +02:00
if (blockposition == null) {
2019-04-25 04:00:00 +02:00
WorldServer.LOGGER.warn("Unable to find spawn biome");
2018-07-15 02:00:00 +02:00
}
2019-04-24 02:28:36 +02:00
@@ -638,6 +731,7 @@
2018-12-13 01:00:00 +01:00
ChunkProviderServer chunkproviderserver = this.getChunkProvider();
2014-11-25 22:32:16 +01:00
2019-04-23 04:00:00 +02:00
if (!flag1) {
2014-12-03 20:35:33 +01:00
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
2014-11-25 22:32:16 +01:00
if (iprogressupdate != null) {
2018-07-15 02:00:00 +02:00
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
2014-12-03 20:35:33 +01:00
}
2019-04-24 02:28:36 +02:00
@@ -716,8 +810,16 @@
2019-04-23 04:00:00 +02:00
while (objectiterator.hasNext()) {
Entity entity = (Entity) objectiterator.next();
+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
+ if (entity instanceof EntityInsentient) {
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
+ if (entityinsentient.isTypeNotPersistent(0) && entityinsentient.isPersistent()) {
+ continue;
+ }
+ }
- if (!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) {
+ if (true || !(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) {
+ // CraftBukkit end
EnumCreatureType enumcreaturetype = entity.getEntityType().d();
2014-11-25 22:32:16 +01:00
2019-04-23 04:00:00 +02:00
if (enumcreaturetype != EnumCreatureType.MISC) {
2019-04-24 02:28:36 +02:00
@@ -733,11 +835,24 @@
2014-11-25 22:32:16 +01:00
2019-04-23 04:00:00 +02:00
@Override
public boolean addEntity(Entity entity) {
- return this.addEntity0(entity);
+ // CraftBukkit start
+ return this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ @Override
+ public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
+ return this.addEntity0(entity, reason);
+ // CraftBukkit end
2016-10-16 08:20:12 +02:00
}
2019-04-23 04:00:00 +02:00
public boolean addEntitySerialized(Entity entity) {
- return this.addEntity0(entity);
+ // CraftBukkit start
+ return this.addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ public boolean addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
+ return this.addEntity0(entity, reason);
+ // CraftBukkit end
2016-10-16 08:20:12 +02:00
}
2019-04-23 04:00:00 +02:00
public void addEntityTeleport(Entity entity) {
2019-04-24 02:28:36 +02:00
@@ -787,13 +902,18 @@
2019-04-23 04:00:00 +02:00
this.registerEntity(entityplayer);
}
2016-02-29 22:32:46 +01:00
2019-04-23 04:00:00 +02:00
- private boolean addEntity0(Entity entity) {
+ // CraftBukkit start
+ private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
2016-02-29 22:32:46 +01:00
if (entity.dead) {
2019-04-25 04:00:00 +02:00
- WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType()));
+ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit
2019-04-23 04:00:00 +02:00
return false;
} else if (this.isUUIDTaken(entity)) {
2016-02-29 22:32:46 +01:00
return false;
} else {
2019-04-23 04:00:00 +02:00
+ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
+ return false;
+ }
+ // CraftBukkit end
IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX / 16.0D), MathHelper.floor(entity.locZ / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer);
2018-09-15 11:16:42 +02:00
2019-04-23 04:00:00 +02:00
if (!(ichunkaccess instanceof Chunk)) {
2019-04-24 02:28:36 +02:00
@@ -821,7 +941,7 @@
2019-04-23 04:00:00 +02:00
if (entity1 == null) {
return false;
} else {
2019-04-25 04:00:00 +02:00
- WorldServer.LOGGER.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.getEntityType()), entity.getUniqueID().toString());
+ // WorldServer.LOGGER.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.getEntityType()), entity.getUniqueID().toString()); // CraftBukkit
2019-04-23 04:00:00 +02:00
return true;
}
}
2019-04-27 01:25:38 +02:00
@@ -876,6 +996,7 @@
this.I.remove(((EntityInsentient) entity).getNavigation());
}
+ entity.valid = false; // CraftBukkit
}
private void registerEntity(Entity entity) {
@@ -899,6 +1020,7 @@
2019-04-23 04:00:00 +02:00
if (entity instanceof EntityInsentient) {
this.I.add(((EntityInsentient) entity).getNavigation());
}
+ entity.valid = true; // CraftBukkit
}
}
2019-04-27 01:25:38 +02:00
@@ -929,6 +1051,18 @@
2014-11-25 22:32:16 +01:00
}
2019-04-23 04:00:00 +02:00
public void strikeLightning(EntityLightning entitylightning) {
+ // CraftBukkit start
+ this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
2018-09-15 11:16:42 +02:00
+ }
+
2019-04-23 04:00:00 +02:00
+ public void strikeLightning(EntityLightning entitylightning, LightningStrikeEvent.Cause cause) {
+ LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause);
2014-11-25 22:32:16 +01:00
+ this.getServer().getPluginManager().callEvent(lightning);
+
+ if (lightning.isCancelled()) {
2019-04-23 04:00:00 +02:00
+ return;
2014-11-25 22:32:16 +01:00
+ }
2016-02-29 22:32:46 +01:00
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
this.globalEntityList.add(entitylightning);
this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning));
2014-11-25 22:32:16 +01:00
}
2019-04-27 01:25:38 +02:00
@@ -937,6 +1071,12 @@
2019-04-23 04:00:00 +02:00
public void a(int i, BlockPosition blockposition, int j) {
Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
+ // CraftBukkit start
+ EntityHuman entityhuman = null;
+ Entity entity = this.getEntity(i);
+ if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity;
+ // CraftBukkit end
+
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
2019-04-27 01:25:38 +02:00
@@ -945,6 +1085,12 @@
2019-04-23 04:00:00 +02:00
double d1 = (double) blockposition.getY() - entityplayer.locY;
double d2 = (double) blockposition.getZ() - entityplayer.locZ;
+ // CraftBukkit start
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
+ continue;
+ }
+ // CraftBukkit end
+
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
2019-04-27 01:25:38 +02:00
@@ -955,12 +1101,14 @@
2019-04-23 04:00:00 +02:00
@Override
public void a(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) {
- this.server.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
+ // CraftBukkit - this.dimension
+ this.server.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.dimension, new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
}
@Override
public void a(@Nullable EntityHuman entityhuman, Entity entity, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) {
- this.server.getPlayerList().sendPacketNearby(entityhuman, entity.locX, entity.locY, entity.locZ, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutEntitySound(soundeffect, soundcategory, entity, f, f1));
+ // CraftBukkit - this.dimension
+ this.server.getPlayerList().sendPacketNearby(entityhuman, entity.locX, entity.locY, entity.locZ, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.dimension, new PacketPlayOutEntitySound(soundeffect, soundcategory, entity, f, f1));
}
@Override
2019-04-27 01:25:38 +02:00
@@ -970,7 +1118,8 @@
2019-04-23 04:00:00 +02:00
@Override
public void a(@Nullable EntityHuman entityhuman, int i, BlockPosition blockposition, int j) {
- this.server.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutWorldEvent(i, blockposition, j, false));
+ // CraftBukkit - this.dimension
+ this.server.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.dimension, new PacketPlayOutWorldEvent(i, blockposition, j, false));
}
@Override
2019-04-27 01:25:38 +02:00
@@ -1005,6 +1154,14 @@
2014-11-25 22:32:16 +01:00
2019-04-23 04:00:00 +02:00
@Override
public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
2019-04-23 04:00:00 +02:00
+ Explosion explosion = super.createExplosion(entity, damagesource, d0, d1, d2, f, flag, explosion_effect);
2014-11-25 22:32:16 +01:00
+
+ if (explosion.wasCanceled) {
+ return explosion;
+ }
2015-02-26 23:41:06 +01:00
+
2014-11-25 22:32:16 +01:00
+ /* Remove
2019-04-23 04:00:00 +02:00
Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, explosion_effect);
2014-11-25 22:32:16 +01:00
2018-07-15 02:00:00 +02:00
if (damagesource != null) {
2019-04-27 01:25:38 +02:00
@@ -1013,6 +1170,8 @@
2018-07-15 02:00:00 +02:00
2014-11-25 22:32:16 +01:00
explosion.a();
explosion.a(false);
+ */
+ // CraftBukkit end - TODO: Check if explosions are still properly implemented
2019-04-23 04:00:00 +02:00
if (explosion_effect == Explosion.Effect.NONE) {
2014-11-25 22:32:16 +01:00
explosion.clearBlocks();
}
2019-04-27 01:25:38 +02:00
@@ -1040,7 +1199,8 @@
2019-04-23 04:00:00 +02:00
BlockActionData blockactiondata = (BlockActionData) this.J.removeFirst();
2014-11-25 22:32:16 +01:00
2018-07-15 02:00:00 +02:00
if (this.a(blockactiondata)) {
2018-08-26 04:00:00 +02:00
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
2018-07-15 02:00:00 +02:00
+ // CraftBukkit - this.worldProvider.dimension -> this.dimension
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
2014-11-25 22:32:16 +01:00
}
2018-07-15 02:00:00 +02:00
}
2014-11-25 22:32:16 +01:00
2019-04-27 01:25:38 +02:00
@@ -1083,13 +1243,20 @@
2014-11-25 22:32:16 +01:00
}
2018-07-15 02:00:00 +02:00
public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
2018-08-26 10:26:09 +02:00
- PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
2014-11-25 22:32:16 +01:00
+ // CraftBukkit - visibility api support
2018-08-26 10:26:09 +02:00
+ return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6, false);
2014-11-25 22:32:16 +01:00
+ }
2015-02-26 23:41:06 +01:00
+
2018-08-26 10:26:09 +02:00
+ public <T extends ParticleParam> int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
+ PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, force, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
2014-11-25 22:32:16 +01:00
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
int j = 0;
2014-11-25 22:32:16 +01:00
2018-07-15 02:00:00 +02:00
for (int k = 0; k < this.players.size(); ++k) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(k);
2014-12-28 15:56:18 +01:00
+ if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
2014-11-25 22:32:16 +01:00
2018-08-26 10:26:09 +02:00
- if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) {
+ if (this.a(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
2018-07-15 02:00:00 +02:00
++j;
2018-08-26 10:26:09 +02:00
}
}
2019-04-27 01:25:38 +02:00
@@ -1172,7 +1339,13 @@
2019-04-23 04:00:00 +02:00
@Override
public WorldMap a(String s) {
return (WorldMap) this.getMinecraftServer().getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData().b(() -> {
- return new WorldMap(s);
+ // CraftBukkit start
+ // We only get here when the data file exists, but is not a valid map
+ WorldMap newMap = new WorldMap(s);
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ return newMap;
+ // CraftBukkit end
}, s);
}