mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 22:14:40 +01:00
138 lines
6 KiB
Diff
138 lines
6 KiB
Diff
--- a/net/minecraft/server/BlockPortal.java
|
|
+++ b/net/minecraft/server/BlockPortal.java
|
|
@@ -4,6 +4,12 @@
|
|
import java.util.Random;
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
|
+import org.bukkit.event.entity.EntityPortalEnterEvent;
|
|
+import org.bukkit.event.world.PortalCreateEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class BlockPortal extends Block {
|
|
|
|
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.D;
|
|
@@ -34,7 +40,8 @@
|
|
}
|
|
|
|
if (world.getType(blockposition).a((IBlockAccess) world, blockposition, EntityTypes.ZOMBIE_PIGMAN)) {
|
|
- Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false);
|
|
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
|
|
+ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
|
|
|
|
if (entity != null) {
|
|
entity.portalCooldown = entity.aW();
|
|
@@ -48,8 +55,10 @@
|
|
BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition);
|
|
|
|
if (blockportal_shape != null) {
|
|
- blockportal_shape.createPortal();
|
|
- return true;
|
|
+ // CraftBukkit start - return portalcreator
|
|
+ return blockportal_shape.createPortal();
|
|
+ // return true;
|
|
+ // CraftBukkit end
|
|
} else {
|
|
return false;
|
|
}
|
|
@@ -85,6 +94,10 @@
|
|
@Override
|
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
|
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
|
|
entity.c(blockposition);
|
|
}
|
|
|
|
@@ -177,6 +190,7 @@
|
|
private BlockPosition position;
|
|
private int height;
|
|
private int width;
|
|
+ java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>(); // CraftBukkit - add field
|
|
|
|
public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
|
|
this.a = generatoraccess;
|
|
@@ -235,6 +249,9 @@
|
|
}
|
|
|
|
protected int c() {
|
|
+ // CraftBukkit start
|
|
+ this.blocks.clear();
|
|
+ // CraftBukkit end
|
|
int i;
|
|
|
|
label56:
|
|
@@ -257,11 +274,21 @@
|
|
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);
|
|
+ blocks.add(CraftBlock.at(this.a, pos));
|
|
+ // CraftBukkit end
|
|
}
|
|
} else if (i == this.width - 1) {
|
|
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);
|
|
+ blocks.add(CraftBlock.at(this.a, pos));
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
}
|
|
@@ -271,6 +298,11 @@
|
|
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
|
|
this.height = 0;
|
|
break;
|
|
+ // CraftBukkit start - add the block to our list
|
|
+ } else {
|
|
+ BlockPosition pos = this.position.shift(this.c, i).up(this.height);
|
|
+ blocks.add(CraftBlock.at(this.a, pos));
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
@@ -294,7 +326,27 @@
|
|
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
|
|
}
|
|
|
|
- public void createPortal() {
|
|
+ // CraftBukkit start - return boolean
|
|
+ public boolean createPortal() {
|
|
+ org.bukkit.World bworld = this.a.getMinecraftWorld().getWorld();
|
|
+
|
|
+ // Copy below for loop
|
|
+ for (int i = 0; i < this.width; ++i) {
|
|
+ BlockPosition blockposition = this.position.shift(this.c, i);
|
|
+
|
|
+ for (int j = 0; j < this.height; ++j) {
|
|
+ BlockPosition pos = blockposition.up(j);
|
|
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE);
|
|
+ this.a.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
for (int i = 0; i < this.width; ++i) {
|
|
BlockPosition blockposition = this.position.shift(this.c, i);
|
|
|
|
@@ -303,6 +355,7 @@
|
|
}
|
|
}
|
|
|
|
+ return true; // CraftBukkit
|
|
}
|
|
|
|
private boolean g() {
|