Search in sources :

Example 1 with IntVector3

use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.

the class CommonMapController method onAddItemFrame.

private void onAddItemFrame(ItemFrame frame) {
    if (itemFrames.contains(frame.getEntityId())) {
        return;
    }
    itemFrames.put(frame.getEntityId(), new ItemFrameInfo(frame));
    // Load the chunk to the left/right of this item frame
    // If the display crosses chunk boundaries, this ensures those are loaded
    // TODO: Is onEntityAdded really the right place for this? Could cause recursive loading.
    BlockFace left_right = FaceUtil.rotate(frame.getFacing(), 2);
    IntVector3 pos = new IntVector3(frame.getLocation());
    IntVector3 pos_left = pos.add(left_right);
    IntVector3 pos_right = pos.subtract(left_right);
    if (pos.getChunkX() != pos_left.getChunkX() || pos.getChunkZ() != pos_left.getChunkZ()) {
        frame.getWorld().getChunkAt(pos_left.getChunkX(), pos_left.getChunkZ());
    }
    if (pos.getChunkX() != pos_right.getChunkX() || pos.getChunkZ() != pos_right.getChunkZ()) {
        frame.getWorld().getChunkAt(pos_right.getChunkX(), pos_right.getChunkZ());
    }
}
Also used : BlockFace(org.bukkit.block.BlockFace) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3)

Example 2 with IntVector3

use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.

the class CommonMapController method findNeighbours.

/**
 * Finds all connected neighbours of an item frame
 *
 * @param itemFrame
 */
private final List<IntVector3> findNeighbours(ItemFrame itemFrame) {
    HashSet<IntVector3> neighbours = new HashSet<IntVector3>();
    BlockFace facing = itemFrame.getFacing();
    IntVector3 itemFramePos = new IntVector3(itemFrame.getLocation());
    UUID itemFrameMapUUID = CommonMapUUIDStore.getMapUUID(getItemFrameItem(itemFrame));
    if (itemFrameMapUUID == null) {
        // no neighbours
        return Collections.emptyList();
    }
    // - Same ItemStack map UUID
    for (ItemFrame otherFrame : iterateItemFrames(itemFrame.getWorld())) {
        if (otherFrame == itemFrame) {
            continue;
        }
        if (otherFrame.getFacing() != facing) {
            continue;
        }
        IntVector3 otherFramePos = new IntVector3(otherFrame.getLocation());
        if (FaceUtil.isAlongX(facing)) {
            if (otherFramePos.x != itemFramePos.x) {
                continue;
            }
        } else {
            if (otherFramePos.z != itemFramePos.z) {
                continue;
            }
        }
        UUID otherFrameMapUUID = CommonMapUUIDStore.getMapUUID(getItemFrameItem(otherFrame));
        if (!itemFrameMapUUID.equals(otherFrameMapUUID)) {
            continue;
        }
        neighbours.add(otherFramePos);
    }
    // Make sure the neighbours result are a single contiguous blob
    // Islands (can not reach the input item frame) are removed
    BlockFace[] sides = { BlockFace.UP, BlockFace.DOWN, FaceUtil.rotate(facing, 2), FaceUtil.rotate(facing, -2) };
    List<IntVector3> pendingList = new ArrayList<IntVector3>(5);
    List<IntVector3> result = new ArrayList<IntVector3>(neighbours.size());
    pendingList.add(itemFramePos);
    do {
        IntVector3 pending = pendingList.remove(pendingList.size() - 1);
        for (BlockFace side : sides) {
            IntVector3 sidePoint = pending.add(side);
            if (neighbours.remove(sidePoint)) {
                pendingList.add(sidePoint);
                result.add(sidePoint);
            }
        }
    } while (!pendingList.isEmpty());
    return result;
}
Also used : BlockFace(org.bukkit.block.BlockFace) ArrayList(java.util.ArrayList) ItemFrame(org.bukkit.entity.ItemFrame) MapUUID(com.bergerkiller.bukkit.common.map.util.MapUUID) UUID(java.util.UUID) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 3 with IntVector3

use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.

the class EntityMoveHandler method moveImpl.

/**
 * This is the move function based on the original move function in the nms.Entity class.
 * It has been modified so it can run externally, outside the Entity class.
 * Calls to this.world.getCubes(this, this.getBoundingBox().b(a,b,c)) have been replaced with a callback.
 * This callback is getCollisions above, which is a modified copy of the world.getCubes function.
 *
 * @param movetype move type
 * @param d0 dx
 * @param d1 dy
 * @param d2 dz
 */
public void moveImpl(MoveType movetype, double d0, double d1, double d2) {
    entity = controller.getEntity();
    if (entity == null) {
        throw new IllegalStateException("Entity Controller is not attached to an Entity");
    }
    that = EntityHandle.createHandle(entity.getHandle());
    final Random this_random = that.getRandom();
    WorldHandle world = that.getWorld();
    // org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
    if (that.isNoclip()) {
        that.setBoundingBox(that.getBoundingBox().translate(d0, d1, d2));
        that.setPositionFromBoundingBox();
    } else {
        // We need to do that.regardless of whether or not we are moving thanks to portals
        try {
            if (this.blockActivationEnabled) {
                that.checkBlockCollisions();
            }
        } catch (Throwable throwable) {
            CrashReportHandle crashreport = CrashReportHandle.create(throwable, "Checking entity block collision");
            CrashReportSystemDetailsHandle crashreportsystemdetails = crashreport.getSystemDetails("Entity being checked for collision");
            that.appendEntityCrashDetails(crashreportsystemdetails);
            throw (RuntimeException) ReportedExceptionHandle.createNew(crashreport).getRaw();
        }
        // Check if we're moving
        if (d0 == 0 && d1 == 0 && d2 == 0 && that.isVehicle() && that.isPassenger()) {
            return;
        }
        // This logic is only >= 1.11.2
        if (CommonCapabilities.ENTITY_MOVE_VER2 && movetype == MoveType.PISTON) {
            long i = world.getTime();
            final double[] that_aI = EntityHandle.T.move_SomeArray.get(entity.getHandle());
            if (i != EntityHandle.T.move_SomeState.getLong(entity.getHandle())) {
                Arrays.fill(that_aI, 0.0D);
                EntityHandle.T.move_SomeState.setLong(entity.getHandle(), i);
            }
            int j;
            double d3;
            if (d0 != 0.0D) {
                j = EnumAxisHandle.X.ordinal();
                d3 = MathUtil.clamp(d0 + that_aI[j], -0.51D, 0.51D);
                d0 = d3 - that_aI[j];
                that_aI[j] = d3;
                if (Math.abs(d0) <= 9.999999747378752E-6D) {
                    return;
                }
            } else if (d1 != 0.0D) {
                j = EnumAxisHandle.Y.ordinal();
                d3 = MathUtil.clamp(d1 + that_aI[j], -0.51D, 0.51D);
                d1 = d3 - that_aI[j];
                that_aI[j] = d3;
                if (Math.abs(d1) <= 9.999999747378752E-6D) {
                    return;
                }
            } else {
                if (d2 == 0.0D) {
                    return;
                }
                j = EnumAxisHandle.Z.ordinal();
                d3 = MathUtil.clamp(d2 + that_aI[j], -0.51D, 0.51D);
                d2 = d3 - that_aI[j];
                that_aI[j] = d3;
                if (Math.abs(d2) <= 9.999999747378752E-6D) {
                    return;
                }
            }
        }
        world.method_profiler_begin("move");
        double d4 = that.getLocX();
        double d5 = that.getLocY();
        double d6 = that.getLocZ();
        if (that.isCollidingWithBlock()) {
            if (this.blockCollisionEnabled) {
                Vector multiplier = that.getBlockCollisionMultiplier();
                d0 *= multiplier.getX();
                d1 *= multiplier.getY();
                d2 *= multiplier.getZ();
                that.setMot(0.0, 0.0, 0.0);
            }
            that.setNotCollidingWithBlock();
        }
        double d7 = d0;
        double d8 = d1;
        double d9 = d2;
        if ((movetype == MoveType.SELF || movetype == MoveType.PLAYER) && that.isOnGround() && that.isSneaking() && that.isInstanceOf(EntityHumanHandle.T)) {
            for (; /* double d10 = 0.05D*/
            d0 != 0.0D && world.isNotCollidingWithBlocks(that, that.getBoundingBox().translate(d0, (double) (-that.getHeightOffset()), 0.0D)); d7 = d0) {
                if (d0 < 0.05D && d0 >= -0.05D) {
                    d0 = 0.0D;
                } else if (d0 > 0.0D) {
                    d0 -= 0.05D;
                } else {
                    d0 += 0.05D;
                }
            }
            for (; d2 != 0.0D && world.isNotCollidingWithBlocks(that, that.getBoundingBox().translate(0.0D, (double) (-that.getHeightOffset()), d2)); d9 = d2) {
                if (d2 < 0.05D && d2 >= -0.05D) {
                    d2 = 0.0D;
                } else if (d2 > 0.0D) {
                    d2 -= 0.05D;
                } else {
                    d2 += 0.05D;
                }
            }
            for (; d0 != 0.0D && d2 != 0.0D && world.isNotCollidingWithBlocks(that, that.getBoundingBox().translate(d0, (double) (-that.getHeightOffset()), d2)); d9 = d2) {
                if (d0 < 0.05D && d0 >= -0.05D) {
                    d0 = 0.0D;
                } else if (d0 > 0.0D) {
                    d0 -= 0.05D;
                } else {
                    d0 += 0.05D;
                }
                d7 = d0;
                if (d2 < 0.05D && d2 >= -0.05D) {
                    d2 = 0.0D;
                } else if (d2 > 0.0D) {
                    d2 -= 0.05D;
                } else {
                    d2 += 0.05D;
                }
            }
        }
        // Store old bounding box before changes to it are made
        AxisAlignedBBHandle axisalignedbb = that.getBoundingBox();
        if (d0 != 0.0D || d1 != 0.0D || d2 != 0.0D) {
            // BKCommonLib start
            // collision event handler
            shapeAccumulator.open(world_getCollisionShapes(that, d0, d1, d2));
            // BKCommonLib: add isEmpty() optimization
            if (!shapeAccumulator.isEmpty()) {
                if (d1 <= -1.0E-7D || d1 >= 1.0E-7D) {
                    d1 = VoxelShapeHandle.traceAxis(EnumAxisHandle.Y, that.getBoundingBox(), shapeAccumulator.stream(), d1);
                    if (d1 != 0.0D) {
                        that.setBoundingBox(that.getBoundingBox().translate(0.0D, d1, 0.0D));
                    }
                }
                if (d0 <= -1.0E-7D || d0 >= 1.0E-7D) {
                    d0 = VoxelShapeHandle.traceAxis(EnumAxisHandle.X, that.getBoundingBox(), shapeAccumulator.stream(), d0);
                    if (d0 != 0.0D) {
                        that.setBoundingBox(that.getBoundingBox().translate(d0, 0.0D, 0.0D));
                    }
                }
                if (d2 <= -1.0E-7D || d2 >= 1.0E-7D) {
                    d2 = VoxelShapeHandle.traceAxis(EnumAxisHandle.Z, that.getBoundingBox(), shapeAccumulator.stream(), d2);
                    if (d2 != 0.0D) {
                        that.setBoundingBox(that.getBoundingBox().translate(0.0D, 0.0D, d2));
                    }
                }
            } else {
                that.setBoundingBox(that.getBoundingBox().translate(d0, d1, d2));
            }
        }
        // CraftBukkit - decompile error
        boolean flag = that.isOnGround() || d1 != d8 && d1 < 0.0D;
        // NB: This code only executes with entities that are tall (have a head), like players
        if (that.getHeightOffset() > 0.0F && flag && (d7 != d0 || d9 != d2)) {
            double d12 = d0;
            double d13 = d1;
            double d14 = d2;
            AxisAlignedBBHandle axisalignedbb1 = that.getBoundingBox();
            that.setBoundingBox(axisalignedbb);
            d1 = (double) that.getHeightOffset();
            // BKCommonLib start
            // collision event handler
            shapeAccumulator.open(world_getCollisionShapes(that, d7, d1, d9));
            // BKCommonLib end
            AxisAlignedBBHandle axisalignedbb2 = that.getBoundingBox();
            AxisAlignedBBHandle axisalignedbb3 = axisalignedbb2.transformB(d7, 0.0D, d9);
            double d11 = d1;
            d11 = VoxelShapeHandle.traceAxis(EnumAxisHandle.Y, axisalignedbb3, shapeAccumulator.stream(), d11);
            if (d11 != 0.0D) {
                axisalignedbb2 = axisalignedbb2.translate(0.0D, d11, 0.0D);
            }
            double d15 = d7;
            d15 = VoxelShapeHandle.traceAxis(EnumAxisHandle.X, axisalignedbb2, shapeAccumulator.stream(), d15);
            if (d15 != 0.0D) {
                axisalignedbb2 = axisalignedbb2.translate(d15, 0.0D, 0.0D);
            }
            double d16 = d9;
            d16 = VoxelShapeHandle.traceAxis(EnumAxisHandle.Z, axisalignedbb2, shapeAccumulator.stream(), d16);
            if (d16 != 0.0D) {
                axisalignedbb2 = axisalignedbb2.translate(0.0D, 0.0D, d16);
            }
            AxisAlignedBBHandle axisalignedbb4 = that.getBoundingBox();
            double d17 = d1;
            d17 = VoxelShapeHandle.traceAxis(EnumAxisHandle.Y, axisalignedbb4, shapeAccumulator.stream(), d17);
            if (d17 != 0.0D) {
                axisalignedbb4 = axisalignedbb4.translate(0.0D, d17, 0.0D);
            }
            double d18 = d7;
            d18 = VoxelShapeHandle.traceAxis(EnumAxisHandle.X, axisalignedbb4, shapeAccumulator.stream(), d18);
            if (d18 != 0.0D) {
                axisalignedbb4 = axisalignedbb4.translate(d18, 0.0D, 0.0D);
            }
            double d19 = d9;
            d19 = VoxelShapeHandle.traceAxis(EnumAxisHandle.Z, axisalignedbb4, shapeAccumulator.stream(), d19);
            if (d19 != 0.0D) {
                axisalignedbb4 = axisalignedbb4.translate(0.0D, 0.0D, d19);
            }
            double d20 = d15 * d15 + d16 * d16;
            double d21 = d18 * d18 + d19 * d19;
            if (d20 > d21) {
                d0 = d15;
                d2 = d16;
                d1 = -d11;
                that.setBoundingBox(axisalignedbb2);
            } else {
                d0 = d18;
                d2 = d19;
                d1 = -d17;
                that.setBoundingBox(axisalignedbb4);
            }
            d1 = VoxelShapeHandle.traceAxis(EnumAxisHandle.Y, that.getBoundingBox(), shapeAccumulator.stream(), d1);
            if (d1 != 0.0D) {
                that.setBoundingBox(that.getBoundingBox().translate(0.0D, d1, 0.0D));
            }
            if (d12 * d12 + d14 * d14 >= d0 * d0 + d2 * d2) {
                d0 = d12;
                d1 = d13;
                d2 = d14;
                that.setBoundingBox(axisalignedbb1);
            }
        }
        // NB: This code only executes with entities that are tall (have a head), like players
        world.method_profiler_end();
        world.method_profiler_begin("rest");
        that.setPositionFromBoundingBox();
        that.setHorizontalMovementBlocked(d7 != d0 || d9 != d2);
        // CraftBukkit - decompile error
        that.setVerticalMovementBlocked(d1 != d8);
        that.setOnGround(that.isVerticalMovementBlocked() && d8 < 0.0);
        int l = MathUtil.floor(that.getLocX());
        int k4 = MathUtil.floor(that.getLocY() - 0.2);
        int l4 = MathUtil.floor(that.getLocZ());
        IntVector3 blockposition = new IntVector3(l, k4, l4);
        BlockData iblockdata = world.getBlockData(blockposition);
        if (iblockdata.isType(org.bukkit.Material.AIR)) {
            IntVector3 blockposition1 = blockposition.add(0, -1, 0);
            BlockData iblockdata1 = world.getBlockData(blockposition1);
            BlockHandle block = iblockdata1.getBlock();
            if (block.isInstanceOf(BlockFenceHandle.T) || block.isInstanceOf(BlockCobbleWallHandle.T) || block.isInstanceOf(BlockFenceGateHandle.T)) {
                iblockdata = iblockdata1;
                blockposition = blockposition1;
            }
        }
        that.updateFalling(d1, that.isOnGround(), iblockdata, blockposition);
        if (d7 != d0) {
            that.setMotX(0.0);
        }
        if (d9 != d2) {
            that.setMotZ(0.0);
        }
        if (d8 != d1) {
            iblockdata.getBlock().entityHitVertical(world, that);
        }
        // CraftBukkit start
        if (that.isHorizontalMovementBlocked() && that.getBukkitEntity() instanceof Vehicle) {
            /*
                Vehicle vehicle = (Vehicle) that.getBukkitEntity();
                org.bukkit.block.Block bl = entity.getWorld().getBlockAt(MathUtil.floor(that.getLocX()), MathUtil.floor(that.getLocY()), MathUtil.floor(that.getLocZ()));

                if (d6 > d0) {
                    bl = bl.getRelative(BlockFace.EAST);
                } else if (d6 < d0) {
                    bl = bl.getRelative(BlockFace.WEST);
                } else if (d8 > d2) {
                    bl = bl.getRelative(BlockFace.SOUTH);
                } else if (d8 < d2) {
                    bl = bl.getRelative(BlockFace.NORTH);
                }

                if (bl.getType() != org.bukkit.Material.AIR) {
                    VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
                    Bukkit.getPluginManager().callEvent(event);
                }
                */
            // BKCommonLib: avoid creating an extra Block with getRelative if we don't have to!
            // Similarly, we don't have to create this Block when the block is air...
            org.bukkit.World bl_world = entity.getWorld();
            int bl_x = MathUtil.floor(that.getLocX());
            int bl_y = MathUtil.floor(that.getLocY());
            int bl_z = MathUtil.floor(that.getLocZ());
            if (d7 > d0) {
                bl_x++;
            } else if (d7 < d0) {
                bl_x--;
            } else if (d9 > d2) {
                bl_z++;
            } else if (d9 < d2) {
                bl_z--;
            }
            if (!WorldUtil.getBlockData(bl_world, bl_x, bl_y, bl_z).isType(org.bukkit.Material.AIR)) {
                org.bukkit.block.Block bl = bl_world.getBlockAt(bl_x, bl_y, bl_z);
                Vehicle vehicle = (Vehicle) that.getBukkitEntity();
                VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
                Bukkit.getPluginManager().callEvent(event);
            }
        // BKCommonLib end
        }
        if (that.hasMovementSound() && (!that.isOnGround() || !that.isSneaking() || !that.isInstanceOf(EntityHumanHandle.T)) && !that.isPassenger()) {
            double d22 = that.getLocX() - d4;
            double d23 = that.getLocY() - d5;
            double d11 = that.getLocZ() - d6;
            BlockHandle block1 = iblockdata.getBlock();
            if (block1.getRaw() != BlocksHandle.LADDER) {
                d23 = 0.0D;
            }
            if (block1 != null && that.isOnGround()) {
                iblockdata.stepOn(this.entity.getWorld(), blockposition, this.entity.getEntity());
            }
            that.setWalkedDistanceXZ((float) ((double) that.getWalkedDistanceXZ() + Math.sqrt(d22 * d22 + d11 * d11) * 0.6D));
            that.setWalkedDistanceXYZ((float) ((double) that.getWalkedDistanceXYZ() + Math.sqrt(d22 * d22 + d23 * d23 + d11 * d11) * 0.6D));
            if (that.getWalkedDistanceXYZ() > (float) that.getStepCounter() && !iblockdata.isType(org.bukkit.Material.AIR)) {
                that.setStepCounter((int) that.getWalkedDistanceXYZ() + 1);
                if (that.isInWater()) {
                    EntityHandle entity = that.isVehicle() ? that.getDriverEntity() : null;
                    float f = entity == this.entity.getEntity() ? 0.35F : 0.4F;
                    float f1 = (float) Math.sqrt(entity.getMotX() * entity.getMotX() * 0.2 + entity.getMotY() * entity.getMotY() + entity.getMotZ() * entity.getMotZ() * 0.2) * f;
                    if (f1 > 1.0F) {
                        f1 = 1.0F;
                    }
                    that.makeSound(that.getSwimSound(), f1, 1.0F + (this_random.nextFloat() - this_random.nextFloat()) * 0.4F);
                } else {
                    that.playStepSound(blockposition, iblockdata);
                }
            }
        }
        // CraftBukkit start - Move to the top of the method
        /*
            try {
                that.checkBlockCollisions();
            } catch (Throwable throwable) {
                CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision");
                CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being checked for collision");

                that.appendEntityCrashDetails(crashreportsystemdetails);
                throw new ReportedException(crashreport);
            }
            */
        // CraftBukkit end
        boolean flag1 = that.isWet();
        // Handle damage here
        if (this.blockCollisionEnabled && world.isBurnArea(that.getBoundingBox().shrinkUniform(0.001))) {
            that.burn(1.0f);
            if (!flag1) {
                that.setFireTicks(that.getFireTicks() + 1);
                if (that.getFireTicks() == 0) {
                    // CraftBukkit start
                    EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(null, entity.getEntity(), 8);
                    Bukkit.getPluginManager().callEvent(event);
                    if (!event.isCancelled()) {
                        that.setOnFire(event.getDuration());
                    }
                // CraftBukkit end
                }
            }
        } else if (that.getFireTicks() <= 0) {
            that.setFireTicks(-that.getMaxFireTicks());
        }
        if (flag1 && that.isBurning()) {
            that.makeSound(SoundEffect.EXTINGUISH, 0.7F, 1.6F + (this_random.nextFloat() - this_random.nextFloat()) * 0.4F);
            that.setFireTicks(-that.getMaxFireTicks());
        }
        world.method_profiler_end();
    }
// org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
Also used : EntityHandle(com.bergerkiller.generated.net.minecraft.world.entity.EntityHandle) Vehicle(org.bukkit.entity.Vehicle) Block(org.bukkit.block.Block) Random(java.util.Random) BlockData(com.bergerkiller.bukkit.common.wrappers.BlockData) Vector(org.bukkit.util.Vector) BlockHandle(com.bergerkiller.generated.net.minecraft.world.level.block.BlockHandle) WorldHandle(com.bergerkiller.generated.net.minecraft.world.level.WorldHandle) VehicleBlockCollisionEvent(org.bukkit.event.vehicle.VehicleBlockCollisionEvent) AxisAlignedBBHandle(com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle) EntityCombustEvent(org.bukkit.event.entity.EntityCombustEvent) CrashReportSystemDetailsHandle(com.bergerkiller.generated.net.minecraft.CrashReportSystemDetailsHandle) CrashReportHandle(com.bergerkiller.generated.net.minecraft.CrashReportHandle) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3)

Example 4 with IntVector3

use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.

the class OfflineBlock method readFrom.

/**
 * Reads the details of an OfflineBlock from a data input stream
 *
 * @param stream Stream to read from
 * @return Decoded OfflineBlock
 * @throws IOException
 */
public static OfflineBlock readFrom(DataInputStream stream) throws IOException {
    OfflineWorld world = OfflineWorld.of(StreamUtil.readUUID(stream));
    IntVector3 position = IntVector3.read(stream);
    return new OfflineBlock(world, position);
}
Also used : IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3)

Example 5 with IntVector3

use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.

the class PlayerRespawnPoint method applyToPlayer.

/**
 * Applies this respawn point configuration to a player. If {@link #NONE}, then
 * the respawn point is reset to nothing.
 *
 * @param player The player to apply this respawn point to
 */
public void applyToPlayer(Player player) {
    EntityPlayerHandle handle = EntityPlayerHandle.fromBukkit(player);
    if (getWorld() == null) {
        handle.setSpawnWorld(null);
        handle.setSpawnCoord(null);
    } else {
        handle.setSpawnWorld(getWorld());
        handle.setSpawnCoord(new IntVector3(getX(), getY(), getZ()));
        handle.setSpawnAngle(getAngle());
    }
}
Also used : IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3) EntityPlayerHandle(com.bergerkiller.generated.net.minecraft.server.level.EntityPlayerHandle)

Aggregations

IntVector3 (com.bergerkiller.bukkit.common.bases.IntVector3)27 HashSet (java.util.HashSet)9 IntVector2 (com.bergerkiller.bukkit.common.bases.IntVector2)6 Chunk (org.bukkit.Chunk)5 BlockFace (org.bukkit.block.BlockFace)4 Test (org.junit.Test)4 MapUUID (com.bergerkiller.bukkit.common.map.util.MapUUID)3 WorldHandle (com.bergerkiller.generated.net.minecraft.world.level.WorldHandle)3 File (java.io.File)3 UUID (java.util.UUID)3 World (org.bukkit.World)3 BlockLocation (com.bergerkiller.bukkit.common.BlockLocation)2 Octree (com.bergerkiller.bukkit.common.collections.octree.Octree)2 CommonTagCompound (com.bergerkiller.bukkit.common.nbt.CommonTagCompound)2 BlockData (com.bergerkiller.bukkit.common.wrappers.BlockData)2 EntityPlayerHandle (com.bergerkiller.generated.net.minecraft.server.level.EntityPlayerHandle)2 BitSet (java.util.BitSet)2 Random (java.util.Random)2 Set (java.util.Set)2 ItemFrame (org.bukkit.entity.ItemFrame)2