TVs, radios, and a lot to do

This commit is contained in:
Andrew-71 2023-07-13 23:24:18 +03:00
parent 222fa946a3
commit 99eab1b9ca
192 changed files with 12886 additions and 41 deletions

View file

@ -4,6 +4,7 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BarrelBlock;
import net.minecraft.block.Block;
import net.minecraft.block.WallBlock;
import net.minecraft.item.BlockItem;
@ -119,6 +120,7 @@ public class NSE_Blocks {
public static final Block MAGENTA_WARNING = new Block(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL));
public static final Block METAL_PLATING = new Block(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL));
public static final Block CRATE = new Block(FabricBlockSettings.create().sounds(BlockSoundGroup.WOOD).nonOpaque());
public static final WallBlock CONCRETE_WALL = new WallBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.STONE));
// WOOD/FLOOR ======
@ -261,6 +263,7 @@ public class NSE_Blocks {
register("magenta_warning", () -> MAGENTA_WARNING, NSE_BUILDING_TAB);
register("metal_plating", () -> METAL_PLATING, NSE_BUILDING_TAB);
register("crate", () -> CRATE, NSE_BUILDING_TAB);
register("concrete_wall", () -> CONCRETE_WALL, NSE_BUILDING_TAB); // TODO: Broken
register("herringbone_acacia_planks", () -> HERRINGBONE_ACACIA_PLANKS, NSE_BUILDING_TAB);

View file

@ -0,0 +1,54 @@
package su.a71.new_soviet;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import su.a71.new_soviet.blocks.RadioBlock;
import su.a71.new_soviet.blocks.TVBlock;
import java.util.Optional;
import java.util.function.Supplier;
public class NSE_Custom {
public static final TVBlock TV = new TVBlock();
public static final TVBlock RED_TV = new TVBlock();
public static final TVBlock BROWN_TV = new TVBlock();
public static final RadioBlock RADIO = new RadioBlock();
private static final ItemGroup NSE_CUSTOM_TAB = FabricItemGroup.builder()
.icon(() -> new ItemStack(TV))
.displayName(Text.translatable("itemGroup.new_soviet.custom"))
.build();
private static void register(String name, Supplier<? extends Block> supplier, ItemGroup tab) {
Registry.register(Registries.BLOCK, new Identifier(NewSoviet.MOD_ID, name), supplier.get());
BlockItem blockItem = new BlockItem(supplier.get(), new FabricItemSettings());
Registry.register(Registries.ITEM, new Identifier(NewSoviet.MOD_ID, name), blockItem);
Optional<RegistryKey<ItemGroup>> key = Registries.ITEM_GROUP.getKey(tab);
key.ifPresent(itemGroupRegistryKey -> ItemGroupEvents.modifyEntriesEvent(itemGroupRegistryKey).register(content -> {
content.add(blockItem);
}));
}
public static void init() {
Registry.register(Registries.ITEM_GROUP, new Identifier("new_soviet", "custom"), NSE_CUSTOM_TAB);
register("tv", () -> TV, NSE_CUSTOM_TAB);
register("red_tv", () -> RED_TV, NSE_CUSTOM_TAB);
register("brown_tv", () -> BROWN_TV, NSE_CUSTOM_TAB);
register("radio", () -> RADIO, NSE_CUSTOM_TAB);
}
}

View file

@ -22,5 +22,6 @@ public class NewSoviet implements ModInitializer {
public void onInitialize() {
NSE_Blocks.init();
NSE_Items.init();
NSE_Custom.init();
}
}

View file

@ -0,0 +1,11 @@
package su.a71.new_soviet.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
public class AirRaidBlock extends Block {
public AirRaidBlock(Settings settings) {
super(settings);
}
}

View file

@ -0,0 +1,47 @@
package su.a71.new_soviet.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.ShapeContext;
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.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;
public class RadioBlock extends HorizontalFacingBlock {
public RadioBlock() {
super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY));
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
}
@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) {
Direction dir = state.get(FACING);
switch(dir) {
case NORTH, SOUTH:
return VoxelShapes.cuboid(0.0625f, 0.0f, 0.3125f, 0.9375f, 0.5625f, 0.6875f);
case EAST, WEST:
return VoxelShapes.cuboid(0.3125f, 0.0f, 0.0625f, 0.6875f, 0.5625f, 0.9375f);
default:
return VoxelShapes.fullCube();
}
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
}
}

View file

@ -0,0 +1,49 @@
package su.a71.new_soviet.blocks;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.block.ShapeContext;
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.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;
public class TVBlock extends HorizontalFacingBlock {
public TVBlock() {
super(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).notSolid().pistonBehavior(PistonBehavior.DESTROY));
setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH));
}
@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) {
Direction dir = state.get(FACING);
switch(dir) {
case NORTH, SOUTH:
return VoxelShapes.cuboid(0.0f, 0.0f, 0.1875f, 1.0f, 0.8125f, 0.8125f);
case EAST, WEST:
return VoxelShapes.cuboid(0.1875f, 0.0f, 0.0f, 0.8125f, 0.8125f, 1.0f);
default:
return VoxelShapes.fullCube();
}
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
}
}