Paper/nms-patches/BlockPortal.patch

139 lines
5.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
2018-07-15 02:00:00 +02:00
@@ -4,6 +4,12 @@
import java.util.Random;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2018-07-15 02:00:00 +02:00
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+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 {
2018-07-15 02:00:00 +02:00
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.y;
@@ -37,7 +43,8 @@
}
2018-07-15 02:00:00 +02:00
if (i > 0 && !world.getType(blockposition1.up()).isOccluding()) {
- Entity entity = EntityTypes.ZOMBIE_PIGMAN.a(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false);
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
2018-07-15 02:00:00 +02:00
+ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
if (entity != null) {
2018-07-15 02:00:00 +02:00
entity.portalCooldown = entity.aQ();
@@ -55,8 +62,10 @@
BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition);
2018-07-15 02:00:00 +02:00
if (blockportal_shape != null) {
2015-07-30 08:56:52 +02:00
- blockportal_shape.createPortal();
- return true;
+ // CraftBukkit start - return portalcreator
2015-07-30 08:56:52 +02:00
+ return blockportal_shape.createPortal();
+ // return true;
2018-07-15 02:00:00 +02:00
+ // CraftBukkit end
} else {
2018-07-15 02:00:00 +02:00
return false;
}
@@ -93,6 +102,10 @@
2018-07-15 02:00:00 +02:00
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if (!entity.isPassenger() && !entity.isVehicle() && entity.bm()) {
+ // 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
2016-02-29 22:32:46 +01:00
entity.e(blockposition);
2015-02-26 23:41:06 +01:00
}
2018-07-15 02:00:00 +02:00
@@ -193,6 +206,7 @@
2015-07-30 08:56:52 +02:00
private BlockPosition position;
private int height;
private int width;
2015-02-26 23:41:06 +01:00
+ java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>(); // CraftBukkit - add field
2018-07-15 02:00:00 +02:00
public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
this.a = generatoraccess;
@@ -251,6 +265,9 @@
2015-02-26 23:41:06 +01:00
}
protected int c() {
+ // CraftBukkit start
+ this.blocks.clear();
+ // CraftBukkit end
int i;
label56:
2018-07-15 02:00:00 +02:00
@@ -273,11 +290,21 @@
2015-02-26 23:41:06 +01:00
block = this.a.getType(blockposition.shift(this.d)).getBlock();
if (block != Blocks.OBSIDIAN) {
break label56;
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = blockposition.shift(this.d);
2018-07-15 02:00:00 +02:00
+ blocks.add(CraftBlock.at(this.a, pos));
2015-02-26 23:41:06 +01:00
+ // CraftBukkit end
}
2015-07-30 08:56:52 +02:00
} else if (i == this.width - 1) {
2015-02-26 23:41:06 +01:00
block = this.a.getType(blockposition.shift(this.c)).getBlock();
if (block != Blocks.OBSIDIAN) {
break label56;
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = blockposition.shift(this.c);
2018-07-15 02:00:00 +02:00
+ blocks.add(CraftBlock.at(this.a, pos));
2015-02-26 23:41:06 +01:00
+ // CraftBukkit end
}
}
}
2018-07-15 02:00:00 +02:00
@@ -287,6 +314,11 @@
2015-07-30 08:56:52 +02:00
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
this.height = 0;
2015-02-26 23:41:06 +01:00
break;
+ // CraftBukkit start - add the block to our list
+ } else {
2015-07-30 08:56:52 +02:00
+ BlockPosition pos = this.position.shift(this.c, i).up(this.height);
2018-07-15 02:00:00 +02:00
+ blocks.add(CraftBlock.at(this.a, pos));
2015-02-26 23:41:06 +01:00
+ // CraftBukkit end
}
}
2018-07-15 02:00:00 +02:00
@@ -310,7 +342,27 @@
2015-07-30 08:56:52 +02:00
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
}
2015-07-30 08:56:52 +02:00
- public void createPortal() {
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start - return boolean
2015-07-30 08:56:52 +02:00
+ public boolean createPortal() {
2018-07-15 02:00:00 +02:00
+ org.bukkit.World bworld = this.a.getMinecraftWorld().getWorld();
2015-02-26 23:41:06 +01:00
+
+ // Copy below for loop
2015-07-30 08:56:52 +02:00
+ for (int i = 0; i < this.width; ++i) {
+ BlockPosition blockposition = this.position.shift(this.c, i);
2015-02-26 23:41:06 +01:00
+
2015-07-30 08:56:52 +02:00
+ for (int j = 0; j < this.height; ++j) {
2015-02-26 23:41:06 +01:00
+ BlockPosition pos = blockposition.up(j);
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ }
+ }
+
+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE);
2018-07-15 02:00:00 +02:00
+ this.a.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
2015-02-26 23:41:06 +01:00
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
2015-07-30 08:56:52 +02:00
for (int i = 0; i < this.width; ++i) {
BlockPosition blockposition = this.position.shift(this.c, i);
2015-02-26 23:41:06 +01:00
2018-07-15 02:00:00 +02:00
@@ -319,6 +371,7 @@
2015-02-26 23:41:06 +01:00
}
}
+ return true; // CraftBukkit
}
2018-07-15 02:00:00 +02:00
private boolean g() {