Various fixes and changes, see CHANGELOG

This commit is contained in:
Andrew-71 2023-10-19 20:59:58 +03:00
parent 24e07523da
commit 55724bb0a2
140 changed files with 1074 additions and 3141 deletions

View file

@ -83,7 +83,7 @@ public class CeilingFanBlock extends Block implements Waterloggable {
}
static {
SHAPE = VoxelShapes.union(Block.createCuboidShape(4.0, 2.0, 4.0, 12.0, 7.0, 12.0), Block.createCuboidShape(7.0, 7.0, 7.0, 9.0, 13.0, 9.0), Block.createCuboidShape(6.0, 13.0, 6.0, 10.0, 16.0, 10.0));
SHAPE = VoxelShapes.union(Block.createCuboidShape(4.0, 1.0, 4.0, 12.0, 4.0, 12.0), Block.createCuboidShape(6.5, 3.0, 6.5, 9.5, 7.0, 9.5), Block.createCuboidShape(7.5, 7.0, 7.5, 8.5, 13.0, 8.5), Block.createCuboidShape(6.5, 13.0, 6.5, 9.5, 16.0, 9.5));
ON = RedstoneTorchBlock.LIT;
WATERLOGGED = Properties.WATERLOGGED;
}

View file

@ -3,25 +3,33 @@ package su.a71.new_soviet.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
public class RadioReceiverBlock extends HorizontalFacingBlock implements Waterloggable {
public static final BooleanProperty WATERLOGGED;
public class RadioReceiverBlock extends HorizontalFacingBlock {
public RadioReceiverBlock() {
super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY).strength(1f, 2f).mapColor(MapColor.PALE_YELLOW));
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
setDefaultState(getDefaultState()
.with(Properties.HORIZONTAL_FACING, Direction.NORTH)
.with(WATERLOGGED, false));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(Properties.HORIZONTAL_FACING);
builder.add(Properties.HORIZONTAL_FACING, WATERLOGGED);
}
@Override
@ -36,6 +44,26 @@ public class RadioReceiverBlock extends HorizontalFacingBlock {
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
return super.getPlacementState(ctx)
.with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite())
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
}
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (state.get(WATERLOGGED)) {
world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
}
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
}
static {
WATERLOGGED = Properties.WATERLOGGED;
}
}

View file

@ -3,6 +3,7 @@ package su.a71.new_soviet.blocks;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
@ -13,6 +14,8 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -35,10 +38,20 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide
public static final BooleanProperty BROKEN;
public static final BooleanProperty ON;
public static final BooleanProperty WATERLOGGED;
public static final BooleanProperty INVERTED;
public TVBlock(AbstractBlock.Settings settings) {
super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.BLOCK).strength(1f, 2f));
super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.BLOCK).strength(1f, 2f)
.luminance((BlockState state) -> {
if (state.get(BROKEN)) {
return 0;
}
if (state.get(INVERTED)) {
return state.get(ON) ? 0 : 5;
} else {
return state.get(ON) ? 5 : 0;
}
}));
setDefaultState(getDefaultState()
.with(Properties.HORIZONTAL_FACING, Direction.NORTH)
.with(WATERLOGGED, false)
@ -47,7 +60,7 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(Properties.HORIZONTAL_FACING, WATERLOGGED, ON, BROKEN);
builder.add(Properties.HORIZONTAL_FACING, WATERLOGGED, ON, BROKEN, INVERTED);
}
@Override
@ -68,9 +81,20 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide
.with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite())
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER)
.with(ON, ctx.getWorld().isReceivingRedstonePower(ctx.getBlockPos()))
.with(INVERTED, false)
.with(BROKEN, false);
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient) {
world.setBlockState(pos, state.cycle(INVERTED), 2);
}
float f = state.get(ON) ? 1f : 0.9f;
world.playSound(null, pos, NSE_Sounds.SWITCH_PRESS, SoundCategory.BLOCKS, 0.6f, f);
return ActionResult.SUCCESS;
}
@Override
public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) {
if (!state.get(BROKEN)) {
@ -121,5 +145,6 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide
ON = RedstoneTorchBlock.LIT;
WATERLOGGED = Properties.WATERLOGGED;
BROKEN = Properties.CRACKED;
INVERTED = Properties.INVERTED;
}
}