net.minecraft.world.level.portal
This commit is contained in:
@@ -1,149 +0,0 @@
|
||||
--- a/net/minecraft/world/level/portal/PortalForcer.java
|
||||
+++ b/net/minecraft/world/level/portal/PortalForcer.java
|
||||
@@ -42,34 +42,52 @@
|
||||
this.level = world;
|
||||
}
|
||||
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Paper
|
||||
public Optional<BlockPos> findClosestPortalPosition(BlockPos pos, boolean destIsNether, WorldBorder worldBorder) {
|
||||
+ // CraftBukkit start
|
||||
+ return this.findClosestPortalPosition(pos, worldBorder, destIsNether ? 16 : 128); // Search Radius
|
||||
+ }
|
||||
+
|
||||
+ public Optional<BlockPos> findClosestPortalPosition(BlockPos blockposition, WorldBorder worldborder, int i) {
|
||||
PoiManager villageplace = this.level.getPoiManager();
|
||||
- int i = destIsNether ? 16 : 128;
|
||||
+ // int i = flag ? 16 : 128;
|
||||
+ // CraftBukkit end
|
||||
|
||||
- villageplace.ensureLoadedAndValid(this.level, pos, i);
|
||||
- Stream stream = villageplace.getInSquare((holder) -> {
|
||||
+ villageplace.ensureLoadedAndValid(this.level, blockposition, i);
|
||||
+ Stream<BlockPos> stream = villageplace.getInSquare((holder) -> { // CraftBukkit - decompile error
|
||||
return holder.is(PoiTypes.NETHER_PORTAL);
|
||||
- }, pos, i, PoiManager.Occupancy.ANY).map(PoiRecord::getPos);
|
||||
+ }, blockposition, i, PoiManager.Occupancy.ANY).map(PoiRecord::getPos);
|
||||
|
||||
- Objects.requireNonNull(worldBorder);
|
||||
- return stream.filter(worldBorder::isWithinBounds).filter((blockposition1) -> {
|
||||
+ Objects.requireNonNull(worldborder);
|
||||
+ return stream.filter(worldborder::isWithinBounds).filter(pos -> !(this.level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> pos.getY() >= v))).filter((blockposition1) -> { // Paper - Configurable nether ceiling damage
|
||||
return this.level.getBlockState(blockposition1).hasProperty(BlockStateProperties.HORIZONTAL_AXIS);
|
||||
- }).min(Comparator.comparingDouble((blockposition1) -> {
|
||||
- return blockposition1.distSqr(pos);
|
||||
+ }).min(Comparator.comparingDouble((BlockPos blockposition1) -> { // CraftBukkit - decompile error
|
||||
+ return blockposition1.distSqr(blockposition);
|
||||
}).thenComparingInt(Vec3i::getY));
|
||||
}
|
||||
|
||||
public Optional<BlockUtil.FoundRectangle> createPortal(BlockPos pos, Direction.Axis axis) {
|
||||
- Direction enumdirection = Direction.get(Direction.AxisDirection.POSITIVE, axis);
|
||||
+ // CraftBukkit start
|
||||
+ return this.createPortal(pos, axis, null, 16);
|
||||
+ }
|
||||
+
|
||||
+ public Optional<BlockUtil.FoundRectangle> createPortal(BlockPos blockposition, Direction.Axis enumdirection_enumaxis, net.minecraft.world.entity.Entity entity, int createRadius) {
|
||||
+ // CraftBukkit end
|
||||
+ Direction enumdirection = Direction.get(Direction.AxisDirection.POSITIVE, enumdirection_enumaxis);
|
||||
double d0 = -1.0D;
|
||||
BlockPos blockposition1 = null;
|
||||
double d1 = -1.0D;
|
||||
BlockPos blockposition2 = null;
|
||||
WorldBorder worldborder = this.level.getWorldBorder();
|
||||
int i = Math.min(this.level.getMaxY(), this.level.getMinY() + this.level.getLogicalHeight() - 1);
|
||||
+ // Paper start - Configurable nether ceiling damage; make sure the max height doesn't exceed the void damage height
|
||||
+ if (this.level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.enabled()) {
|
||||
+ i = Math.min(i, this.level.paperConfig().environment.netherCeilingVoidDamageHeight.intValue() - 1);
|
||||
+ }
|
||||
+ // Paper end - Configurable nether ceiling damage
|
||||
boolean flag = true;
|
||||
- BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable();
|
||||
- Iterator iterator = BlockPos.spiralAround(pos, 16, Direction.EAST, Direction.SOUTH).iterator();
|
||||
+ BlockPos.MutableBlockPos blockposition_mutableblockposition = blockposition.mutable();
|
||||
+ Iterator iterator = BlockPos.spiralAround(blockposition, createRadius, Direction.EAST, Direction.SOUTH).iterator(); // CraftBukkit
|
||||
|
||||
int j;
|
||||
int k;
|
||||
@@ -95,7 +113,7 @@
|
||||
if (i1 <= 0 || i1 >= 3) {
|
||||
blockposition_mutableblockposition1.setY(k);
|
||||
if (this.canHostFrame(blockposition_mutableblockposition1, blockposition_mutableblockposition, enumdirection, 0)) {
|
||||
- double d2 = pos.distSqr(blockposition_mutableblockposition1);
|
||||
+ double d2 = blockposition.distSqr(blockposition_mutableblockposition1);
|
||||
|
||||
if (this.canHostFrame(blockposition_mutableblockposition1, blockposition_mutableblockposition, enumdirection, -1) && this.canHostFrame(blockposition_mutableblockposition1, blockposition_mutableblockposition, enumdirection, 1) && (d0 == -1.0D || d0 > d2)) {
|
||||
d0 = d2;
|
||||
@@ -122,6 +140,7 @@
|
||||
int j1;
|
||||
int k1;
|
||||
|
||||
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.level); // CraftBukkit - Use BlockStateListPopulator
|
||||
if (d0 == -1.0D) {
|
||||
j1 = Math.max(this.level.getMinY() - -1, 70);
|
||||
k1 = i - 9;
|
||||
@@ -129,7 +148,7 @@
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
- blockposition1 = (new BlockPos(pos.getX() - enumdirection.getStepX() * 1, Mth.clamp(pos.getY(), j1, k1), pos.getZ() - enumdirection.getStepZ() * 1)).immutable();
|
||||
+ blockposition1 = (new BlockPos(blockposition.getX() - enumdirection.getStepX() * 1, Mth.clamp(blockposition.getY(), j1, k1), blockposition.getZ() - enumdirection.getStepZ() * 1)).immutable();
|
||||
blockposition1 = worldborder.clampToBounds(blockposition1);
|
||||
Direction enumdirection1 = enumdirection.getClockWise();
|
||||
|
||||
@@ -139,7 +158,7 @@
|
||||
BlockState iblockdata = i1 < 0 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState();
|
||||
|
||||
blockposition_mutableblockposition.setWithOffset(blockposition1, l * enumdirection.getStepX() + k * enumdirection1.getStepX(), i1, l * enumdirection.getStepZ() + k * enumdirection1.getStepZ());
|
||||
- this.level.setBlockAndUpdate(blockposition_mutableblockposition, iblockdata);
|
||||
+ blockList.setBlock(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,20 +168,30 @@
|
||||
for (k1 = -1; k1 < 4; ++k1) {
|
||||
if (j1 == -1 || j1 == 2 || k1 == -1 || k1 == 3) {
|
||||
blockposition_mutableblockposition.setWithOffset(blockposition1, j1 * enumdirection.getStepX(), k1, j1 * enumdirection.getStepZ());
|
||||
- this.level.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3);
|
||||
+ blockList.setBlock(blockposition_mutableblockposition, Blocks.OBSIDIAN.defaultBlockState(), 3); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- BlockState iblockdata1 = (BlockState) Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, axis);
|
||||
+ BlockState iblockdata1 = (BlockState) Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, enumdirection_enumaxis);
|
||||
|
||||
for (k1 = 0; k1 < 2; ++k1) {
|
||||
for (j = 0; j < 3; ++j) {
|
||||
blockposition_mutableblockposition.setWithOffset(blockposition1, k1 * enumdirection.getStepX(), j, k1 * enumdirection.getStepZ());
|
||||
- this.level.setBlock(blockposition_mutableblockposition, iblockdata1, 18);
|
||||
+ blockList.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.World bworld = this.level.getWorld();
|
||||
+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR);
|
||||
+
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ blockList.updateList();
|
||||
+ // CraftBukkit end
|
||||
return Optional.of(new BlockUtil.FoundRectangle(blockposition1.immutable(), 2, 3));
|
||||
}
|
||||
|
||||
@@ -178,6 +207,13 @@
|
||||
for (int j = -1; j < 3; ++j) {
|
||||
for (int k = -1; k < 4; ++k) {
|
||||
temp.setWithOffset(pos, portalDirection.getStepX() * j + enumdirection1.getStepX() * distanceOrthogonalToPortal, k, portalDirection.getStepZ() * j + enumdirection1.getStepZ() * distanceOrthogonalToPortal);
|
||||
+ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed
|
||||
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits) {
|
||||
+ if (!this.level.getBlockState(temp).isDestroyable()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed
|
||||
if (k < 0 && !this.level.getBlockState(temp).isSolid()) {
|
||||
return false;
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
--- a/net/minecraft/world/level/portal/PortalShape.java
|
||||
+++ b/net/minecraft/world/level/portal/PortalShape.java
|
||||
@@ -23,6 +23,11 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
||||
+import org.bukkit.event.world.PortalCreateEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PortalShape {
|
||||
|
||||
private static final int MIN_WIDTH = 2;
|
||||
@@ -40,14 +45,18 @@
|
||||
private final BlockPos bottomLeft;
|
||||
private final int height;
|
||||
private final int width;
|
||||
+ // CraftBukkit start - add field
|
||||
+ private final BlockStateListPopulator blocks;
|
||||
|
||||
- private PortalShape(Direction.Axis axis, int foundPortalBlocks, Direction negativeDir, BlockPos lowerCorner, int width, int height) {
|
||||
- this.axis = axis;
|
||||
- this.numPortalBlocks = foundPortalBlocks;
|
||||
- this.rightDir = negativeDir;
|
||||
- this.bottomLeft = lowerCorner;
|
||||
- this.width = width;
|
||||
- this.height = height;
|
||||
+ private PortalShape(Direction.Axis enumdirection_enumaxis, int i, Direction enumdirection, BlockPos blockposition, int j, int k, BlockStateListPopulator blocks) {
|
||||
+ this.blocks = blocks;
|
||||
+ // CraftBukkit end
|
||||
+ this.axis = enumdirection_enumaxis;
|
||||
+ this.numPortalBlocks = i;
|
||||
+ this.rightDir = enumdirection;
|
||||
+ this.bottomLeft = blockposition;
|
||||
+ this.width = j;
|
||||
+ this.height = k;
|
||||
}
|
||||
|
||||
public static Optional<PortalShape> findEmptyPortalShape(LevelAccessor world, BlockPos pos, Direction.Axis firstCheckedAxis) {
|
||||
@@ -69,110 +78,118 @@
|
||||
}
|
||||
|
||||
public static PortalShape findAnyShape(BlockGetter world, BlockPos pos, Direction.Axis axis) {
|
||||
+ BlockStateListPopulator blocks = new BlockStateListPopulator(((LevelAccessor) world).getMinecraftWorld()); // CraftBukkit
|
||||
Direction enumdirection = axis == Direction.Axis.X ? Direction.WEST : Direction.SOUTH;
|
||||
- BlockPos blockposition1 = PortalShape.calculateBottomLeft(world, enumdirection, pos);
|
||||
+ BlockPos blockposition1 = PortalShape.calculateBottomLeft(world, enumdirection, pos, blocks); // CraftBukkit
|
||||
|
||||
if (blockposition1 == null) {
|
||||
- return new PortalShape(axis, 0, enumdirection, pos, 0, 0);
|
||||
+ return new PortalShape(axis, 0, enumdirection, pos, 0, 0, blocks); // CraftBukkit
|
||||
} else {
|
||||
- int i = PortalShape.calculateWidth(world, blockposition1, enumdirection);
|
||||
+ int i = PortalShape.calculateWidth(world, blockposition1, enumdirection, blocks); // CraftBukkit
|
||||
|
||||
if (i == 0) {
|
||||
- return new PortalShape(axis, 0, enumdirection, blockposition1, 0, 0);
|
||||
+ return new PortalShape(axis, 0, enumdirection, blockposition1, 0, 0, blocks); // CraftBukkit
|
||||
} else {
|
||||
MutableInt mutableint = new MutableInt();
|
||||
- int j = PortalShape.calculateHeight(world, blockposition1, enumdirection, i, mutableint);
|
||||
+ int j = PortalShape.calculateHeight(world, blockposition1, enumdirection, i, mutableint, blocks); // CraftBukkit
|
||||
|
||||
- return new PortalShape(axis, mutableint.getValue(), enumdirection, blockposition1, i, j);
|
||||
+ return new PortalShape(axis, mutableint.getValue(), enumdirection, blockposition1, i, j, blocks); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
- private static BlockPos calculateBottomLeft(BlockGetter world, Direction direction, BlockPos pow) {
|
||||
- for (int i = Math.max(world.getMinY(), pow.getY() - 21); pow.getY() > i && PortalShape.isEmpty(world.getBlockState(pow.below())); pow = pow.below()) {
|
||||
+ private static BlockPos calculateBottomLeft(BlockGetter iblockaccess, Direction enumdirection, BlockPos blockposition, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
+ for (int i = Math.max(iblockaccess.getMinY(), blockposition.getY() - 21); blockposition.getY() > i && PortalShape.isEmpty(iblockaccess.getBlockState(blockposition.below())); blockposition = blockposition.below()) {
|
||||
;
|
||||
}
|
||||
|
||||
- Direction enumdirection1 = direction.getOpposite();
|
||||
- int j = PortalShape.getDistanceUntilEdgeAboveFrame(world, pow, enumdirection1) - 1;
|
||||
+ Direction enumdirection1 = enumdirection.getOpposite();
|
||||
+ int j = PortalShape.getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection1, blocks) - 1; // CraftBukkit
|
||||
|
||||
- return j < 0 ? null : pow.relative(enumdirection1, j);
|
||||
+ return j < 0 ? null : blockposition.relative(enumdirection1, j);
|
||||
}
|
||||
|
||||
- private static int calculateWidth(BlockGetter world, BlockPos lowerCorner, Direction negativeDir) {
|
||||
- int i = PortalShape.getDistanceUntilEdgeAboveFrame(world, lowerCorner, negativeDir);
|
||||
+ private static int calculateWidth(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
+ int i = PortalShape.getDistanceUntilEdgeAboveFrame(iblockaccess, blockposition, enumdirection, blocks); // CraftBukkit
|
||||
|
||||
return i >= 2 && i <= 21 ? i : 0;
|
||||
}
|
||||
|
||||
- private static int getDistanceUntilEdgeAboveFrame(BlockGetter world, BlockPos lowerCorner, Direction negativeDir) {
|
||||
+ private static int getDistanceUntilEdgeAboveFrame(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int i = 0; i <= 21; ++i) {
|
||||
- blockposition_mutableblockposition.set(lowerCorner).move(negativeDir, i);
|
||||
- BlockState iblockdata = world.getBlockState(blockposition_mutableblockposition);
|
||||
+ blockposition_mutableblockposition.set(blockposition).move(enumdirection, i);
|
||||
+ BlockState iblockdata = iblockaccess.getBlockState(blockposition_mutableblockposition);
|
||||
|
||||
if (!PortalShape.isEmpty(iblockdata)) {
|
||||
- if (PortalShape.FRAME.test(iblockdata, world, blockposition_mutableblockposition)) {
|
||||
+ if (PortalShape.FRAME.test(iblockdata, iblockaccess, blockposition_mutableblockposition)) {
|
||||
+ blocks.setBlock(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit - lower left / right
|
||||
return i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
- BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition.move(Direction.DOWN));
|
||||
+ BlockState iblockdata1 = iblockaccess.getBlockState(blockposition_mutableblockposition.move(Direction.DOWN));
|
||||
|
||||
- if (!PortalShape.FRAME.test(iblockdata1, world, blockposition_mutableblockposition)) {
|
||||
+ if (!PortalShape.FRAME.test(iblockdata1, iblockaccess, blockposition_mutableblockposition)) {
|
||||
break;
|
||||
}
|
||||
+ blocks.setBlock(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit - bottom row
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
- private static int calculateHeight(BlockGetter world, BlockPos lowerCorner, Direction negativeDir, int width, MutableInt foundPortalBlocks) {
|
||||
- BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
- int j = PortalShape.getDistanceUntilTop(world, lowerCorner, negativeDir, blockposition_mutableblockposition, width, foundPortalBlocks);
|
||||
+ private static int calculateHeight(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, int i, MutableInt mutableint, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
+ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
+ int j = PortalShape.getDistanceUntilTop(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, mutableint, blocks); // CraftBukkit
|
||||
|
||||
- return j >= 3 && j <= 21 && PortalShape.hasTopFrame(world, lowerCorner, negativeDir, blockposition_mutableblockposition, width, j) ? j : 0;
|
||||
+ return j >= 3 && j <= 21 && PortalShape.hasTopFrame(iblockaccess, blockposition, enumdirection, blockposition_mutableblockposition, i, j, blocks) ? j : 0; // CraftBukkit
|
||||
}
|
||||
|
||||
- private static boolean hasTopFrame(BlockGetter world, BlockPos lowerCorner, Direction direction, BlockPos.MutableBlockPos pos, int width, int height) {
|
||||
- for (int k = 0; k < width; ++k) {
|
||||
- BlockPos.MutableBlockPos blockposition_mutableblockposition1 = pos.set(lowerCorner).move(Direction.UP, height).move(direction, k);
|
||||
+ private static boolean hasTopFrame(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockPos.MutableBlockPos blockposition_mutableblockposition, int i, int j, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
+ for (int k = 0; k < i; ++k) {
|
||||
+ BlockPos.MutableBlockPos blockposition_mutableblockposition1 = blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, k);
|
||||
|
||||
- if (!PortalShape.FRAME.test(world.getBlockState(blockposition_mutableblockposition1), world, blockposition_mutableblockposition1)) {
|
||||
+ if (!PortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition1), iblockaccess, blockposition_mutableblockposition1)) {
|
||||
return false;
|
||||
}
|
||||
+ blocks.setBlock(blockposition_mutableblockposition1, iblockaccess.getBlockState(blockposition_mutableblockposition1), 18); // CraftBukkit - upper row
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
- private static int getDistanceUntilTop(BlockGetter world, BlockPos lowerCorner, Direction negativeDir, BlockPos.MutableBlockPos pos, int width, MutableInt foundPortalBlocks) {
|
||||
+ private static int getDistanceUntilTop(BlockGetter iblockaccess, BlockPos blockposition, Direction enumdirection, BlockPos.MutableBlockPos blockposition_mutableblockposition, int i, MutableInt mutableint, BlockStateListPopulator blocks) { // CraftBukkit
|
||||
for (int j = 0; j < 21; ++j) {
|
||||
- pos.set(lowerCorner).move(Direction.UP, j).move(negativeDir, -1);
|
||||
- if (!PortalShape.FRAME.test(world.getBlockState(pos), world, pos)) {
|
||||
+ blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, -1);
|
||||
+ if (!PortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition), iblockaccess, blockposition_mutableblockposition)) {
|
||||
return j;
|
||||
}
|
||||
|
||||
- pos.set(lowerCorner).move(Direction.UP, j).move(negativeDir, width);
|
||||
- if (!PortalShape.FRAME.test(world.getBlockState(pos), world, pos)) {
|
||||
+ blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, i);
|
||||
+ if (!PortalShape.FRAME.test(iblockaccess.getBlockState(blockposition_mutableblockposition), iblockaccess, blockposition_mutableblockposition)) {
|
||||
return j;
|
||||
}
|
||||
|
||||
- for (int k = 0; k < width; ++k) {
|
||||
- pos.set(lowerCorner).move(Direction.UP, j).move(negativeDir, k);
|
||||
- BlockState iblockdata = world.getBlockState(pos);
|
||||
+ for (int k = 0; k < i; ++k) {
|
||||
+ blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, k);
|
||||
+ BlockState iblockdata = iblockaccess.getBlockState(blockposition_mutableblockposition);
|
||||
|
||||
if (!PortalShape.isEmpty(iblockdata)) {
|
||||
return j;
|
||||
}
|
||||
|
||||
if (iblockdata.is(Blocks.NETHER_PORTAL)) {
|
||||
- foundPortalBlocks.increment();
|
||||
+ mutableint.increment();
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit start - left and right
|
||||
+ blocks.setBlock(blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, -1), iblockaccess.getBlockState(blockposition_mutableblockposition), 18);
|
||||
+ blocks.setBlock(blockposition_mutableblockposition.set(blockposition).move(Direction.UP, j).move(enumdirection, i), iblockaccess.getBlockState(blockposition_mutableblockposition), 18);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return 21;
|
||||
@@ -186,12 +203,28 @@
|
||||
return this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
|
||||
}
|
||||
|
||||
- public void createPortalBlocks(LevelAccessor world) {
|
||||
+ // CraftBukkit start - return boolean, add entity
|
||||
+ public boolean createPortalBlocks(LevelAccessor generatoraccess, Entity entity) {
|
||||
+ org.bukkit.World bworld = generatoraccess.getMinecraftWorld().getWorld();
|
||||
+
|
||||
+ // Copy below for loop
|
||||
BlockState iblockdata = (BlockState) Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, this.axis);
|
||||
|
||||
BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> {
|
||||
- world.setBlock(blockposition, iblockdata, 18);
|
||||
+ this.blocks.setBlock(blockposition, iblockdata, 18);
|
||||
});
|
||||
+
|
||||
+ PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) this.blocks.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE);
|
||||
+ generatoraccess.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> {
|
||||
+ generatoraccess.setBlock(blockposition, iblockdata, 18);
|
||||
+ });
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
@@ -1,71 +0,0 @@
|
||||
--- a/net/minecraft/world/level/portal/TeleportTransition.java
|
||||
+++ b/net/minecraft/world/level/portal/TeleportTransition.java
|
||||
@@ -8,26 +8,55 @@
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Relative;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
-public record TeleportTransition(ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set<Relative> relatives, TeleportTransition.PostTeleportTransition postTeleportTransition) {
|
||||
+public record TeleportTransition(ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set<Relative> relatives, TeleportTransition.PostTeleportTransition postTeleportTransition, PlayerTeleportEvent.TeleportCause cause) {
|
||||
|
||||
+ public TeleportTransition(ServerLevel newLevel, Vec3 position, Vec3 deltaMovement, float yRot, float xRot, boolean missingRespawnBlock, boolean asPassenger, Set<Relative> relatives, TeleportTransition.PostTeleportTransition postTeleportTransition) {
|
||||
+ this(newLevel, position, deltaMovement, yRot, xRot, missingRespawnBlock, asPassenger, relatives, postTeleportTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public TeleportTransition(PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ this(null, Vec3.ZERO, Vec3.ZERO, 0.0F, 0.0F, false, false, Set.of(), DO_NOTHING, cause);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static final TeleportTransition.PostTeleportTransition DO_NOTHING = (entity) -> {
|
||||
};
|
||||
public static final TeleportTransition.PostTeleportTransition PLAY_PORTAL_SOUND = TeleportTransition::playPortalSound;
|
||||
public static final TeleportTransition.PostTeleportTransition PLACE_PORTAL_TICKET = TeleportTransition::placePortalTicket;
|
||||
|
||||
public TeleportTransition(ServerLevel world, Vec3 pos, Vec3 velocity, float yaw, float pitch, TeleportTransition.PostTeleportTransition postDimensionTransition) {
|
||||
- this(world, pos, velocity, yaw, pitch, Set.of(), postDimensionTransition);
|
||||
+ // CraftBukkit start
|
||||
+ this(world, pos, velocity, yaw, pitch, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
}
|
||||
|
||||
+ public TeleportTransition(ServerLevel worldserver, Vec3 vec3d, Vec3 vec3d1, float f, float f1, TeleportTransition.PostTeleportTransition teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ this(worldserver, vec3d, vec3d1, f, f1, Set.of(), teleporttransition_a, cause);
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
public TeleportTransition(ServerLevel world, Vec3 pos, Vec3 velocity, float yaw, float pitch, Set<Relative> flags, TeleportTransition.PostTeleportTransition postDimensionTransition) {
|
||||
- this(world, pos, velocity, yaw, pitch, false, false, flags, postDimensionTransition);
|
||||
+ // CraftBukkit start
|
||||
+ this(world, pos, velocity, yaw, pitch, flags, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
}
|
||||
|
||||
+ public TeleportTransition(ServerLevel worldserver, Vec3 vec3d, Vec3 vec3d1, float f, float f1, Set<Relative> set, TeleportTransition.PostTeleportTransition teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ this(worldserver, vec3d, vec3d1, f, f1, false, false, set, teleporttransition_a, cause);
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
public TeleportTransition(ServerLevel world, Entity entity, TeleportTransition.PostTeleportTransition postDimensionTransition) {
|
||||
- this(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, 0.0F, 0.0F, false, false, Set.of(), postDimensionTransition);
|
||||
+ // CraftBukkit start
|
||||
+ this(world, entity, postDimensionTransition, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
}
|
||||
|
||||
+ public TeleportTransition(ServerLevel worldserver, Entity entity, TeleportTransition.PostTeleportTransition teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3.ZERO, worldserver.getSharedSpawnAngle(), 0.0F, false, false, Set.of(), teleporttransition_a, cause); // Paper - MC-200092 - fix first spawn pos yaw being ignored
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
private static void playPortalSound(Entity entity) {
|
||||
if (entity instanceof ServerPlayer entityplayer) {
|
||||
entityplayer.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
|
||||
@@ -40,7 +69,7 @@
|
||||
}
|
||||
|
||||
public static TeleportTransition missingRespawnBlock(ServerLevel world, Entity entity, TeleportTransition.PostTeleportTransition postDimensionTransition) {
|
||||
- return new TeleportTransition(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, 0.0F, 0.0F, true, false, Set.of(), postDimensionTransition);
|
||||
+ return new TeleportTransition(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, world.getSharedSpawnAngle(), 0.0F, true, false, Set.of(), postDimensionTransition); // Paper - MC-200092 - fix spawn pos yaw being ignored
|
||||
}
|
||||
|
||||
private static Vec3 findAdjustedSharedSpawnPos(ServerLevel world, Entity entity) {
|
||||
Reference in New Issue
Block a user