Davey?
This commit is contained in:
parent
0bf6453e69
commit
83a976ae8b
26 changed files with 731 additions and 16 deletions
|
@ -59,16 +59,6 @@ public class GoldenTableLampBlock extends LampBlock {
|
|||
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
|
||||
}
|
||||
|
||||
public VoxelShape getStandingShape(){
|
||||
VoxelShape shape = VoxelShapes.empty();
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.4375, 0.25, 0.4375, 0.5625, 0.875, 0.5625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.375, 0, 0.375, 0.625, 0.25, 0.625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.25, 0.6875, 0.25, 0.75, 0.9375, 0.75));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.125, 0.3125, 0.125, 0.875, 0.6875, 0.875));
|
||||
shape.simplify();
|
||||
return shape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package su.a71.new_soviet.blocks.lamps.lamp_post;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.ai.pathing.NavigationType;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
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;
|
||||
import net.minecraft.world.WorldView;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.a71.new_soviet.util.Shapes;
|
||||
|
||||
public class LampPostLampBlock extends Block implements Waterloggable {
|
||||
public static final DirectionProperty FACING;
|
||||
public static final BooleanProperty WATERLOGGED;
|
||||
public Shapes.HorizontalShape SHAPE;
|
||||
|
||||
public LampPostLampBlock(AbstractBlock.Settings settings, Shapes.HorizontalShape shape) {
|
||||
super(settings.luminance((state) -> 14));
|
||||
SHAPE = shape;
|
||||
this.setDefaultState(this.stateManager.getDefaultState()
|
||||
.with(WATERLOGGED, false)
|
||||
.with(Properties.HORIZONTAL_FACING, Direction.NORTH));
|
||||
|
||||
}
|
||||
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
Direction dir = state.get(FACING);
|
||||
return switch (dir) {
|
||||
case NORTH -> SHAPE.north();
|
||||
case SOUTH -> SHAPE.south();
|
||||
case EAST -> SHAPE.east();
|
||||
case WEST -> SHAPE.west();
|
||||
default -> VoxelShapes.fullCube();
|
||||
};
|
||||
}
|
||||
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
Direction direction = Direction.DOWN;
|
||||
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
|
||||
Direction[] directions = ctx.getPlacementDirections();
|
||||
for (Direction direction : directions) {
|
||||
if (direction.getAxis() == Direction.Axis.Y) {
|
||||
BlockState blockState = this.getDefaultState();
|
||||
if (blockState.canPlaceAt(ctx.getWorld(), ctx.getBlockPos())) {
|
||||
return blockState
|
||||
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER)
|
||||
.with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(new Property[]{WATERLOGGED, Properties.HORIZONTAL_FACING});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.rotate(mirror.getRotation((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
static {
|
||||
WATERLOGGED = Properties.WATERLOGGED;
|
||||
FACING = Properties.HORIZONTAL_FACING;
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ public class DiceItem extends Item {
|
|||
world.playSound((PlayerEntity)null, user.getX(), user.getY(), user.getZ(), NSE_Sounds.DICE_SOUND, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
output.append(NewSoviet.RANDOM.nextBetween(1, this.getSides())).append(", ");
|
||||
}
|
||||
user.sendMessage(Text.translatable(itemStack.getCount() == 1 ? "item.new_soviet.dice.thrown" : "item.new_soviet.dice.thrown_multiple").append(" " + output.subSequence(0, output.length() - 2)), Config.INSTANCE.shouldAnnounceDice());
|
||||
user.sendMessage(Text.translatable(itemStack.getCount() == 1 ? "item.new_soviet.dice.thrown" : "item.new_soviet.dice.thrown_multiple").append(" " + output.subSequence(0, output.length() - 2)), !Config.INSTANCE.shouldAnnounceDice());
|
||||
}
|
||||
|
||||
user.increaseStat(Stats.USED.getOrCreateStat(this), itemStack.getCount());
|
||||
|
|
|
@ -24,7 +24,11 @@ import su.a71.new_soviet.blocks.lamps.LightBulbLampBlock;
|
|||
import su.a71.new_soviet.blocks.lamps.TableLampBlock;
|
||||
import su.a71.new_soviet.blocks.lamps.VintageLampBlock;
|
||||
import su.a71.new_soviet.blocks.lamps.lamp_post.LampPostBaseBlock;
|
||||
import su.a71.new_soviet.blocks.lamps.lamp_post.LampPostLampBlock;
|
||||
import su.a71.new_soviet.entity.TVBlockEntity;
|
||||
import su.a71.new_soviet.util.Shapes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NSE_Custom extends NSE_BaseRegistration {
|
||||
public static final TVBlock TV = new TVBlock(FabricBlockSettings.create().mapColor(MapColor.TERRACOTTA_YELLOW));
|
||||
|
@ -41,6 +45,30 @@ public class NSE_Custom extends NSE_BaseRegistration {
|
|||
public static final LightBulbLampBlock LIGHT_BULB_LAMP = new LightBulbLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.GLASS).strength(0.9f, 1.5f).mapColor(MapColor.WHITE).requiresTool());
|
||||
|
||||
public static final LampPostBaseBlock LAMP_POST_BASE = new LampPostBaseBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY));
|
||||
public static final LampPostLampBlock CAGED_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY),
|
||||
new Shapes.HorizontalShape(List.of(
|
||||
List.of(5.0, 0.0, 5.0, 11.0, 2.0, 11.0),
|
||||
List.of(7.0, 2.0, 7.0, 9.0, 4.0, 9.0),
|
||||
List.of(6.0, 4.0, 6.0, 10.0, 5.0, 10.0),
|
||||
List.of(3.0, 9.0, 3.0, 13.0, 13.0, 7.0))));
|
||||
public static final LampPostLampBlock MODERN_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY),
|
||||
new Shapes.HorizontalShape(List.of(
|
||||
List.of(5.0, 0.0, 5.0, 11.0, 2.0, 11.0),
|
||||
List.of(7.0, 2.0, 7.0, 9.0, 4.0, 9.0),
|
||||
List.of(6.0, 4.0, 6.0, 10.0, 5.0, 10.0),
|
||||
List.of(3.0, 9.0, 3.0, 13.0, 13.0, 7.0))));
|
||||
public static final LampPostLampBlock BIG_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY),
|
||||
new Shapes.HorizontalShape(List.of(
|
||||
List.of(5.0, 0.0, 5.0, 11.0, 2.0, 11.0),
|
||||
List.of(7.0, 2.0, 7.0, 9.0, 4.0, 9.0),
|
||||
List.of(6.0, 4.0, 6.0, 10.0, 5.0, 10.0),
|
||||
List.of(3.0, 9.0, 3.0, 13.0, 13.0, 7.0))));
|
||||
public static final LampPostLampBlock VINTAGE_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY),
|
||||
new Shapes.HorizontalShape(List.of(
|
||||
List.of(5.0, 0.0, 5.0, 11.0, 2.0, 11.0),
|
||||
List.of(7.0, 2.0, 7.0, 9.0, 4.0, 9.0),
|
||||
List.of(6.0, 4.0, 6.0, 10.0, 5.0, 10.0),
|
||||
List.of(3.0, 9.0, 3.0, 13.0, 13.0, 7.0))));
|
||||
|
||||
public static final CeilingFanBlock CEILING_FAN = new CeilingFanBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.WHITE));
|
||||
|
||||
|
@ -80,6 +108,12 @@ public class NSE_Custom extends NSE_BaseRegistration {
|
|||
registerBlock("golden_table_lamp", () -> GOLDEN_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("vintage_lamp", () -> VINTAGE_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("light_bulb_lamp", () -> LIGHT_BULB_LAMP, NSE_CUSTOM_TAB);
|
||||
|
||||
registerBlock("caged_post_lamp", () -> CAGED_POST_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("modern_post_lamp", () -> MODERN_POST_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("big_post_lamp", () -> BIG_POST_LAMP, NSE_CUSTOM_TAB);
|
||||
registerBlock("vintage_post_lamp", () -> VINTAGE_POST_LAMP, NSE_CUSTOM_TAB);
|
||||
|
||||
registerBlock("lamp_post_base", () -> LAMP_POST_BASE, NSE_CUSTOM_TAB);
|
||||
registerBlock("ceiling_fan", () -> CEILING_FAN, NSE_CUSTOM_TAB);
|
||||
registerBlock("siren", () -> SIREN, NSE_CUSTOM_TAB);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue