Search in sources :

Example 1 with Fluid

use of net.minecraft.server.v1_15_R1.Fluid in project dynmap by webbukkit.

the class BukkitVersionHelperSpigot115 method initializeBlockStates.

/**
 * Initialize block states (org.dynmap.blockstate.DynmapBlockState)
 */
@Override
public void initializeBlockStates() {
    dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
    HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
    int cnt = Block.REGISTRY_ID.a();
    DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
    // Loop through block data states
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        Block b = bd.getBlock();
        String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
        // See if we have seen this one
        DynmapBlockState lastbs = lastBlockState.get(bname);
        int idx = 0;
        if (lastbs != null) {
            // Yes
            // Get number of states so far, since this is next
            idx = lastbs.getStateCount();
        }
        // Build state name
        String sb = "";
        String fname = bd.toString();
        int off1 = fname.indexOf('[');
        if (off1 >= 0) {
            int off2 = fname.indexOf(']');
            sb = fname.substring(off1 + 1, off2);
        }
        Material mat = bd.getMaterial();
        // getLightBlock
        int lightAtten = b.l(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
        // Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
        // Fill in base attributes
        bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
        if (mat.isSolid()) {
            bld.setSolid();
        }
        if (mat == Material.AIR) {
            bld.setAir();
        }
        if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
            bld.setLog();
        }
        if (mat == Material.LEAVES) {
            bld.setLeaves();
        }
        if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
            // Test if fluid type for block is not empty
            bld.setWaterlogged();
        }
        // Build state
        DynmapBlockState dbs = bld.build();
        dataToState.put(bd, dbs);
        lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
        Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
    }
}
Also used : BlockRotatable(net.minecraft.server.v1_15_R1.BlockRotatable) HashMap(java.util.HashMap) IdentityHashMap(java.util.IdentityHashMap) DynmapBlockState(org.dynmap.renderer.DynmapBlockState) Material(net.minecraft.server.v1_15_R1.Material) IBlockData(net.minecraft.server.v1_15_R1.IBlockData) Block(net.minecraft.server.v1_15_R1.Block) BlockFluids(net.minecraft.server.v1_15_R1.BlockFluids)

Example 2 with Fluid

use of net.minecraft.server.v1_15_R1.Fluid in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

protected static PathType b(IBlockAccess var0, BlockPosition var1) {
    IBlockData var2 = var0.getType(var1);
    Block var3 = var2.getBlock();
    Material var4 = var2.getMaterial();
    if (var2.isAir())
        return PathType.OPEN;
    if (var2.a(TagsBlock.TRAPDOORS) || var2.a(Blocks.LILY_PAD))
        return PathType.TRAPDOOR;
    if (var2.a(Blocks.CACTUS))
        return PathType.DAMAGE_CACTUS;
    if (var2.a(Blocks.SWEET_BERRY_BUSH))
        return PathType.DAMAGE_OTHER;
    if (var2.a(Blocks.HONEY_BLOCK))
        return PathType.STICKY_HONEY;
    if (var2.a(Blocks.COCOA))
        return PathType.COCOA;
    Fluid var5 = var0.getFluid(var1);
    if (var5.a(TagsFluid.WATER))
        return PathType.WATER;
    if (var5.a(TagsFluid.LAVA))
        return PathType.LAVA;
    if (a(var2))
        return PathType.DAMAGE_FIRE;
    if (BlockDoor.l(var2) && !var2.get(BlockDoor.OPEN).booleanValue())
        return PathType.DOOR_WOOD_CLOSED;
    if (var3 instanceof BlockDoor && var4 == Material.ORE && !var2.get(BlockDoor.OPEN).booleanValue())
        return PathType.DOOR_IRON_CLOSED;
    if (var3 instanceof BlockDoor && var2.get(BlockDoor.OPEN).booleanValue())
        return PathType.DOOR_OPEN;
    if (var3 instanceof BlockMinecartTrackAbstract)
        return PathType.RAIL;
    if (var3 instanceof BlockLeaves)
        return PathType.LEAVES;
    if (var3.a(TagsBlock.FENCES) || var3.a(TagsBlock.WALLS) || (var3 instanceof BlockFenceGate && !var2.get(BlockFenceGate.OPEN).booleanValue()))
        return PathType.FENCE;
    if (!var2.a(var0, var1, PathMode.LAND))
        return PathType.BLOCKED;
    return PathType.OPEN;
}
Also used : BlockDoor(net.minecraft.server.v1_16_R3.BlockDoor) IBlockData(net.minecraft.server.v1_16_R3.IBlockData) BlockLeaves(net.minecraft.server.v1_16_R3.BlockLeaves) BlockFenceGate(net.minecraft.server.v1_16_R3.BlockFenceGate) Fluid(net.minecraft.server.v1_16_R3.Fluid) TagsFluid(net.minecraft.server.v1_16_R3.TagsFluid) Block(net.minecraft.server.v1_16_R3.Block) TagsBlock(net.minecraft.server.v1_16_R3.TagsBlock) Material(net.minecraft.server.v1_16_R3.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_16_R3.BlockMinecartTrackAbstract)

Example 3 with Fluid

use of net.minecraft.server.v1_15_R1.Fluid in project Citizens2 by CitizensDev.

the class NMSImpl method flyingMoveLogic.

public static void flyingMoveLogic(EntityLiving entity, Vec3D vec3d) {
    if (entity.doAITick() || entity.cs()) {
        double d0 = 0.08D;
        boolean flag = ((entity.getMot()).y <= 0.0D);
        if (flag && entity.hasEffect(MobEffects.SLOW_FALLING)) {
            d0 = 0.01D;
            entity.fallDistance = 0.0F;
        }
        Fluid fluid = entity.world.getFluid(entity.getChunkCoordinates());
        if (entity.isInWater() && /*&& entity.cT() */
        !entity.a(fluid.getType())) {
            double d1 = entity.locY();
            float f = entity.isSprinting() ? 0.9F : 0.8F;
            float f1 = 0.02F;
            float f2 = EnchantmentManager.e(entity);
            if (f2 > 3.0F)
                f2 = 3.0F;
            if (!entity.isOnGround())
                f2 *= 0.5F;
            if (f2 > 0.0F) {
                f += (0.54600006F - f) * f2 / 3.0F;
                f1 += (entity.dN() - f1) * f2 / 3.0F;
            }
            if (entity.hasEffect(MobEffects.DOLPHINS_GRACE))
                f = 0.96F;
            entity.a(f1, vec3d);
            entity.move(EnumMoveType.SELF, entity.getMot());
            Vec3D vec3d1 = entity.getMot();
            if (entity.positionChanged && entity.isClimbing())
                vec3d1 = new Vec3D(vec3d1.x, 0.2D, vec3d1.z);
            entity.setMot(vec3d1.d(f, 0.800000011920929D, f));
            Vec3D vec3d2 = entity.a(d0, flag, entity.getMot());
            entity.setMot(vec3d2);
            if (entity.positionChanged && entity.e(vec3d2.x, vec3d2.y + 0.6D - entity.locY() + d1, vec3d2.z))
                entity.setMot(vec3d2.x, 0.30000001192092896D, vec3d2.z);
        } else if (entity.aQ() && /*&& entity.cT()*/
        !entity.a(fluid.getType())) {
            double d1 = entity.locY();
            entity.a(0.02F, vec3d);
            entity.move(EnumMoveType.SELF, entity.getMot());
            if (entity.b(TagsFluid.LAVA) <= entity.cx()) {
                entity.setMot(entity.getMot().d(0.5D, 0.8D, 0.5D));
                Vec3D vec3D = entity.a(d0, flag, entity.getMot());
                entity.setMot(vec3D);
            } else {
                entity.setMot(entity.getMot().a(0.5D));
            }
            if (!entity.isNoGravity())
                entity.setMot(entity.getMot().add(0.0D, -d0 / 4.0D, 0.0D));
            Vec3D vec3d3 = entity.getMot();
            if (entity.positionChanged && entity.e(vec3d3.x, vec3d3.y + 0.6D - entity.locY() + d1, vec3d3.z))
                entity.setMot(vec3d3.x, 0.3D, vec3d3.z);
        } else if (entity.isGliding()) {
            Vec3D vec3d4 = entity.getMot();
            if (vec3d4.y > -0.5D)
                entity.fallDistance = 1.0F;
            Vec3D vec3d5 = entity.getLookDirection();
            float f = entity.pitch * 0.017453292F;
            double d2 = Math.sqrt(vec3d5.x * vec3d5.x + vec3d5.z * vec3d5.z);
            double d3 = Math.sqrt(entity.c(vec3d4));
            double d4 = vec3d5.f();
            float f3 = MathHelper.cos(f);
            f3 = (float) (f3 * f3 * Math.min(1.0D, d4 / 0.4D));
            vec3d4 = entity.getMot().add(0.0D, d0 * (-1.0D + f3 * 0.75D), 0.0D);
            if (vec3d4.y < 0.0D && d2 > 0.0D) {
                double d5 = vec3d4.y * -0.1D * f3;
                vec3d4 = vec3d4.add(vec3d5.x * d5 / d2, d5, vec3d5.z * d5 / d2);
            }
            if (f < 0.0F && d2 > 0.0D) {
                double d5 = d3 * -MathHelper.sin(f) * 0.04D;
                vec3d4 = vec3d4.add(-vec3d5.x * d5 / d2, d5 * 3.2D, -vec3d5.z * d5 / d2);
            }
            if (d2 > 0.0D)
                vec3d4 = vec3d4.add((vec3d5.x / d2 * d3 - vec3d4.x) * 0.1D, 0.0D, (vec3d5.z / d2 * d3 - vec3d4.z) * 0.1D);
            entity.setMot(vec3d4.d(0.9900000095367432D, 0.9800000190734863D, 0.9900000095367432D));
            entity.move(EnumMoveType.SELF, entity.getMot());
            if (entity.positionChanged && !entity.world.isClientSide) {
                double d5 = Math.sqrt(entity.c(entity.getMot()));
                double d6 = d3 - d5;
                float f4 = (float) (d6 * 10.0D - 3.0D);
                if (f4 > 0.0F) {
                    try {
                        entity.playSound((SoundEffect) ENTITY_GET_SOUND_FALL.invoke(entity, (int) f4), 1.0F, 1.0F);
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                    entity.damageEntity(DamageSource.FLY_INTO_WALL, f4);
                }
            }
            if (entity.isOnGround() && !entity.world.isClientSide && entity.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(entity, false).isCancelled())
                entity.setFlag(7, false);
        } else {
            BlockPosition blockposition = new BlockPosition(entity.locX(), (entity.getBoundingBox()).minY - 0.5000001D, // entity.ar();
            entity.locZ());
            float f5 = entity.world.getType(blockposition).getBlock().getFrictionFactor();
            float f = entity.isOnGround() ? (f5 * 0.91F) : 0.91F;
            Vec3D vec3d6 = entity.a(vec3d, f5);
            double d7 = vec3d6.y;
            if (entity.hasEffect(MobEffects.LEVITATION)) {
                d7 += (0.05D * (entity.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - vec3d6.y) * 0.2D;
                entity.fallDistance = 0.0F;
            } else if (entity.world.isClientSide && !entity.world.isLoaded(blockposition)) {
                if (entity.locY() > 0.0D) {
                    d7 = -0.1D;
                } else {
                    d7 = 0.0D;
                }
            } else if (!entity.isNoGravity()) {
                d7 -= d0;
            }
            entity.setMot(vec3d6.x * f, d7 * 0.9800000190734863D, vec3d6.z * f);
        }
    }
    entity.a(entity, entity instanceof EntityBird);
}
Also used : Fluid(net.minecraft.server.v1_16_R3.Fluid) TagsFluid(net.minecraft.server.v1_16_R3.TagsFluid) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) EntityBird(net.minecraft.server.v1_16_R3.EntityBird) Vec3D(net.minecraft.server.v1_16_R3.Vec3D)

Example 4 with Fluid

use of net.minecraft.server.v1_15_R1.Fluid in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

protected PathType b(IBlockAccess var0, int var1, int var2, int var3) {
    BlockPosition var4 = new BlockPosition(var1, var2, var3);
    IBlockData var5 = var0.getType(var4);
    Block var6 = var5.getBlock();
    Material var7 = var5.getMaterial();
    if (var5.isAir()) {
        return PathType.OPEN;
    } else if (!var6.a(TagsBlock.TRAPDOORS) && var6 != Blocks.LILY_PAD) {
        if (var6 == Blocks.FIRE) {
            return PathType.DAMAGE_FIRE;
        } else if (var6 == Blocks.CACTUS) {
            return PathType.DAMAGE_CACTUS;
        } else if (var6 == Blocks.SWEET_BERRY_BUSH) {
            return PathType.DAMAGE_OTHER;
        } else if (var6 instanceof BlockDoor && var7 == Material.WOOD && !(Boolean) var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_WOOD_CLOSED;
        } else if (var6 instanceof BlockDoor && var7 == Material.ORE && !(Boolean) var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_IRON_CLOSED;
        } else if (var6 instanceof BlockDoor && var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_OPEN;
        } else if (var6 instanceof BlockMinecartTrackAbstract) {
            return PathType.RAIL;
        } else if (var6 instanceof BlockLeaves) {
            return PathType.LEAVES;
        } else if (!var6.a(TagsBlock.FENCES) && !var6.a(TagsBlock.WALLS) && (!(var6 instanceof BlockFenceGate) || var5.get(BlockFenceGate.OPEN))) {
            Fluid var8 = var0.getFluid(var4);
            if (var8.a(TagsFluid.WATER)) {
                return PathType.WATER;
            } else if (var8.a(TagsFluid.LAVA)) {
                return PathType.LAVA;
            } else {
                return var5.a(var0, var4, PathMode.LAND) ? PathType.OPEN : PathType.BLOCKED;
            }
        } else {
            return PathType.FENCE;
        }
    } else {
        return PathType.TRAPDOOR;
    }
}
Also used : BlockDoor(net.minecraft.server.v1_14_R1.BlockDoor) IBlockData(net.minecraft.server.v1_14_R1.IBlockData) BlockLeaves(net.minecraft.server.v1_14_R1.BlockLeaves) BlockFenceGate(net.minecraft.server.v1_14_R1.BlockFenceGate) BlockPosition(net.minecraft.server.v1_14_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.MutableBlockPosition) PooledBlockPosition(net.minecraft.server.v1_14_R1.BlockPosition.PooledBlockPosition) Fluid(net.minecraft.server.v1_14_R1.Fluid) TagsFluid(net.minecraft.server.v1_14_R1.TagsFluid) Block(net.minecraft.server.v1_14_R1.Block) TagsBlock(net.minecraft.server.v1_14_R1.TagsBlock) Material(net.minecraft.server.v1_14_R1.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_14_R1.BlockMinecartTrackAbstract)

Example 5 with Fluid

use of net.minecraft.server.v1_15_R1.Fluid in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method c.

protected static PathType c(IBlockAccess var0, int var1, int var2, int var3) {
    BlockPosition var4 = new BlockPosition(var1, var2, var3);
    IBlockData var5 = var0.getType(var4);
    Block var6 = var5.getBlock();
    Material var7 = var5.getMaterial();
    if (var5.isAir()) {
        return PathType.OPEN;
    } else if (!var6.a(TagsBlock.TRAPDOORS) && var6 != Blocks.LILY_PAD) {
        if (var6 == Blocks.FIRE) {
            return PathType.DAMAGE_FIRE;
        } else if (var6 == Blocks.CACTUS) {
            return PathType.DAMAGE_CACTUS;
        } else if (var6 == Blocks.SWEET_BERRY_BUSH) {
            return PathType.DAMAGE_OTHER;
        } else if (var6 == Blocks.HONEY_BLOCK) {
            return PathType.STICKY_HONEY;
        } else if (var6 == Blocks.COCOA) {
            return PathType.COCOA;
        } else if (var6 instanceof BlockDoor && var7 == Material.WOOD && !(Boolean) var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_WOOD_CLOSED;
        } else if (var6 instanceof BlockDoor && var7 == Material.ORE && !(Boolean) var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_IRON_CLOSED;
        } else if (var6 instanceof BlockDoor && var5.get(BlockDoor.OPEN)) {
            return PathType.DOOR_OPEN;
        } else if (var6 instanceof BlockMinecartTrackAbstract) {
            return PathType.RAIL;
        } else if (var6 instanceof BlockLeaves) {
            return PathType.LEAVES;
        } else if (var6.a(TagsBlock.FENCES) || var6.a(TagsBlock.WALLS) || var6 instanceof BlockFenceGate && !(Boolean) var5.get(BlockFenceGate.OPEN)) {
            return PathType.FENCE;
        } else {
            Fluid var8 = var0.getFluid(var4);
            if (var8.a(TagsFluid.WATER)) {
                return PathType.WATER;
            } else if (var8.a(TagsFluid.LAVA)) {
                return PathType.LAVA;
            } else {
                return var5.a(var0, var4, PathMode.LAND) ? PathType.OPEN : PathType.BLOCKED;
            }
        }
    } else {
        return PathType.TRAPDOOR;
    }
}
Also used : BlockDoor(net.minecraft.server.v1_15_R1.BlockDoor) IBlockData(net.minecraft.server.v1_15_R1.IBlockData) BlockLeaves(net.minecraft.server.v1_15_R1.BlockLeaves) BlockFenceGate(net.minecraft.server.v1_15_R1.BlockFenceGate) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_15_R1.BlockPosition.MutableBlockPosition) PooledBlockPosition(net.minecraft.server.v1_15_R1.BlockPosition.PooledBlockPosition) Fluid(net.minecraft.server.v1_15_R1.Fluid) TagsFluid(net.minecraft.server.v1_15_R1.TagsFluid) Block(net.minecraft.server.v1_15_R1.Block) TagsBlock(net.minecraft.server.v1_15_R1.TagsBlock) Material(net.minecraft.server.v1_15_R1.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_15_R1.BlockMinecartTrackAbstract)

Aggregations

Block (net.minecraft.server.v1_15_R1.Block)2 IBlockData (net.minecraft.server.v1_15_R1.IBlockData)2 Material (net.minecraft.server.v1_15_R1.Material)2 Fluid (net.minecraft.server.v1_16_R3.Fluid)2 TagsFluid (net.minecraft.server.v1_16_R3.TagsFluid)2 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Block (net.minecraft.server.v1_13_R2.Block)1 BlockCobbleWall (net.minecraft.server.v1_13_R2.BlockCobbleWall)1 BlockDoor (net.minecraft.server.v1_13_R2.BlockDoor)1 BlockFence (net.minecraft.server.v1_13_R2.BlockFence)1 BlockFenceGate (net.minecraft.server.v1_13_R2.BlockFenceGate)1 BlockMinecartTrackAbstract (net.minecraft.server.v1_13_R2.BlockMinecartTrackAbstract)1 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)1 MutableBlockPosition (net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition)1 Fluid (net.minecraft.server.v1_13_R2.Fluid)1 IBlockData (net.minecraft.server.v1_13_R2.IBlockData)1 Material (net.minecraft.server.v1_13_R2.Material)1 TagsFluid (net.minecraft.server.v1_13_R2.TagsFluid)1 Block (net.minecraft.server.v1_14_R1.Block)1