Search in sources :

Example 76 with BlockState

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

the class EntityMySkeletonHorse 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 77 with BlockState

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

the class EntityMyDonkey 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.16F, soundeffecttype.getPitch());
            } else if (this.soundCounter <= 5) {
                this.playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch());
            }
        } else if (!blockdata.getMaterial().isLiquid()) {
            this.soundCounter += 1;
            playSound(SoundEvents.HORSE_STEP_WOOD, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch());
        } else {
            playSound(SoundEvents.HORSE_STEP, soundeffecttype.getVolume() * 0.16F, soundeffecttype.getPitch());
        }
    }
}
Also used : SoundType(net.minecraft.world.level.block.SoundType) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 78 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project Totemic by TeamTotemic.

the class TotemPoleBlock method updateShape.

@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) {
    if (facing == Direction.UP) {
        for (int i = 0; i < TotemEffectAPI.MAX_POLE_SIZE; i++) {
            BlockPos searchPos = currentPos.below(i + 1);
            BlockState searchState = world.getBlockState(searchPos);
            if (searchState.getBlock() instanceof TotemBaseBlock) {
                searchState.updateShape(Direction.UP, state, world, searchPos, currentPos);
            } else if (!(searchState.getBlock() instanceof TotemPoleBlock))
                break;
        }
    }
    return state;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos)

Example 79 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project SpongeCommon by SpongePowered.

the class ReplaceBlockEntity method captureState.

@Override
protected void captureState() {
    super.captureState();
    final BlockState currentState = this.worldSupplier.get().getBlockState(this.affectedPosition);
    final SpongeBlockSnapshot snapshot = TrackingUtil.createPooledSnapshot(currentState, this.affectedPosition, BlockChangeFlags.NONE, Constants.World.DEFAULT_BLOCK_CHANGE_LIMIT, this.removed, this.worldSupplier, Optional::empty, Optional::empty);
    snapshot.blockChange = BlockChange.MODIFY;
    this.removedSnapshot = snapshot;
}
Also used : SpongeBlockSnapshot(org.spongepowered.common.block.SpongeBlockSnapshot) BlockState(net.minecraft.world.level.block.state.BlockState) Optional(java.util.Optional)

Example 80 with BlockState

use of net.minecraft.world.level.block.state.BlockState in project SpongeCommon by SpongePowered.

the class CheckBlockPostPlacementIsSameEffect method processSideEffect.

@Override
public EffectResult processSideEffect(final BlockPipeline pipeline, final PipelineCursor oldState, final BlockState newState, final SpongeBlockChangeFlag flag, final int limit) {
    final LevelChunkSection chunkSection = pipeline.getAffectedSection();
    final int x = oldState.pos.getX() & 15;
    final int y = oldState.pos.getY() & 15;
    final int z = oldState.pos.getZ() & 15;
    final BlockState currentState = chunkSection.getBlockState(x, y, z);
    if (currentState.getBlock() != newState.getBlock()) {
        return EffectResult.NULL_RETURN;
    }
    return EffectResult.NULL_PASS;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) LevelChunkSection(net.minecraft.world.level.chunk.LevelChunkSection)

Aggregations

BlockState (net.minecraft.world.level.block.state.BlockState)141 BlockPos (net.minecraft.core.BlockPos)75 Direction (net.minecraft.core.Direction)18 Level (net.minecraft.world.level.Level)14 Block (net.minecraft.world.level.block.Block)14 ArrayList (java.util.ArrayList)10 ServerLevel (net.minecraft.server.level.ServerLevel)10 SoundType (net.minecraft.world.level.block.SoundType)10 Vec3 (net.minecraft.world.phys.Vec3)10 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)9 Random (java.util.Random)8 ItemStack (net.minecraft.world.item.ItemStack)7 FluidState (net.minecraft.world.level.material.FluidState)7 AABB (net.minecraft.world.phys.AABB)6 BuildBlock (com.wuest.prefab.structures.base.BuildBlock)5 LevelChunk (net.minecraft.world.level.chunk.LevelChunk)5 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)5 LocationTag (com.denizenscript.denizen.objects.LocationTag)4 FakeBlock (com.denizenscript.denizen.utilities.blocks.FakeBlock)4 HashMap (java.util.HashMap)4