2021-03-16 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								--- a/net/minecraft/world/entity/Entity.java
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+++ b/net/minecraft/world/entity/Entity.java
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 08:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -116,8 +116,59 @@
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 import org.apache.logging.log4j.LogManager;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 import org.apache.logging.log4j.Logger;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:39:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import net.minecraft.world.level.dimension.WorldDimension;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.Bukkit;
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.Location;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.Server;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.block.BlockFace;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.command.CommandSender;
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.craftbukkit.event.CraftPortalEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.entity.Hanging;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.entity.LivingEntity;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.entity.Vehicle;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.entity.EntityCombustByEntityEvent;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.vehicle.VehicleEnterEvent;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.vehicle.VehicleExitEvent;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.craftbukkit.CraftWorld;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.craftbukkit.entity.CraftEntity;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.craftbukkit.entity.CraftPlayer;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.craftbukkit.event.CraftEventFactory;
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-27 10:27:05 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.entity.Pose;
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-08 18:24:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.entity.EntityAirChangeEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.entity.EntityCombustEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-31 10:06:06 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.entity.EntityDropItemEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.entity.EntityPortalEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-27 10:27:05 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.entity.EntityPoseChangeEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 21:47:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.event.player.PlayerTeleportEvent;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+import org.bukkit.plugin.PluginManager;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+// CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 public abstract class Entity implements INamableTileEntity, EntityAccess, ICommandListener {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    private static final int CURRENT_LEVEL = 2;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-02 19:49:41 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    private CraftEntity bukkitEntity;
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public CraftEntity getBukkitEntity() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (bukkitEntity == null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 21:33:49 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            bukkitEntity = CraftEntity.getEntity(level.getCraftServer(), this);
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        return bukkitEntity;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    @Override
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        return getBukkitEntity();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     protected static final Logger LOGGER = LogManager.getLogger();
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public static final String ID_TAG = "id";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     public static final String PASSENGERS_TAG = "Passengers";
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -228,6 +279,23 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public boolean hasVisualFire;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     @Nullable
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     private IBlockData feetBlockState;
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-07 17:21:38 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public boolean persist = true;
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-07 17:21:38 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public boolean valid;
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												SPIGOT-5880, SPIGOT-5567: New ChunkGenerator API
## **Current API**
The current world generation API is very old and limited when you want to make more complex world generation. Resulting in some hard to fix bugs such as that you cannot modify blocks outside the chunk in the BlockPopulator (which should and was per the docs possible), or strange behavior such as SPIGOT-5880.
## **New API**
With the new API, the generation is more separate in multiple methods and is more in line with Vanilla chunk generation. The new API is designed to as future proof as possible. If for example a new generation step is added it can easily also be added as a step in API by simply creating the method for it. On the other side if a generation step gets removed, the method can easily be called after another, which is the case with surface and bedrock. The new API and changes are also fully backwards compatible with old chunk generators.
### **Changes in the new api**
**Extra generation steps:**
Noise, surface, bedrock and caves are added as steps. With those generation steps three extra methods for Vanilla generation are also added. Those new methods provide the ChunkData instead of returning one. The reason for this is, that the ChunkData is now backed by a ChunkAccess. With this, each step has the information of the step before and the Vanilla information (if chosen by setting a 'should' method to true). The old method is deprecated.
**New class BiomeProvider**
The BiomeProvider acts as Biome source and wrapper for the NMS class WorldChunkManager. With this the underlying Vanilla ChunkGeneration knows which Biome to use for the structure and decoration generation. (Fixes: SPIGOT-5880). Although the List of Biomes which is required in BiomeProvider, is currently not much in use in Vanilla, I decided to add it to future proof the API when it may be required in later versions of Minecraft.
The BiomeProvider is also separated from the ChunkGenerator for plugins which only want to change the biome map, such as single Biome worlds or if some biomes should be more present than others.
**Deprecated isParallelCapable**
Mojang has and is pushing to a more multi threaded chunk generation. This should also be the case for custom chunk generators. This is why the new API only supports multi threaded generation. This does not affect the old API, which is still checking this.
**Base height method added**
This method was added to also bring the Minecraft generator and Bukkit generator more in line. With this it is possible to return the max height of a location (before decorations). This is useful to let most structures know were to place them. This fixes SPIGOT-5567. (This fixes not all structures placement, desert pyramids for example are still way up at y-level 64, This however is more a vanilla bug and should be fixed at Mojangs end).
**WorldInfo Class**
The World object was swapped for a WorldInfo object. This is because many methods of the World object won't work during world generation and would mostly likely result in a deadlock. It contains any information a plugin should need to identify the world.
**BlockPopulator Changes**
Instead of directly manipulating a chunk, changes are now made to a new class LimitedRegion, this class provides methods to populated the chunk and its surrounding area. The wrapping is done so that the population can be moved into the place where Minecraft generates decorations. Where there is no chunk to access yet. By moving it into this place the generation is now async and the surrounding area of the chunk can also be used.
For common methods between the World and LimitedRegion a RegionAccessor was added.
By: DerFrZocker <derrieple@gmail.com>
											
										 
										
											2021-08-15 08:08:16 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public boolean generation;
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-07 17:21:38 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
							 | 
						
					
						
							
								
									
										
										
										
											2022-01-03 18:07:01 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-19 17:44:48 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public boolean persistentInvisibility = false;
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public BlockPosition lastLavaContact;
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-07 17:21:38 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public float getBukkitYaw() {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        return this.yRot;
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-07 17:21:38 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-16 01:11:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public boolean isChunkLoaded() {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        return level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4);
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-16 01:11:20 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							
								
									
										
										
										
											2017-11-07 17:21:38 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public Entity(EntityTypes<?> entitytypes, World world) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.id = Entity.ENTITY_COUNTER.incrementAndGet();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -365,6 +433,12 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void onClientRemoval() {}
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-27 10:27:05 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void setPose(EntityPose entitypose) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-28 10:03:52 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-14 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (entitypose == this.getPose()) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-28 10:03:52 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 21:33:49 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[entitypose.ordinal()]));
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-28 10:03:52 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.entityData.set(Entity.DATA_POSE, entitypose);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-27 10:27:05 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -381,6 +455,33 @@
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     protected void setRot(float f, float f1) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (Float.isNaN(f)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            f = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (this instanceof EntityPlayer) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid yaw");
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-05 16:21:07 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)");
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            f = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // pitch was sometimes set to NaN, so we need to set it back to 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (Float.isNaN(f1)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            f1 = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (this instanceof EntityPlayer) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid pitch");
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-05 16:21:07 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)");
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            f1 = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.setYRot(f % 360.0F);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         this.setXRot(f1 % 360.0F);
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-26 17:19:16 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -422,6 +523,15 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.baseTick();
							 | 
						
					
						
							
								
									
										
										
										
											2017-03-20 15:41:15 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    public void postTick() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (!(this instanceof EntityPlayer)) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            this.handleNetherPortal();
							 | 
						
					
						
							
								
									
										
										
										
											2017-03-20 15:41:15 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void baseTick() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         this.level.getProfiler().push("entityBaseTick");
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 08:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.feetBlockState = null;
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -436,7 +546,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.walkDistO = this.walkDist;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         this.xRotO = this.getXRot();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         this.yRotO = this.getYRot();
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-        this.handleNetherPortal();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (this instanceof EntityPlayer) this.handleNetherPortal(); // CraftBukkit - // Moved up to postTick
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         if (this.canSpawnSprintParticle()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             this.spawnSprintParticle();
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -471,6 +581,10 @@
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         if (this.isInLava()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             this.lavaHurt();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             this.fallDistance *= 0.5F;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            this.lastLavaContact = null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         this.checkOutOfWorld();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								@@ -514,15 +628,48 @@
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void lavaHurt() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         if (!this.fireImmune()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            this.setSecondsOnFire(15);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start - Fallen in lava TODO: this event spams!
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (this instanceof EntityLiving && remainingFireTicks <= 0) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // not on fire yet
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                org.bukkit.block.Block damager = (lastLavaContact == null) ? null : org.bukkit.craftbukkit.block.CraftBlock.at(level, lastLavaContact);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                org.bukkit.entity.Entity damagee = this.getBukkitEntity();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 21:33:49 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                this.level.getCraftServer().getPluginManager().callEvent(combustEvent);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (!combustEvent.isCancelled()) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    this.setSecondsOnFire(combustEvent.getDuration(), false);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // This will be called every single tick the entity is in lava, so don't throw an event
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                this.setSecondsOnFire(15, false);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            CraftEventFactory.blockDamage = (lastLavaContact) == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(level, lastLavaContact);
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if (this.hurt(DamageSource.LAVA, 4.0F)) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            CraftEventFactory.blockDamage = null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-09 20:38:37 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void setSecondsOnFire(int i) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-09 20:38:37 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        this.setSecondsOnFire(i, true);
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-09 20:38:37 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public void setSecondsOnFire(int i, boolean callEvent) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-09 20:38:37 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (callEvent) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i);
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 21:33:49 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            this.level.getCraftServer().getPluginManager().callEvent(event);
							 | 
						
					
						
							
								
									
										
										
										
											2019-01-09 20:38:37 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (event.isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            i = event.getDuration();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         int j = i * 20;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         if (this instanceof EntityLiving) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -627,6 +774,28 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     block.updateEntityAfterFallOn(this.level, this);
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (horizontalCollision && getBukkitEntity() instanceof Vehicle) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    Vehicle vehicle = (Vehicle) this.getBukkitEntity();
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    org.bukkit.block.Block bl = this.level.getWorld().getBlockAt(MathHelper.floor(this.getX()), MathHelper.floor(this.getY()), MathHelper.floor(this.getZ()));
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    if (vec3d.x > vec3d1.x) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        bl = bl.getRelative(BlockFace.EAST);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    } else if (vec3d.x < vec3d1.x) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        bl = bl.getRelative(BlockFace.WEST);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    } else if (vec3d.z > vec3d1.z) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        bl = bl.getRelative(BlockFace.SOUTH);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    } else if (vec3d.z < vec3d1.z) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        bl = bl.getRelative(BlockFace.NORTH);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    if (!bl.getType().isAir()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 21:33:49 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        level.getCraftServer().getPluginManager().callEvent(event);
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							
								
									
										
										
										
											2016-10-12 19:47:14 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 if (this.onGround && !this.isSteppingCarefully()) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     block.stepOn(this.level, blockposition, iblockdata, this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1260,6 +1429,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.yo = d1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         this.zo = d4;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.setPos(d3, d1, d4);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (valid) level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-26 17:19:16 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2019-12-11 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void moveTo(Vec3D vec3d) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1450,6 +1620,12 @@
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit start - collidable API
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public boolean canCollideWithBukkit(Entity entity) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        return isPushable();
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (entity instanceof EntityPlayer) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1483,7 +1659,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             String s = this.getEncodeId();
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            if (s == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (!this.persist || s == null) { // CraftBukkit - persist flag
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 nbttagcompound.putString("id", s);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1508,6 +1684,18 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             Vec3D vec3d = this.getDeltaMovement();
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // TODO: make sure this is the best way to address this.
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (Float.isNaN(this.yRot)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                this.yRot = 0;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (Float.isNaN(this.xRot)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                this.xRot = 0;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             nbttagcompound.putFloat("FallDistance", this.fallDistance);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1516,6 +1704,18 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             nbttagcompound.putUUID("UUID", this.getUUID());
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            nbttagcompound.putLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            nbttagcompound.putLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            nbttagcompound.putInt("Bukkit.updateLevel", CURRENT_LEVEL);
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-26 18:20:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (!this.persist) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                nbttagcompound.putBoolean("Bukkit.persist", this.persist);
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-26 18:20:58 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-19 17:44:48 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (this.persistentInvisibility) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                nbttagcompound.putBoolean("Bukkit.invisible", this.persistentInvisibility);
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-19 17:44:48 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             IChatBaseComponent ichatbasecomponent = this.getCustomName();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             if (ichatbasecomponent != null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1583,6 +1783,11 @@
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-25 14:36:46 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start - stores eventually existing bukkit values
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (this.bukkitEntity != null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                this.bukkitEntity.storeBukkitValues(nbttagcompound);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             return nbttagcompound;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } catch (Throwable throwable) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1664,6 +1869,49 @@
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 throw new IllegalStateException("Entity has invalid position");
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (this instanceof EntityLiving) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                EntityLiving entity = (EntityLiving) this;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // Reset the persistence for tamed animals
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    EntityInsentient entityinsentient = (EntityInsentient) entity;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    entityinsentient.setPersistenceRequired(!entityinsentient.removeWhenFarAway(0));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            this.persist = !nbttagcompound.contains("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist");
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start - Reset world
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (this instanceof EntityPlayer) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                Server server = Bukkit.getServer();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                org.bukkit.World bworld = null;
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-21 17:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                // TODO: Remove World related checks, replaced with WorldUID
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                String worldName = nbttagcompound.getString("world");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if (nbttagcompound.contains("WorldUUIDMost") && nbttagcompound.contains("WorldUUIDLeast")) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    bworld = server.getWorld(uid);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    bworld = server.getWorld(worldName);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (bworld == null) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getLevel(World.OVERWORLD).getWorld();
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                ((EntityPlayer) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle());
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2019-05-25 11:22:18 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            this.getBukkitEntity().readBukkitValues(nbttagcompound);
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (nbttagcompound.contains("Bukkit.invisible")) {
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-19 17:44:48 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                boolean bukkitInvisible = nbttagcompound.getBoolean("Bukkit.invisible");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                this.setInvisible(bukkitInvisible);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                this.persistentInvisibility = bukkitInvisible;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } catch (Throwable throwable) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1739,9 +1987,22 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         } else if (this.level.isClientSide) {
							 | 
						
					
						
							
								
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } else {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start - Capture drops for death event
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-08 17:58:52 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             entityitem.setDefaultPickUpDelay();
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-31 10:06:06 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            Bukkit.getPluginManager().callEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (event.isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             this.level.addFreshEntity(entityitem);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-31 10:06:06 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             return entityitem;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1836,7 +2097,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 this.setPose(EntityPose.STANDING);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 this.vehicle = entity;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                this.vehicle.addPassenger(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 entity.getIndirectPassengersStream().filter((entity2) -> {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     return entity2 instanceof EntityPlayer;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 }).forEach((entity2) -> {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1867,7 +2128,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             Entity entity = this.vehicle;
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-28 10:10:17 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             this.vehicle = null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            entity.removePassenger(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-28 10:10:17 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1876,10 +2137,31 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.removeVehicle();
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-09 09:32:11 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 06:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-    protected void addPassenger(Entity entity) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    protected boolean addPassenger(Entity entity) { // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (entity.getVehicle() != this) {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-15 15:09:39 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            Entity orig = craft == null ? null : craft.getHandle();
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 09:45:57 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                VehicleEnterEvent event = new VehicleEnterEvent(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        (Vehicle) getBukkitEntity(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                         entity.getBukkitEntity()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                );
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // Suppress during worldgen
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (this.valid) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    Bukkit.getPluginManager().callEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                Entity n = craftn == null ? null : craftn.getHandle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (event.isCancelled() || n != orig) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-09 09:32:11 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    return false;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if (this.passengers.isEmpty()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 this.passengers = ImmutableList.of(entity);
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1895,12 +2177,32 @@
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-09 09:32:11 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-28 10:10:17 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2018-09-09 09:32:11 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        return true; // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-28 10:10:17 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-    protected void removePassenger(Entity entity) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    protected boolean removePassenger(Entity entity) { // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (entity.getVehicle() == this) {
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            Entity orig = craft == null ? null : craft.getHandle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                VehicleExitEvent event = new VehicleExitEvent(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        (Vehicle) getBukkitEntity(),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                        (LivingEntity) entity.getBukkitEntity()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                );
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-30 10:55:06 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // Suppress during worldgen
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (this.valid) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    Bukkit.getPluginManager().callEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                Entity n = craftn == null ? null : craftn.getHandle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                if (event.isCancelled() || n != orig) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-28 10:10:17 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    return false;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 this.passengers = ImmutableList.of();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1911,6 +2213,7 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             entity.boardingCooldown = 60;
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-28 10:10:17 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        return true; // CraftBukkit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     protected boolean canAddPassenger(Entity entity) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1961,14 +2264,20 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-02-13 10:31:49 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if (this.isInsidePortal) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 MinecraftServer minecraftserver = worldserver.getServer();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                ResourceKey<World> resourcekey = this.level.dimension() == World.NETHER ? World.OVERWORLD : World.NETHER;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:39:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                ResourceKey<World> resourcekey = this.level.getTypeKey() == WorldDimension.NETHER ? World.OVERWORLD : World.NETHER; // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 WorldServer worldserver1 = minecraftserver.getLevel(resourcekey);
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-26 08:30:47 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                if (worldserver1 != null && minecraftserver.isNetherEnabled() && !this.isPassenger() && this.portalTime++ >= i) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.level.getProfiler().push("portal");
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.portalTime = i;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.setPortalCooldown();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                    this.changeDimension(worldserver1);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 21:47:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    if (this instanceof EntityPlayer) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        ((EntityPlayer) this).changeDimension(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 21:47:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        this.changeDimension(worldserver1);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 21:47:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     this.level.getProfiler().pop();
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-26 21:47:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2086,6 +2395,13 @@
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 16:17:35 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-22 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void setSwimming(boolean flag) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 16:17:35 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												SPIGOT-5880, SPIGOT-5567: New ChunkGenerator API
## **Current API**
The current world generation API is very old and limited when you want to make more complex world generation. Resulting in some hard to fix bugs such as that you cannot modify blocks outside the chunk in the BlockPopulator (which should and was per the docs possible), or strange behavior such as SPIGOT-5880.
## **New API**
With the new API, the generation is more separate in multiple methods and is more in line with Vanilla chunk generation. The new API is designed to as future proof as possible. If for example a new generation step is added it can easily also be added as a step in API by simply creating the method for it. On the other side if a generation step gets removed, the method can easily be called after another, which is the case with surface and bedrock. The new API and changes are also fully backwards compatible with old chunk generators.
### **Changes in the new api**
**Extra generation steps:**
Noise, surface, bedrock and caves are added as steps. With those generation steps three extra methods for Vanilla generation are also added. Those new methods provide the ChunkData instead of returning one. The reason for this is, that the ChunkData is now backed by a ChunkAccess. With this, each step has the information of the step before and the Vanilla information (if chosen by setting a 'should' method to true). The old method is deprecated.
**New class BiomeProvider**
The BiomeProvider acts as Biome source and wrapper for the NMS class WorldChunkManager. With this the underlying Vanilla ChunkGeneration knows which Biome to use for the structure and decoration generation. (Fixes: SPIGOT-5880). Although the List of Biomes which is required in BiomeProvider, is currently not much in use in Vanilla, I decided to add it to future proof the API when it may be required in later versions of Minecraft.
The BiomeProvider is also separated from the ChunkGenerator for plugins which only want to change the biome map, such as single Biome worlds or if some biomes should be more present than others.
**Deprecated isParallelCapable**
Mojang has and is pushing to a more multi threaded chunk generation. This should also be the case for custom chunk generators. This is why the new API only supports multi threaded generation. This does not affect the old API, which is still checking this.
**Base height method added**
This method was added to also bring the Minecraft generator and Bukkit generator more in line. With this it is possible to return the max height of a location (before decorations). This is useful to let most structures know were to place them. This fixes SPIGOT-5567. (This fixes not all structures placement, desert pyramids for example are still way up at y-level 64, This however is more a vanilla bug and should be fixed at Mojangs end).
**WorldInfo Class**
The World object was swapped for a WorldInfo object. This is because many methods of the World object won't work during world generation and would mostly likely result in a deadlock. It contains any information a plugin should need to identify the world.
**BlockPopulator Changes**
Instead of directly manipulating a chunk, changes are now made to a new class LimitedRegion, this class provides methods to populated the chunk and its surrounding area. The wrapping is done so that the population can be moved into the place where Minecraft generates decorations. Where there is no chunk to access yet. By moving it into this place the generation is now async and the surrounding area of the chunk can also be used.
For common methods between the World and LimitedRegion a RegionAccessor was added.
By: DerFrZocker <derrieple@gmail.com>
											
										 
										
											2021-08-15 08:08:16 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (valid && this.isSwimming() != flag && this instanceof EntityLiving) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 16:17:35 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (CraftEventFactory.callToggleSwimEvent((EntityLiving) this, flag).isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         this.setSharedFlag(4, flag);
							 | 
						
					
						
							
								
									
										
										
										
											2018-07-15 16:17:35 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2134,8 +2450,12 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-19 17:44:48 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit - start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     public void setInvisible(boolean flag) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-        this.setSharedFlag(5, flag);
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-19 17:44:48 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (!this.persistentInvisibility) { // Prevent Minecraft from removing our invisibility flag
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            this.setSharedFlag(5, flag);
							 | 
						
					
						
							
								
									
										
										
										
											2020-09-19 17:44:48 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit - end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public boolean getSharedFlag(int i) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2162,7 +2482,17 @@
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-08 18:24:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void setAirSupply(int i) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-        this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, i);
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-08 18:24:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // Suppress during worldgen
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (this.valid) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            event.getEntity().getServer().getPluginManager().callEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-08 18:24:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (event.isCancelled()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount());
							 | 
						
					
						
							
								
									
										
										
										
											2016-08-08 18:24:21 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public int getTicksFrozen() {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2189,11 +2519,41 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         this.setRemainingFireTicks(this.remainingFireTicks + 1);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        final PluginManager pluginManager = Bukkit.getPluginManager();
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (this.remainingFireTicks == 0) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-            this.setSecondsOnFire(8);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start - Call a combust event when lightning strikes
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            pluginManager.callEvent(entityCombustEvent);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            if (!entityCombustEvent.isCancelled()) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                this.setSecondsOnFire(entityCombustEvent.getDuration(), false);
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (thisBukkitEntity instanceof Hanging) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            pluginManager.callEvent(hangingEvent);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (hangingEvent.isCancelled()) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-        this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (this.fireImmune()) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        CraftEventFactory.entityDamage = entitylightning;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        if (!this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F)) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            CraftEventFactory.entityDamage = null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public void onAboveBubbleCol(boolean flag) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2349,15 +2709,32 @@
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     @Nullable
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public Entity changeDimension(WorldServer worldserver) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        return teleportTo(worldserver, null);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    @Nullable
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    public Entity teleportTo(WorldServer worldserver, BlockPosition location) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (this.level instanceof WorldServer && !this.isRemoved()) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             this.level.getProfiler().push("changeDimension");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            this.unRide();
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2020-06-25 10:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            // this.decouple();
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (worldserver == null) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                return null;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             this.level.getProfiler().push("reposition");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            ShapeDetectorShape shapedetectorshape = (location == null) ? this.findDimensionEntryPoint(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             if (shapedetectorshape == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-14 15:10:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                worldserver = shapedetectorshape.world;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                this.unRide();
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-14 15:10:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 this.level.getProfiler().popPush("reloading");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 Entity entity = this.getType().create(worldserver);
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2366,9 +2743,17 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     entity.setDeltaMovement(shapedetectorshape.speed);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     worldserver.addDuringTeleport(entity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                    if (worldserver.dimension() == World.END) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                        WorldServer.makeObsidianPlatform(worldserver);
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:39:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    if (worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        WorldServer.makeObsidianPlatform(worldserver, this); // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    }
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    // CraftBukkit start - Forward the CraftEntity to the new entity
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    this.getBukkitEntity().setHandle(entity);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    entity.bukkitEntity = this.getBukkitEntity();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    if (this instanceof EntityInsentient) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                        ((EntityInsentient) this).dropLeash(true, false); // Unleash to prevent duping of leads.
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     }
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 this.removeAfterChangingDimensions();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2389,20 +2774,33 @@
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     @Nullable
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-        boolean flag = this.level.dimension() == World.END && worldserver.dimension() == World.OVERWORLD;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-        boolean flag1 = worldserver.dimension() == World.END;
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (worldserver == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:39:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        boolean flag = this.level.getTypeKey() == WorldDimension.END && worldserver.getTypeKey() == WorldDimension.OVERWORLD; // fromEndToOverworld
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        boolean flag1 = worldserver.getTypeKey() == WorldDimension.END; // targetIsEnd
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-12 01:02:13 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         if (!flag && !flag1) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-            boolean flag2 = worldserver.dimension() == World.NETHER;
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:39:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            boolean flag2 = worldserver.getTypeKey() == WorldDimension.NETHER; // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-            if (this.level.dimension() != World.NETHER && !flag2) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-23 18:39:43 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (this.level.getTypeKey() != WorldDimension.NETHER && !flag2) { // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 WorldBorder worldborder = worldserver.getWorldBorder();
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 double d0 = DimensionManager.getTeleportationScale(this.level.dimensionType(), worldserver.dimensionType());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0);
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-14 15:10:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-14 15:10:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if (event == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                    return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                }
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-14 15:10:30 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
							 | 
						
					
						
							
								
									
										
										
										
											2020-01-12 01:02:13 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder).map((blockutil_rectangle) -> {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> {
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos);
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     EnumDirection.EnumAxis enumdirection_enumaxis;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     Vec3D vec3d;
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2419,8 +2817,8 @@
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                         vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                    return BlockPortalShape.createPortalInfo(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot());
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-                }).orElse((Object) null);
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    return BlockPortalShape.createPortalInfo(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot(), event); // CraftBukkit
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                }).orElse(null); // CraftBuukkit - decompile error
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         } else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             BlockPosition blockposition1;
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2430,8 +2828,15 @@
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             } else {
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-23 12:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition1, PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+            if (event == null) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-            return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot(), ((CraftWorld) event.getTo().getWorld()).getHandle(), event);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            // CraftBukkit end
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2439,8 +2844,23 @@
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-    protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-        return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder);
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    // CraftBukkit start
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-14 08:26:40 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        Location enter = bukkitEntity.getLocation();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        event.getEntity().getServer().getPluginManager().callEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+            return null;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        return new CraftPortalEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        return worldserver.getPortalForcer().findPortalAround(blockposition, worldborder, searchRadius);
							 | 
						
					
						
							
								
									
										
										
										
											2020-08-12 07:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public boolean canChangeDimensions() {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2649,7 +3069,26 @@
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-02 17:53:34 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-        this.bb = axisalignedbb;
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-02 17:53:34 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit start - block invalid bounding boxes
							 | 
						
					
						
							
								
									
										
										
										
											2018-10-23 06:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        double minX = axisalignedbb.minX,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                minY = axisalignedbb.minY,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                minZ = axisalignedbb.minZ,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                maxX = axisalignedbb.maxX,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                maxY = axisalignedbb.maxY,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                maxZ = axisalignedbb.maxZ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        double len = axisalignedbb.maxX - axisalignedbb.minX;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (len < 0) maxX = minX;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (len > 64) maxX = minX + 64.0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        len = axisalignedbb.maxY - axisalignedbb.minY;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (len < 0) maxY = minY;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (len > 64) maxY = minY + 64.0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        len = axisalignedbb.maxZ - axisalignedbb.minZ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (len < 0) maxZ = minZ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        if (len > 64) maxZ = minZ + 64.0;
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 15:00:00 +10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        this.bb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-02 17:53:34 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+        // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-22 09:00:00 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 08:06:32 +11:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -2933,6 +3372,11 @@
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                     vec3d = vec3d.add(vec3d1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                     ++k1;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                 }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                                // CraftBukkit start - store last lava contact location
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                                if (tag == TagsFluid.LAVA) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                                    this.lastLavaContact = blockposition_mutableblockposition.immutable();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                                }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+                                // CraftBukkit end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                             }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                         }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                     }
							 |