Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/BlockPortal.patch

145 Zeilen
6.5 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockPortal.java
+++ b/net/minecraft/server/BlockPortal.java
2016-05-10 13:47:39 +02:00
@@ -4,6 +4,9 @@
import java.util.Random;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
2015-02-26 23:41:06 +01:00
+import org.bukkit.event.world.PortalCreateEvent; // CraftBukkit
+
public class BlockPortal extends BlockHalfTransparent {
2015-02-26 23:41:06 +01:00
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockStateEnum.of("axis", EnumDirection.EnumAxis.class, new EnumDirection.EnumAxis[] { EnumDirection.EnumAxis.X, EnumDirection.EnumAxis.Z});
2016-05-10 13:47:39 +02:00
@@ -43,7 +46,8 @@
}
2017-05-19 13:00:13 +02:00
if (i > 0 && !world.getType(blockposition1.up()).l()) {
2016-02-29 22:32:46 +01:00
- Entity entity = ItemMonsterEgg.a(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D);
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
2016-02-29 22:32:46 +01:00
+ Entity entity = ItemMonsterEgg.spawnCreature(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
if (entity != null) {
2017-06-08 10:00:00 +02:00
entity.portalCooldown = entity.aM();
2016-05-10 13:47:39 +02:00
@@ -70,14 +74,16 @@
2015-02-26 23:41:06 +01:00
BlockPortal.Shape blockportal_shape = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.X);
2015-02-26 23:41:06 +01:00
if (blockportal_shape.d() && blockportal_shape.e == 0) {
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;
} else {
2015-02-26 23:41:06 +01:00
BlockPortal.Shape blockportal_shape1 = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.Z);
2015-02-26 23:41:06 +01:00
if (blockportal_shape1.d() && blockportal_shape1.e == 0) {
2015-07-30 08:56:52 +02:00
- blockportal_shape1.createPortal();
- return true;
2015-07-30 08:56:52 +02:00
+ return blockportal_shape1.createPortal();
+ // return true;
+ // CraftBukkit end
} else {
return false;
}
2016-05-10 13:47:39 +02:00
@@ -108,6 +114,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
2017-06-08 10:00:00 +02:00
if (!entity.isPassenger() && !entity.isVehicle() && entity.bf()) {
+ // 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
}
2017-05-14 04:00:00 +02:00
@@ -216,6 +226,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
public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
this.a = world;
2017-05-14 04:00:00 +02:00
@@ -274,6 +285,10 @@
2015-02-26 23:41:06 +01:00
}
protected int c() {
+ // CraftBukkit start
+ this.blocks.clear();
+ org.bukkit.World bworld = this.a.getWorld();
+ // CraftBukkit end
int i;
label56:
2017-05-14 04:00:00 +02:00
@@ -294,11 +309,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);
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ // 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);
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ // CraftBukkit end
}
}
}
2017-05-14 04:00:00 +02:00
@@ -308,6 +333,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);
2015-02-26 23:41:06 +01:00
+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
+ // CraftBukkit end
}
}
2017-05-14 04:00:00 +02:00
@@ -329,7 +359,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() {
2015-02-26 23:41:06 +01:00
+ org.bukkit.World bworld = this.a.getWorld();
+
+ // 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);
+ this.a.getServer().getPluginManager().callEvent(event);
+
+ 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
2017-05-14 04:00:00 +02:00
@@ -338,6 +388,7 @@
2015-02-26 23:41:06 +01:00
}
}
+ return true; // CraftBukkit
}
}
}