3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 07:10:10 +01:00
Paper/nms-patches/BlockPortalShape.patch

82 Zeilen
4.1 KiB
Diff

2020-08-11 23:00:00 +02:00
--- a/net/minecraft/server/BlockPortalShape.java
+++ b/net/minecraft/server/BlockPortalShape.java
@@ -4,6 +4,13 @@
import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.event.CraftPortalEvent;
2020-08-11 23:00:00 +02:00
+import org.bukkit.event.world.PortalCreateEvent;
+// CraftBukkit end
+
public class BlockPortalShape {
private static final BlockBase.e a = (iblockdata, iblockaccess, blockposition) -> {
@@ -17,6 +24,7 @@
private BlockPosition position;
private int height;
private int width;
+ java.util.List<org.bukkit.block.BlockState> blocks = new java.util.ArrayList<org.bukkit.block.BlockState>(); // CraftBukkit - add field
public static Optional<BlockPortalShape> a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
return a(generatoraccess, blockposition, (blockportalshape) -> {
@@ -81,6 +89,7 @@
if (!a(iblockdata)) {
if (BlockPortalShape.a.test(iblockdata, this.b, blockposition_mutableblockposition)) {
+ blocks.add(CraftBlock.at(this.b, blockposition_mutableblockposition).getState()); // CraftBukkit
return i;
}
break;
@@ -152,12 +161,30 @@
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.b.getMinecraftWorld().getWorld();
+
+ // Copy below for loop
IBlockData iblockdata = (IBlockData) Blocks.NETHER_PORTAL.getBlockData().set(BlockPortal.AXIS, this.c);
BlockPosition.a(this.position, this.position.shift(EnumDirection.UP, this.height - 1).shift(this.d, this.width - 1)).forEach((blockposition) -> {
+ CraftBlockState state = CraftBlockState.getBlockState(this.b.getMinecraftWorld(), blockposition, 18);
+ state.setData(iblockdata);
+ blocks.add(state);
+ });
+
+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, null, PortalCreateEvent.CreateReason.FIRE);
+ this.b.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
+ BlockPosition.a(this.position, this.position.shift(EnumDirection.UP, this.height - 1).shift(this.d, this.width - 1)).forEach((blockposition) -> {
this.b.setTypeAndData(blockposition, iblockdata, 18);
});
+ return true; // CraftBukkit
}
public boolean c() {
@@ -194,7 +221,7 @@
return new Vec3D(d2, d3, d4);
}
- public static ShapeDetectorShape a(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1) {
+ public static ShapeDetectorShape a(WorldServer worldserver, BlockUtil.Rectangle blockutil_rectangle, EnumDirection.EnumAxis enumdirection_enumaxis, Vec3D vec3d, EntitySize entitysize, Vec3D vec3d1, float f, float f1, CraftPortalEvent portalEventInfo) { // CraftBukkit // PAIL rename toDetectorShape
BlockPosition blockposition = blockutil_rectangle.origin;
IBlockData iblockdata = worldserver.getType(blockposition);
EnumDirection.EnumAxis enumdirection_enumaxis1 = (EnumDirection.EnumAxis) iblockdata.get(BlockProperties.E);
2020-08-11 23:00:00 +02:00
@@ -208,6 +235,6 @@
boolean flag = enumdirection_enumaxis1 == EnumDirection.EnumAxis.X;
Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2));
- return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1);
+ return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1, worldserver, portalEventInfo); // CraftBukkit
2020-08-11 23:00:00 +02:00
}
}