Add a lot

This commit is contained in:
Andrew-71 2024-03-07 11:24:38 +03:00
parent 0f80a8fc69
commit d40dcc4cc2
439 changed files with 8803 additions and 21 deletions

View file

@ -52,6 +52,7 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
SIREN_SOUNDS.add(new SirenSound("Bell", NSE_Sounds.BELL_SIREN_SOUND, 100));
SIREN_SOUNDS.add(new SirenSound("Woop", NSE_Sounds.WOOP_SIREN_SOUND, 40));
SIREN_SOUNDS.add(new SirenSound("Cloister Bell", NSE_Sounds.CLOISTER_SIREN_SOUND, 60));
SIREN_SOUNDS.add(new SirenSound("Kuplinov siren", NSE_Sounds.KUPLINOV_SIREN_SOUND, 120));
}
@Override

View file

@ -0,0 +1,66 @@
package su.a71.new_soviet.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
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 org.jetbrains.annotations.Nullable;
public class StoveBlock extends BlockWithEntity {
public static final DirectionProperty FACING;
public StoveBlock() {
super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.BLOCK));
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(Properties.HORIZONTAL_FACING);
}
@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return null;
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) {
return switch (state.get(FACING)) {
case NORTH, SOUTH -> VoxelShapes.cuboid(0.0625f, 0.0f, 0.3125f, 0.9375f, 0.5625f, 0.6875f);
case EAST, WEST -> VoxelShapes.cuboid(0.3125f, 0.0f, 0.0625f, 0.6875f, 0.5625f, 0.9375f);
default -> VoxelShapes.fullCube();
};
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
}
public BlockState rotate(BlockState state, BlockRotation rotation) {
return state.with(FACING, rotation.rotate(state.get(FACING)));
}
public BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(state.get(FACING)));
}
static {
FACING = Properties.HORIZONTAL_FACING;
}
}

View file

@ -0,0 +1,72 @@
package su.a71.new_soviet.blocks;
import net.minecraft.block.*;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.player.PlayerEntity;
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.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.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.registration.NSE_Sounds;
import su.a71.new_soviet.util.Shapes;
public class WMachineBlock extends HorizontalFacingBlock {
private final Shapes.HorizontalShape blockShape;
public WMachineBlock(Settings settings, Shapes.HorizontalShape blockShape) {
super(settings.notSolid().nonOpaque().noBlockBreakParticles().pistonBehavior(PistonBehavior.DESTROY).strength(0.1f, 2f));
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
this.blockShape = blockShape;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(Properties.HORIZONTAL_FACING);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext ctx) {
return switch (state.get(FACING)) {
case NORTH -> blockShape.north();
case SOUTH -> blockShape.south();
case EAST -> blockShape.east();
case WEST -> blockShape.west();
default -> VoxelShapes.fullCube();
};
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
float pitch = (float) NewSoviet.RANDOM.nextBetween(8, 12) / 10;
float volume = (float) NewSoviet.RANDOM.nextBetween(5, 7) / 10;
world.playSound(null, pos, NSE_Sounds.W_MACHINE_BUTTON_PRESS, SoundCategory.BLOCKS, volume, pitch);
return ActionResult.SUCCESS;
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
}
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {
return !floor.getCollisionShape(world, pos).getFace(Direction.UP).isEmpty() || floor.isSideSolidFullSquare(world, pos, Direction.UP);
}
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockPos blockPos = pos.down();
return this.canPlantOnTop(world.getBlockState(blockPos), world, blockPos);
}
}

View file

@ -10,7 +10,6 @@ import net.minecraft.fluid.Fluids;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager;
@ -30,6 +29,7 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import su.a71.new_soviet.NewSoviet;
import su.a71.new_soviet.registration.NSE_Items;
import su.a71.new_soviet.registration.NSE_Sounds;
import su.a71.new_soviet.util.Shapes;
@ -79,7 +79,7 @@ public class WindowBlock extends HorizontalFacingBlock {
return ActionResult.SUCCESS;
}
} if (player.getInventory().getMainHandStack().getItem() == NSE_Items.SCREWDRIVER && !player.getItemCooldownManager().isCoolingDown(NSE_Items.SCREWDRIVER)) {
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), NSE_Sounds.SCREWDRIVER_SOUND, SoundCategory.BLOCKS, 1.0f, 1f);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), NSE_Sounds.SCREWDRIVER_SOUND, SoundCategory.BLOCKS, 1.0f, (float)NewSoviet.RANDOM.nextBetween(8, 11) / 10);
if (!state.get(CLOSED)) {
player.sendMessage(Text.translatable("block.new_soviet.window.fixed").formatted(Formatting.BOLD), true);
} else if (state.get(CLOSED)) {

View file

@ -0,0 +1,17 @@
package su.a71.new_soviet.blocks.lamps;
import su.a71.new_soviet.util.Shapes;
import java.util.List;
public class DevTableLampBlock extends GoldenTableLampBlock {
public DevTableLampBlock(Settings settings) {
super(settings);
SHAPE = new Shapes.HorizontalShapeLegacy(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)));
}
}