Search in sources :

Example 11 with IntVector3

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

the class RegionHandler_Vanilla_1_8 method getRegions3.

@Override
public Set<IntVector3> getRegions3(World world) {
    // Obtain the region file names
    Set<File> regionFiles = new HashSet<File>();
    File regionFolder = Common.SERVER.getWorldRegionFolder(world.getName());
    if (regionFolder != null) {
        String[] regionFileNames = regionFolder.list();
        for (String regionFileName : regionFileNames) {
            File file = new File(regionFolder, regionFileName);
            if (file.isFile() && file.exists() && file.length() >= 4096) {
                regionFiles.add(file);
            }
        }
    }
    // Synchronized, since we are going to iterate the files here...unsafe not to do so!
    synchronized (regionFileCacheType) {
        for (File regionFile : getCache().keySet()) {
            if (regionFile != null && regionFile.getParentFile().equals(regionFolder)) {
                regionFiles.add(regionFile);
            }
        }
    }
    // Parse all found files into the region x and z coordinates
    HashSet<IntVector3> regionIndices = new HashSet<IntVector3>();
    for (File file : regionFiles) {
        IntVector2 regionFileCoordinates = getRegionFileCoordinates(file);
        if (regionFileCoordinates == null) {
            continue;
        }
        IntVector3 coords = regionFileCoordinates.toIntVector3(0);
        if (coords != null) {
            regionIndices.add(coords);
        }
    }
    // Look at all loaded chunks of the world and add the regions they are inside of
    for (Chunk chunk : world.getLoadedChunks()) {
        IntVector3 coords = new IntVector3(chunk.getX() >> 5, 0, chunk.getZ() >> 5);
        regionIndices.add(coords);
    }
    return regionIndices;
}
Also used : IntVector2(com.bergerkiller.bukkit.common.bases.IntVector2) Chunk(org.bukkit.Chunk) File(java.io.File) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3) HashSet(java.util.HashSet)

Example 12 with IntVector3

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

the class CommonMapController method findCluster.

/**
 * Finds a cluster of all connected item frames that an item frame is part of
 *
 * @param itemFrame Start item frame
 * @param itemFramePosition Start block position of itemFrame
 * @param includingEmpty Whether to include frames in the cluster that have no item
 * @return cluster
 */
public final synchronized ItemFrameCluster findCluster(final EntityItemFrameHandle itemFrame, final IntVector3 itemFramePosition, final boolean includingEmpty) {
    final Predicate<EntityItemFrameHandle> itemFrameFilter;
    if (includingEmpty && ItemUtil.isEmpty(itemFrame.getItem())) {
        // Proceed only filling empty item frames
        itemFrameFilter = e -> ItemUtil.isEmpty(e.getItem());
    } else {
        final UUID itemFrameMapUUID;
        if (this.isFrameTilingSupported && (itemFrameMapUUID = itemFrame.getItemMapDisplayDynamicOnlyUUID()) != null) {
            if (includingEmpty) {
                itemFrameFilter = e -> {
                    return itemFrameMapUUID.equals(e.getItemMapDisplayDynamicOnlyUUID()) || ItemUtil.isEmpty(e.getItem());
                };
            } else {
                itemFrameFilter = e -> {
                    return itemFrameMapUUID.equals(e.getItemMapDisplayDynamicOnlyUUID());
                };
            }
        } else {
            // no neighbours or tiling disabled
            return new ItemFrameCluster(OfflineWorld.of(itemFrame.getBukkitWorld()), itemFrame.getFacing(), Collections.singleton(itemFramePosition), 0);
        }
    }
    // Look up in cache first
    World world = itemFrame.getBukkitWorld();
    Map<IntVector3, ItemFrameCluster> cachedClusters;
    if (!includingEmpty && itemFrameClustersByWorldEnabled) {
        cachedClusters = itemFrameClustersByWorld.get(world);
        if (cachedClusters == null) {
            cachedClusters = new HashMap<>();
            itemFrameClustersByWorld.put(world, cachedClusters);
        }
        ItemFrameCluster fromCache = cachedClusters.get(itemFramePosition);
        if (fromCache != null) {
            return fromCache;
        }
    } else {
        cachedClusters = null;
    }
    // Take cache entry
    FindNeighboursCache cache = this.findNeighboursCache;
    if (cache != null) {
        cache.reset();
        this.findNeighboursCache = null;
    } else {
        cache = new FindNeighboursCache();
    }
    try {
        // Find all item frames that:
        // - Are on the same world as this item frame
        // - Facing the same way
        // - Along the same x/y/z (facing)
        // - Same ItemStack map UUID (or, if includingEmpty, are empty)
        ItemFrameClusterKey key = new ItemFrameClusterKey(world, itemFrame.getFacing(), itemFramePosition);
        for (EntityItemFrameHandle otherFrame : getItemFrameEntities(key)) {
            if (otherFrame.getId() != itemFrame.getId() && itemFrameFilter.test(otherFrame)) {
                cache.put(otherFrame);
            }
        }
        BlockFace[] neighbourAxis;
        if (FaceUtil.isAlongY(key.facing)) {
            neighbourAxis = NEIGHBOUR_AXIS_ALONG_Y;
        } else if (FaceUtil.isAlongX(key.facing)) {
            neighbourAxis = NEIGHBOUR_AXIS_ALONG_X;
        } else {
            neighbourAxis = NEIGHBOUR_AXIS_ALONG_Z;
        }
        // Find the most common item frame rotation in use
        // Only 4 possible rotations can be used for maps, so this is easy
        int[] rotation_counts = new int[4];
        rotation_counts[(new FindNeighboursCache.Frame(itemFrame)).rotation]++;
        // Make sure the neighbours result are a single contiguous blob
        // Islands (can not reach the input item frame) are removed
        Set<IntVector3> result = new HashSet<IntVector3>(cache.cache.size());
        result.add(itemFramePosition);
        cache.pendingList.add(itemFramePosition);
        do {
            IntVector3 pending = cache.pendingList.poll();
            for (BlockFace side : neighbourAxis) {
                IntVector3 sidePoint = pending.add(side);
                FindNeighboursCache.Frame frame = cache.cache.remove(sidePoint);
                if (frame != null) {
                    rotation_counts[frame.rotation]++;
                    cache.pendingList.add(sidePoint);
                    result.add(sidePoint);
                }
            }
        } while (!cache.pendingList.isEmpty());
        // Find maximum rotation index
        int rotation_idx = 0;
        for (int i = 1; i < rotation_counts.length; i++) {
            if (rotation_counts[i] > rotation_counts[rotation_idx]) {
                rotation_idx = i;
            }
        }
        // The final combined result
        ItemFrameCluster cluster = new ItemFrameCluster(OfflineWorld.of(key.world), key.facing, result, rotation_idx * 90);
        if (cachedClusters != null) {
            for (IntVector3 position : cluster.coordinates) {
                cachedClusters.put(position, cluster);
            }
        }
        return cluster;
    } finally {
        // Return to cache
        this.findNeighboursCache = cache;
    }
}
Also used : ItemFrame(org.bukkit.entity.ItemFrame) BlockFace(org.bukkit.block.BlockFace) World(org.bukkit.World) OfflineWorld(com.bergerkiller.bukkit.common.offline.OfflineWorld) EntityItemFrameHandle(com.bergerkiller.generated.net.minecraft.world.entity.decoration.EntityItemFrameHandle) MapUUID(com.bergerkiller.bukkit.common.map.util.MapUUID) UUID(java.util.UUID) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3) HashSet(java.util.HashSet)

Example 13 with IntVector3

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

the class RegionHandlerVanilla method getRegions3ForXZ.

@Override
public Set<IntVector3> getRegions3ForXZ(World world, Set<IntVector2> regionXZCoordinates) {
    // Figure out the minimum/maximum region y coordinate
    // Since Minecraft 1.17 there can be more than one region (32 chunks) vertically
    WorldHandle worldHandle = WorldHandle.fromBukkit(world);
    int minRegionY = worldHandle.getMinBuildHeight() >> 9;
    int maxRegionY = (worldHandle.getMaxBuildHeight() - 1) >> 9;
    Set<IntVector3> result = new HashSet<IntVector3>(regionXZCoordinates.size());
    for (IntVector2 coord : regionXZCoordinates) {
        for (int ry = minRegionY; ry <= maxRegionY; ry++) {
            result.add(coord.toIntVector3(ry));
        }
    }
    return result;
}
Also used : WorldHandle(com.bergerkiller.generated.net.minecraft.world.level.WorldHandle) IntVector2(com.bergerkiller.bukkit.common.bases.IntVector2) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3) HashSet(java.util.HashSet)

Example 14 with IntVector3

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

the class RegionHandler method getRegions.

/**
 * Gets all region indices for loadable regions of a world.<br>
 * <br>
 * <b>Deprecated: use {@link #getRegions3(World)} instead
 * to support servers with infinite Y-coordinate generation</b>
 *
 * @param world
 * @return region indices
 */
@Deprecated
public final Set<IntVector2> getRegions(World world) {
    Set<IntVector3> coords_3d = getRegions3(world);
    Set<IntVector2> coords_2d = new HashSet<IntVector2>(coords_3d.size());
    for (IntVector3 coord : coords_3d) {
        coords_2d.add(coord.toIntVector2());
    }
    return coords_2d;
}
Also used : IntVector2(com.bergerkiller.bukkit.common.bases.IntVector2) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3) HashSet(java.util.HashSet)

Example 15 with IntVector3

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

the class EntityMoveHandler method move.

/**
 * 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 move(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.recalcPosition();
    } else {
        // We need to do that.regardless of whether or not we are moving thanks to portals
        try {
            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.getMethodProfiler().begin("move");
        double d4 = that.getLocX();
        double d5 = that.getLocY();
        double d6 = that.getLocZ();
        if (that.isJustLanded()) {
            that.setJustLanded(false);
            d0 *= 0.25D;
            d1 *= 0.05000000074505806D;
            d2 *= 0.25D;
            that.setMotX(0.0);
            that.setMotY(0.0);
            that.setMotZ(0.0);
        }
        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.getCubes(that, that.getBoundingBox().translate(d0, (double) (-that.getHeightOffset()), 0.0D)).isEmpty(); 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.getCubes(that, that.getBoundingBox().translate(0.0D, (double) (-that.getHeightOffset()), d2)).isEmpty(); 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.getCubes(that, that.getBoundingBox().translate(d0, (double) (-that.getHeightOffset()), d2)).isEmpty(); 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;
                }
            }
        }
        // BKCommonLib start
        // collision event handler
        // List<AxisAlignedBB> list = that.world.getCubes(that, that.getBoundingBox().b(d0, d1, d2));
        List<AxisAlignedBBHandle> list = world_getCubes(that, that.getBoundingBox().transformB(d0, d1, d2));
        // BKCommonLib end
        AxisAlignedBBHandle axisalignedbb = that.getBoundingBox();
        int k;
        int l;
        if (d1 != 0.0D) {
            k = 0;
            for (l = list.size(); k < l; ++k) {
                d1 = list.get(k).calcSomeY(that.getBoundingBox(), d1);
            }
            that.setBoundingBox(that.getBoundingBox().translate(0.0D, d1, 0.0D));
        }
        if (d0 != 0.0D) {
            k = 0;
            for (l = list.size(); k < l; ++k) {
                d0 = list.get(k).calcSomeX(that.getBoundingBox(), d0);
            }
            if (d0 != 0.0D) {
                that.setBoundingBox(that.getBoundingBox().translate(d0, 0.0D, 0.0D));
            }
        }
        if (d2 != 0.0D) {
            k = 0;
            for (l = list.size(); k < l; ++k) {
                d2 = list.get(k).calcSomeZ(that.getBoundingBox(), d2);
            }
            if (d2 != 0.0D) {
                that.setBoundingBox(that.getBoundingBox().translate(0.0D, 0.0D, d2));
            }
        }
        // CraftBukkit - decompile error
        boolean flag = that.isOnGround() || d1 != d8 && d1 < 0.0D;
        double d11;
        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
            // List<AxisAlignedBB> list1 = that.world.getCubes(that, that.getBoundingBox().b(d7, d1, d9));
            List<AxisAlignedBBHandle> list1 = world_getCubes(that, that.getBoundingBox().transformB(d7, d1, d9));
            // BKCommonLib end
            AxisAlignedBBHandle axisalignedbb2 = that.getBoundingBox();
            AxisAlignedBBHandle axisalignedbb3 = axisalignedbb2.transformB(d7, 0.0D, d9);
            d11 = d1;
            int i1 = 0;
            for (int j1 = list1.size(); i1 < j1; ++i1) {
                d11 = list1.get(i1).calcSomeY(axisalignedbb3, d11);
            }
            axisalignedbb2 = axisalignedbb2.translate(0.0D, d11, 0.0D);
            double d15 = d7;
            int k1 = 0;
            for (int l1 = list1.size(); k1 < l1; ++k1) {
                d15 = list1.get(k1).calcSomeX(axisalignedbb2, d15);
            }
            axisalignedbb2 = axisalignedbb2.translate(d15, 0.0D, 0.0D);
            double d16 = d9;
            int i2 = 0;
            for (int j2 = list1.size(); i2 < j2; ++i2) {
                d16 = list1.get(i2).calcSomeZ(axisalignedbb2, d16);
            }
            axisalignedbb2 = axisalignedbb2.translate(0.0D, 0.0D, d16);
            AxisAlignedBBHandle axisalignedbb4 = that.getBoundingBox();
            double d17 = d1;
            int k2 = 0;
            for (int l2 = list1.size(); k2 < l2; ++k2) {
                d17 = list1.get(k2).calcSomeY(axisalignedbb4, d17);
            }
            axisalignedbb4 = axisalignedbb4.translate(0.0D, d17, 0.0D);
            double d18 = d7;
            int i3 = 0;
            for (int j3 = list1.size(); i3 < j3; ++i3) {
                d18 = list1.get(i3).calcSomeX(axisalignedbb4, d18);
            }
            axisalignedbb4 = axisalignedbb4.translate(d18, 0.0D, 0.0D);
            double d19 = d9;
            int k3 = 0;
            for (int l3 = list1.size(); k3 < l3; ++k3) {
                d19 = list1.get(k3).calcSomeZ(axisalignedbb4, d19);
            }
            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);
            }
            int i4 = 0;
            for (int j4 = list1.size(); i4 < j4; ++i4) {
                d1 = list1.get(i4).calcSomeY(that.getBoundingBox(), d1);
            }
            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);
            }
        }
        world.getMethodProfiler().end();
        world.getMethodProfiler().begin("rest");
        that.recalcPosition();
        that.setHorizontalMovementImpaired(d7 != d0 || d9 != d2);
        // CraftBukkit - decompile error
        that.setVerticalMovementImpaired(d1 != d8);
        that.setOnGround(that.isVerticalMovementImpaired() && d8 < 0.0);
        that.setMovementImpaired(that.isHorizontalMovementImpaired() || that.isVerticalMovementImpaired());
        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.getType() == 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);
        }
        BlockHandle block1 = iblockdata.getBlock();
        if (d8 != d1) {
            block1.entityHitVertical(world, that);
        }
        // CraftBukkit start
        if (that.isHorizontalMovementImpaired() && 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);
            }
        }
        if (that.hasMovementSound() && (!that.isOnGround() || !that.isSneaking() || !that.isInstanceOf(EntityHumanHandle.T)) && !that.isPassenger()) {
            double d22 = that.getLocX() - d4;
            double d23 = that.getLocY() - d5;
            d11 = that.getLocZ() - d6;
            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.getType() != 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.doStepSoundUpdate(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();
        if (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(CommonSounds.EXTINGUISH, 0.7F, 1.6F + (this_random.nextFloat() - this_random.nextFloat()) * 0.4F);
            that.setFireTicks(-that.getMaxFireTicks());
        }
        world.getMethodProfiler().end();
    }
// org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
Also used : EntityHandle(com.bergerkiller.generated.net.minecraft.server.EntityHandle) Vehicle(org.bukkit.entity.Vehicle) Random(java.util.Random) BlockData(com.bergerkiller.bukkit.common.wrappers.BlockData) BlockHandle(com.bergerkiller.generated.net.minecraft.server.BlockHandle) WorldHandle(com.bergerkiller.generated.net.minecraft.server.WorldHandle) VehicleBlockCollisionEvent(org.bukkit.event.vehicle.VehicleBlockCollisionEvent) AxisAlignedBBHandle(com.bergerkiller.generated.net.minecraft.server.AxisAlignedBBHandle) EntityCombustEvent(org.bukkit.event.entity.EntityCombustEvent) CrashReportSystemDetailsHandle(com.bergerkiller.generated.net.minecraft.server.CrashReportSystemDetailsHandle) CrashReportHandle(com.bergerkiller.generated.net.minecraft.server.CrashReportHandle) IntVector3(com.bergerkiller.bukkit.common.bases.IntVector3)

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