Paper/nms-patches/BlockPortal.patch

38 lines
1.9 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockPortal.java
+++ b/net/minecraft/server/BlockPortal.java
2020-08-11 23:00:00 +02:00
@@ -2,6 +2,13 @@
import java.util.Random;
2018-07-15 02:00:00 +02:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.block.CraftBlockState;
2018-07-15 02:00:00 +02:00
+import org.bukkit.event.entity.EntityPortalEnterEvent;
+import org.bukkit.event.world.PortalCreateEvent;
+// CraftBukkit end
+
2018-07-15 02:00:00 +02:00
public class BlockPortal extends Block {
2020-06-25 02:00:00 +02:00
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.E;
2020-08-11 23:00:00 +02:00
@@ -32,7 +39,8 @@
}
2020-06-25 02:00:00 +02:00
if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) {
- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false);
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
2020-06-25 02:00:00 +02:00
+ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
if (entity != null) {
2020-08-11 23:00:00 +02:00
entity.resetPortalCooldown();
@@ -54,6 +62,10 @@
2019-04-23 04:00:00 +02:00
@Override
2018-07-15 02:00:00 +02:00
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
2019-04-23 04:00:00 +02:00
if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {
+ // CraftBukkit start - Entity in portal
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
entity.d(blockposition);
2015-02-26 23:41:06 +01:00
}