Search in sources :

Example 1 with RedstoneSide

use of net.minecraft.world.level.block.state.properties.RedstoneSide in project additionaladditions by Dqu1J.

the class CopperPatinaBlock method animateTick.

public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
    int i = (Integer) state.getValue(POWER);
    if (i != 0) {
        Iterator var6 = Plane.HORIZONTAL.iterator();
        while (var6.hasNext()) {
            Direction direction = (Direction) var6.next();
            RedstoneSide wireConnection = (RedstoneSide) state.getValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction));
            switch(wireConnection) {
                case UP:
                    this.addPoweredParticles(world, random, pos, COLORS[i], direction, Direction.UP, -0.5F, 0.5F);
                case SIDE:
                    this.addPoweredParticles(world, random, pos, COLORS[i], Direction.DOWN, direction, 0.0F, 0.5F);
                    break;
                case NONE:
                default:
                    this.addPoweredParticles(world, random, pos, COLORS[i], Direction.DOWN, direction, 0.0F, 0.3F);
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) RedstoneSide(net.minecraft.world.level.block.state.properties.RedstoneSide) Direction(net.minecraft.core.Direction) EnumProperty(net.minecraft.world.level.block.state.properties.EnumProperty) Property(net.minecraft.world.level.block.state.properties.Property) IntegerProperty(net.minecraft.world.level.block.state.properties.IntegerProperty)

Example 2 with RedstoneSide

use of net.minecraft.world.level.block.state.properties.RedstoneSide in project additionaladditions by Dqu1J.

the class CopperPatinaBlock method updateForNewState.

private void updateForNewState(Level world, BlockPos pos, BlockState oldState, BlockState newState) {
    Iterator var5 = Plane.HORIZONTAL.iterator();
    while (var5.hasNext()) {
        Direction direction = (Direction) var5.next();
        BlockPos blockPos = pos.relative(direction);
        if (((RedstoneSide) oldState.getValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction))).isConnected() != ((RedstoneSide) newState.getValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction))).isConnected() && world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) {
            world.updateNeighborsAtExceptFromFacing(blockPos, newState.getBlock(), direction.getOpposite());
        }
    }
}
Also used : Iterator(java.util.Iterator) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) MutableBlockPos(net.minecraft.core.BlockPos.MutableBlockPos) BlockPos(net.minecraft.core.BlockPos) RedstoneSide(net.minecraft.world.level.block.state.properties.RedstoneSide) Direction(net.minecraft.core.Direction) EnumProperty(net.minecraft.world.level.block.state.properties.EnumProperty) Property(net.minecraft.world.level.block.state.properties.Property) IntegerProperty(net.minecraft.world.level.block.state.properties.IntegerProperty)

Example 3 with RedstoneSide

use of net.minecraft.world.level.block.state.properties.RedstoneSide in project additionaladditions by Dqu1J.

the class CopperPatinaBlock method method_27843.

private BlockState method_27843(BlockGetter world, BlockState state, BlockPos pos) {
    boolean bl = !world.getBlockState(pos.above()).isRedstoneConductor(world, pos);
    Iterator var5 = Plane.HORIZONTAL.iterator();
    while (var5.hasNext()) {
        Direction direction = (Direction) var5.next();
        if (!((RedstoneSide) state.getValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction))).isConnected()) {
            RedstoneSide wireConnection = this.getRenderConnectionType(world, pos, direction, bl);
            state = (BlockState) state.setValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction), wireConnection);
        }
    }
    return state;
}
Also used : Iterator(java.util.Iterator) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) RedstoneSide(net.minecraft.world.level.block.state.properties.RedstoneSide) Direction(net.minecraft.core.Direction)

Example 4 with RedstoneSide

use of net.minecraft.world.level.block.state.properties.RedstoneSide in project additionaladditions by Dqu1J.

the class CopperPatinaBlock method getShapeForState.

private VoxelShape getShapeForState(BlockState state) {
    VoxelShape voxelShape = DOT_SHAPE;
    Iterator var3 = Plane.HORIZONTAL.iterator();
    while (var3.hasNext()) {
        Direction direction = (Direction) var3.next();
        RedstoneSide wireConnection = (RedstoneSide) state.getValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction));
        if (wireConnection == RedstoneSide.SIDE) {
            voxelShape = Shapes.or(voxelShape, (VoxelShape) field_24414.get(direction));
        } else if (wireConnection == RedstoneSide.UP) {
            voxelShape = Shapes.or(voxelShape, (VoxelShape) field_24415.get(direction));
        }
    }
    return voxelShape;
}
Also used : VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) Iterator(java.util.Iterator) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) RedstoneSide(net.minecraft.world.level.block.state.properties.RedstoneSide) Direction(net.minecraft.core.Direction) EnumProperty(net.minecraft.world.level.block.state.properties.EnumProperty) Property(net.minecraft.world.level.block.state.properties.Property) IntegerProperty(net.minecraft.world.level.block.state.properties.IntegerProperty)

Example 5 with RedstoneSide

use of net.minecraft.world.level.block.state.properties.RedstoneSide in project additionaladditions by Dqu1J.

the class CopperPatinaBlock method updateIndirectNeighbourShapes.

public void updateIndirectNeighbourShapes(BlockState state, LevelAccessor world, BlockPos pos, int flags, int maxUpdateDepth) {
    MutableBlockPos mutable = new MutableBlockPos();
    Iterator var7 = Plane.HORIZONTAL.iterator();
    while (var7.hasNext()) {
        Direction direction = (Direction) var7.next();
        RedstoneSide wireConnection = (RedstoneSide) state.getValue((Property) DIRECTION_TO_WIRE_CONNECTION_PROPERTY.get(direction));
        if (wireConnection != RedstoneSide.NONE && !world.getBlockState(mutable.setWithOffset(pos, direction)).is(this)) {
            mutable.move(Direction.DOWN);
            BlockState blockState = world.getBlockState(mutable);
            if (!blockState.is(Blocks.OBSERVER)) {
                BlockPos blockPos = mutable.relative(direction.getOpposite());
                BlockState blockState2 = blockState.updateShape(direction.getOpposite(), world.getBlockState(blockPos), world, mutable, blockPos);
                updateOrDestroy(blockState, blockState2, world, mutable, flags, maxUpdateDepth);
            }
            mutable.setWithOffset(pos, direction).move(Direction.UP);
            BlockState blockState3 = world.getBlockState(mutable);
            if (!blockState3.is(Blocks.OBSERVER)) {
                BlockPos blockPos2 = mutable.relative(direction.getOpposite());
                BlockState blockState4 = blockState3.updateShape(direction.getOpposite(), world.getBlockState(blockPos2), world, mutable, blockPos2);
                updateOrDestroy(blockState3, blockState4, world, mutable, flags, maxUpdateDepth);
            }
        }
    }
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) Iterator(java.util.Iterator) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) MutableBlockPos(net.minecraft.core.BlockPos.MutableBlockPos) BlockPos(net.minecraft.core.BlockPos) RedstoneSide(net.minecraft.world.level.block.state.properties.RedstoneSide) MutableBlockPos(net.minecraft.core.BlockPos.MutableBlockPos) Direction(net.minecraft.core.Direction) EnumProperty(net.minecraft.world.level.block.state.properties.EnumProperty) Property(net.minecraft.world.level.block.state.properties.Property) IntegerProperty(net.minecraft.world.level.block.state.properties.IntegerProperty)

Aggregations

UnmodifiableIterator (com.google.common.collect.UnmodifiableIterator)5 Iterator (java.util.Iterator)5 Direction (net.minecraft.core.Direction)5 RedstoneSide (net.minecraft.world.level.block.state.properties.RedstoneSide)5 EnumProperty (net.minecraft.world.level.block.state.properties.EnumProperty)4 IntegerProperty (net.minecraft.world.level.block.state.properties.IntegerProperty)4 Property (net.minecraft.world.level.block.state.properties.Property)4 BlockPos (net.minecraft.core.BlockPos)2 MutableBlockPos (net.minecraft.core.BlockPos.MutableBlockPos)2 BlockState (net.minecraft.world.level.block.state.BlockState)1 VoxelShape (net.minecraft.world.phys.shapes.VoxelShape)1