Add (broken) blue boundary marker

This commit is contained in:
Andrew-71 2023-10-01 00:39:45 +03:00
parent c07961af31
commit dfaa80fc16
28 changed files with 199 additions and 5 deletions

View file

@ -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
}
}

View file

@ -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);
}
}

View file

@ -289,7 +289,10 @@ public class BlockTagGenerator extends FabricTagProvider.BlockTagProvider {
.add(NSE_Blocks.METAL_PLATING_STAIRS)
.add(NSE_Blocks.METAL_PLATING_SLAB)
.add(NSE_Custom.VINTAGE_LAMP)
.add(NSE_Custom.LIGHT_BULB_LAMP);
.add(NSE_Custom.LIGHT_BULB_LAMP)
.add(NSE_Blocks.BLUE_IRON_BARS)
.add(NSE_Blocks.RUSTY_BLUE_IRON_BARS)
.add(NSE_Blocks.VINTAGE_IRON_BARS);
// Blocks mined with an axe
getOrCreateTagBuilder(BlockTags.AXE_MINEABLE)

View file

@ -12,6 +12,7 @@ import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.text.Text;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import su.a71.new_soviet.blocks.BoundaryMarkerBlock;
import su.a71.new_soviet.blocks.ConcreteWithBarsBlock;
import su.a71.new_soviet.blocks.HandrailBlock;
@ -403,6 +404,8 @@ public class NSE_Blocks extends NSE_BaseRegistration {
public static final StairsBlock NII_FLOOR_STAIRS = new StairsBlock(NII_FLOOR.getDefaultState(), FabricBlockSettings.copy(NII_FLOOR));
public static final SlabBlock NII_FLOOR_SLAB = new SlabBlock(FabricBlockSettings.copy(NII_FLOOR));
public static final Block BLUE_BOUNDARY_MARKER = new BoundaryMarkerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.STONE).hardness(1.5f).resistance(4f).requiresTool().mapColor(MapColor.TERRACOTTA_BLUE));
// Industrial ==========
public static final Block INDUSTRIAL_WARNING = new Block(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).hardness(4f).resistance(6f).requiresTool().mapColor(MapColor.BLACK));
public static final Block RED_WARNING = new Block(FabricBlockSettings.copy(INDUSTRIAL_WARNING).mapColor(MapColor.RED));
@ -423,7 +426,7 @@ public class NSE_Blocks extends NSE_BaseRegistration {
public static final BarrelBlock CRATE = new BarrelBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.CHISELED_BOOKSHELF).nonOpaque().mapColor(MapColor.OAK_TAN).hardness(1.8f));
public static final WallBlock CONCRETE_WALL = new WallBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.STONE).mapColor(MapColor.STONE_GRAY));
public static final HandrailBlock HANDRAIL = new HandrailBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.COPPER).hardness(4f).nonOpaque());
public static final HandrailBlock HANDRAIL = new HandrailBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.COPPER).requiresTool().hardness(4f).nonOpaque());
public static final PaneBlock BLUE_IRON_BARS = new PaneBlock(FabricBlockSettings.copy(Blocks.IRON_BARS));
public static final PaneBlock RUSTY_BLUE_IRON_BARS = new PaneBlock(FabricBlockSettings.copy(BLUE_IRON_BARS));
public static final PaneBlock VINTAGE_IRON_BARS = new PaneBlock(FabricBlockSettings.copy(Blocks.IRON_BARS));
@ -831,6 +834,8 @@ public class NSE_Blocks extends NSE_BaseRegistration {
registerBlock("chiseled_spruce_door", () -> CHISELED_SPRUCE_DOOR, NSE_BUILDING_TAB);
registerBlock("chiseled_birch_door", () -> CHISELED_BIRCH_DOOR, NSE_BUILDING_TAB);
registerBlock("blue_boundary_marker", () -> BLUE_BOUNDARY_MARKER, NSE_BUILDING_TAB);
registerBlock("industrial_warning", () -> INDUSTRIAL_WARNING, NSE_BUILDING_TAB);
registerBlock("gray_warning", () -> GRAY_WARNING, NSE_BUILDING_TAB);
registerBlock("red_warning", () -> RED_WARNING, NSE_BUILDING_TAB);