Add (broken) blue boundary marker
This commit is contained in:
parent
c07961af31
commit
dfaa80fc16
28 changed files with 199 additions and 5 deletions
|
@ -0,0 +1,81 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
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;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
|
||||
// TODO: BLOCKTAGS! LOOTABLES!
|
||||
public class BoundaryMarkerBlock extends Block implements Waterloggable {
|
||||
public static final BooleanProperty WATERLOGGED;
|
||||
public static final IntProperty COLOUR;
|
||||
public static final VoxelShape SHAPE;
|
||||
|
||||
public BoundaryMarkerBlock(Settings settings) {
|
||||
super(settings);
|
||||
setDefaultState(getDefaultState()
|
||||
.with(WATERLOGGED, false)
|
||||
.with(COLOUR, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(WATERLOGGED, COLOUR);
|
||||
}
|
||||
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
|
||||
if (player.getInventory().getMainHandStack().getItem() instanceof DyeItem) {
|
||||
if (!world.isClient()) {
|
||||
if (!player.isCreative()) {
|
||||
player.getInventory().getMainHandStack().decrement(1);
|
||||
}
|
||||
world.playSound((PlayerEntity)null, pos, SoundEvents.ITEM_DYE_USE, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
// world.setBlockState(pos, state.with(COLOUR, player.getInventory().getMainHandStack().getItem()))
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return super.onUse(state, world, pos, player, hand, hit);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 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;
|
||||
SHAPE = Block.createCuboidShape(5, 0, 5, 11, 16, 11);
|
||||
COLOUR = IntProperty.of("border_colour", 0, 16); // 0 - undyed, 1-16 = dyes
|
||||
}
|
||||
}
|
|
@ -12,6 +12,8 @@ import net.minecraft.state.property.DirectionProperty;
|
|||
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.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
|
@ -20,6 +22,8 @@ import org.jetbrains.annotations.Nullable;
|
|||
public class ConcreteWithBarsBlock extends HorizontalFacingBlock implements Waterloggable {
|
||||
public static final DirectionProperty VERTICAL_DIRECTION;
|
||||
public static final BooleanProperty WATERLOGGED;
|
||||
public static final VoxelShape SHAPE_UP;
|
||||
public static final VoxelShape SHAPE_DOWN;
|
||||
|
||||
public ConcreteWithBarsBlock(Settings settings) {
|
||||
super(settings);
|
||||
|
@ -52,6 +56,13 @@ public class ConcreteWithBarsBlock extends HorizontalFacingBlock implements Wate
|
|||
}
|
||||
}
|
||||
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
if (state.get(VERTICAL_DIRECTION) == Direction.DOWN) {
|
||||
return SHAPE_UP;
|
||||
}
|
||||
return SHAPE_DOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
|
@ -67,5 +78,7 @@ public class ConcreteWithBarsBlock extends HorizontalFacingBlock implements Wate
|
|||
static {
|
||||
VERTICAL_DIRECTION = Properties.VERTICAL_DIRECTION;
|
||||
WATERLOGGED = Properties.WATERLOGGED;
|
||||
SHAPE_DOWN = Block.createCuboidShape(0, 0, 0, 16, 8, 16);
|
||||
SHAPE_UP = Block.createCuboidShape(0, 8, 0, 16, 16, 16);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue