Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-22 06:20:06 +01:00
73 Zeilen
3.3 KiB
Diff
73 Zeilen
3.3 KiB
Diff
|
--- 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.event.entity.EntityPortalEnterEvent;
|
||
|
+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() {
|
||
|
@@ -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); // CraftBukkit
|
||
|
}
|
||
|
}
|