Search in sources :

Example 16 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project MyPet by xXKeyleXx.

the class EntityMyHorse method playStepSound.

@Override
public void playStepSound(BlockPos blockposition, BlockState blockdata) {
    if (!blockdata.getMaterial().isLiquid()) {
        BlockState blockdataUp = this.level.getBlockState(blockposition.up());
        SoundType soundeffecttype = blockdata.getSoundType();
        if (blockdataUp.getBlock() == Blocks.SNOW) {
            soundeffecttype = blockdata.getSoundType();
        }
        if (this.isVehicle()) {
            ++this.soundCounter;
            if (this.soundCounter > 5 && this.soundCounter % 3 == 0) {
                this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            } else if (this.soundCounter <= 5) {
                this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            }
        } else if (!blockdata.getMaterial().isLiquid()) {
            this.soundCounter += 1;
            playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        } else {
            playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        }
    }
}
Also used : SoundType(net.minecraft.world.level.block.SoundType) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 17 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project MyPet by xXKeyleXx.

the class EntityMyMule method playStepSound.

@Override
public void playStepSound(BlockPos blockposition, BlockState blockdata) {
    if (!blockdata.getMaterial().isLiquid()) {
        BlockState blockdataUp = this.level.getBlockState(blockposition.up());
        SoundType soundeffecttype = blockdata.getSoundType();
        if (blockdataUp.getBlock() == Blocks.SNOW) {
            soundeffecttype = blockdata.getSoundType();
        }
        if (this.isVehicle()) {
            ++this.soundCounter;
            if (this.soundCounter > 5 && this.soundCounter % 3 == 0) {
                this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            } else if (this.soundCounter <= 5) {
                this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            }
        } else if (!blockdata.getMaterial().isLiquid()) {
            this.soundCounter += 1;
            playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        } else {
            playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        }
    }
}
Also used : SoundType(net.minecraft.world.level.block.SoundType) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 18 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project MyPet by xXKeyleXx.

the class EntityMyZombieHorse method playStepSound.

@Override
public void playStepSound(BlockPos blockposition, BlockState blockdata) {
    if (!blockdata.getMaterial().isLiquid()) {
        BlockState blockdataUp = this.level.getBlockState(blockposition.above());
        SoundType soundeffecttype = blockdata.getSoundType();
        if (blockdataUp.getBlock() == Blocks.SNOW) {
            soundeffecttype = blockdata.getSoundType();
        }
        if (this.isVehicle()) {
            ++this.soundCounter;
            if (this.soundCounter > 5 && this.soundCounter % 3 == 0) {
                this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            } else if (this.soundCounter <= 5) {
                this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            }
        } else if (!blockdata.getMaterial().isLiquid()) {
            this.soundCounter += 1;
            playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        } else {
            playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        }
    }
}
Also used : SoundType(net.minecraft.world.level.block.SoundType) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 19 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project MyPet by xXKeyleXx.

the class EntityMyMule method playStepSound.

@Override
public void playStepSound(BlockPos blockposition, BlockState blockdata) {
    if (!blockdata.getMaterial().isLiquid()) {
        BlockState blockdataUp = this.level.getBlockState(blockposition.above());
        SoundType soundeffecttype = blockdata.getSoundType();
        if (blockdataUp.getBlock() == Blocks.SNOW) {
            soundeffecttype = blockdata.getSoundType();
        }
        if (this.isVehicle()) {
            ++this.soundCounter;
            if (this.soundCounter > 5 && this.soundCounter % 3 == 0) {
                this.playSound(SoundEvents.HORSE_GALLOP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            } else if (this.soundCounter <= 5) {
                this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
            }
        } else if (!blockdata.getMaterial().isLiquid()) {
            this.soundCounter += 1;
            playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        } else {
            playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.15F, soundeffecttype.getPitch());
        }
    }
}
Also used : SoundType(net.minecraft.world.level.block.SoundType) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 20 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project MyPet by xXKeyleXx.

the class PlatformHelper method getBlockBBsInBB.

public List getBlockBBsInBB(net.minecraft.world.level.Level world, AABB axisalignedbb) {
    UnsafeList unsafeList = new UnsafeList();
    int minX = Mth.floor(axisalignedbb.minX);
    int maxX = (int) Math.ceil(axisalignedbb.maxX);
    int minY = Mth.floor(axisalignedbb.minY);
    int maxY = (int) Math.ceil(axisalignedbb.maxY);
    int minZ = Mth.floor(axisalignedbb.minZ);
    int maxZ = (int) Math.ceil(axisalignedbb.maxZ);
    VoxelShape vec3d;
    boolean isEmpty;
    for (int x = minX; x <= maxX; x++) {
        for (int z = minZ; z <= maxZ; z++) {
            if (((ServerChunkCache) world.getChunkSource()).hasChunk(x >> 4, z >> 4)) {
                for (int y = minY - 1; y <= maxY; y++) {
                    BlockPos bp = new BlockPos(x, y, z);
                    BlockState blockData = world.getBlockState(bp);
                    if (blockData != null && blockData.getMaterial().isSolid()) {
                        vec3d = blockData.getCollisionShape(world, bp);
                        isEmpty = vec3d.isEmpty();
                        if (!isEmpty) {
                            for (AABB bb : vec3d.toAabbs()) {
                                if (bb.move(bp).intersects(axisalignedbb)) {
                                    unsafeList.add(bb);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return unsafeList;
}
Also used : VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos) UnsafeList(org.bukkit.craftbukkit.v1_18_R1.util.UnsafeList) ServerChunkCache(net.minecraft.server.level.ServerChunkCache) AABB(net.minecraft.world.phys.AABB)

Aggregations

BlockState (net.minecraft.world.level.block.state.BlockState)38 BlockPos (net.minecraft.core.BlockPos)10 SoundType (net.minecraft.world.level.block.SoundType)10 Level (net.minecraft.world.level.Level)6 LocationTag (com.denizenscript.denizen.objects.LocationTag)4 FakeBlock (com.denizenscript.denizen.utilities.blocks.FakeBlock)4 ArrayList (java.util.ArrayList)3 Nonnull (javax.annotation.Nonnull)3 Direction (net.minecraft.core.Direction)3 ChunkPos (net.minecraft.world.level.ChunkPos)3 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)3 ChunkCoordinate (com.denizenscript.denizen.utilities.blocks.ChunkCoordinate)2 File (java.io.File)2 List (java.util.List)2 Optional (java.util.Optional)2 TextComponent (net.minecraft.network.chat.TextComponent)2 Player (net.minecraft.world.entity.player.Player)2 ItemStack (net.minecraft.world.item.ItemStack)2 LevelChunk (net.minecraft.world.level.chunk.LevelChunk)2 Fluid (net.minecraft.world.level.material.Fluid)2