diff --git a/src/main/java/uk/minersonline/RealisticComputers/ModBlocks.java b/src/main/java/uk/minersonline/RealisticComputers/ModBlocks.java new file mode 100644 index 0000000..3e6dc38 --- /dev/null +++ b/src/main/java/uk/minersonline/RealisticComputers/ModBlocks.java @@ -0,0 +1,31 @@ +package uk.minersonline.RealisticComputers; + +import net.fabricmc.fabric.api.item.v1.FabricItemSettings; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.block.Block; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.item.BlockItem; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; +import uk.minersonline.RealisticComputers.block.VNCTerminal; +import uk.minersonline.RealisticComputers.block.VNCTerminalBlockEntity; + +import static uk.minersonline.RealisticComputers.RealisticComputers.MOD_ID; + +public class ModBlocks { + public static final Block VNC_TERMINAL = new VNCTerminal(FabricBlockSettings.create().strength(4.0f).nonOpaque()); + public static final BlockItem VNC_TERMINAL_ITEM = new BlockItem(VNC_TERMINAL, new FabricItemSettings()); + + public static final BlockEntityType VNC_TERMINAL_BLOCK_ENTITY = Registry.register( + Registries.BLOCK_ENTITY_TYPE, + new Identifier(MOD_ID, "vnc_terminal"), + FabricBlockEntityTypeBuilder.create(VNCTerminalBlockEntity::new, VNC_TERMINAL).build() + ); + + public static void init() { + Registry.register(Registries.BLOCK, new Identifier(MOD_ID, "vnc_terminal"), VNC_TERMINAL); + Registry.register(Registries.ITEM, new Identifier(MOD_ID, "vnc_terminal"), VNC_TERMINAL_ITEM); + } +} diff --git a/src/main/java/uk/minersonline/RealisticComputers/RealisticComputers.java b/src/main/java/uk/minersonline/RealisticComputers/RealisticComputers.java index 00a5c92..f1d3dd1 100644 --- a/src/main/java/uk/minersonline/RealisticComputers/RealisticComputers.java +++ b/src/main/java/uk/minersonline/RealisticComputers/RealisticComputers.java @@ -2,21 +2,32 @@ import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class RealisticComputers implements ModInitializer { - // This logger is used to write text to the console and the log file. - // It is considered best practice to use your mod id as the logger's name. - // That way, it's clear which mod wrote info, warnings, and errors. - public static final Logger LOGGER = LoggerFactory.getLogger("realistic_computers"); + public static final String MOD_ID = "realistic_computers"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + private static final ItemGroup ITEM_GROUP = FabricItemGroup.builder() + .icon(() -> new ItemStack(ModBlocks.VNC_TERMINAL_ITEM)) + .displayName(Text.translatable(MOD_ID+".main_group")) + .entries((context, entries) -> { + entries.add(ModBlocks.VNC_TERMINAL_ITEM); + }) + .build(); @Override public void onInitialize() { - // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like resources) may still be uninitialized. - // Proceed with mild caution. - LOGGER.info("Hello Fabric world!"); + ModBlocks.init(); + Registry.register(Registries.ITEM_GROUP, new Identifier(MOD_ID, "main_group"), ITEM_GROUP); } } \ No newline at end of file diff --git a/src/main/java/uk/minersonline/RealisticComputers/block/VNCTerminal.java b/src/main/java/uk/minersonline/RealisticComputers/block/VNCTerminal.java new file mode 100644 index 0000000..c585f5e --- /dev/null +++ b/src/main/java/uk/minersonline/RealisticComputers/block/VNCTerminal.java @@ -0,0 +1,51 @@ +package uk.minersonline.RealisticComputers.block; + +import net.minecraft.block.*; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.item.ItemPlacementContext; +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; +import org.jetbrains.annotations.Nullable; + +public class VNCTerminal extends HorizontalFacingBlock implements BlockEntityProvider { + public VNCTerminal(Settings settings) { + super(settings); + setDefaultState(getDefaultState().with(Properties.HORIZONTAL_FACING, Direction.NORTH)); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(Properties.HORIZONTAL_FACING); + } + + @SuppressWarnings("deprecation") + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + Direction dir = state.get(FACING); + return switch (dir) { + case NORTH -> VoxelShapes.cuboid(0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f); + case SOUTH -> VoxelShapes.cuboid(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f); + case EAST -> VoxelShapes.cuboid(0.0f, 0.0f, 0.0f, 0.5f, 1.0f, 1.0f); + case WEST -> VoxelShapes.cuboid(0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + default -> VoxelShapes.fullCube(); + }; + } + + @SuppressWarnings("DataFlowIssue") + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()); + } + + + @Nullable + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return new VNCTerminalBlockEntity(pos, state); + } +} diff --git a/src/main/java/uk/minersonline/RealisticComputers/block/VNCTerminalBlockEntity.java b/src/main/java/uk/minersonline/RealisticComputers/block/VNCTerminalBlockEntity.java new file mode 100644 index 0000000..7e420cb --- /dev/null +++ b/src/main/java/uk/minersonline/RealisticComputers/block/VNCTerminalBlockEntity.java @@ -0,0 +1,12 @@ +package uk.minersonline.RealisticComputers.block; + +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; +import uk.minersonline.RealisticComputers.ModBlocks; + +public class VNCTerminalBlockEntity extends BlockEntity { + public VNCTerminalBlockEntity(BlockPos pos, BlockState state) { + super(ModBlocks.VNC_TERMINAL_BLOCK_ENTITY, pos, state); + } +} diff --git a/src/main/resources/assets/realistic_computers/blockstates/vnc_terminal.json b/src/main/resources/assets/realistic_computers/blockstates/vnc_terminal.json new file mode 100644 index 0000000..eca3751 --- /dev/null +++ b/src/main/resources/assets/realistic_computers/blockstates/vnc_terminal.json @@ -0,0 +1,9 @@ +{ + "variants": { + "facing=north": { "model": "realistic_computers:block/vnc_terminal" }, + "facing=east": { "model": "realistic_computers:block/vnc_terminal", "y": 90 }, + "facing=south": { "model": "realistic_computers:block/vnc_terminal", "y": 180 }, + "facing=west": { "model": "realistic_computers:block/vnc_terminal", "y": 270 } + } +} + diff --git a/src/main/resources/assets/realistic_computers/lang/en_us.json b/src/main/resources/assets/realistic_computers/lang/en_us.json new file mode 100644 index 0000000..006153c --- /dev/null +++ b/src/main/resources/assets/realistic_computers/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "realistic_computers.main_group": "Realistic Computers", + "block.realistic_computers.vnc_terminal": "VNC Terminal" +} \ No newline at end of file diff --git a/src/main/resources/assets/realistic_computers/models/block/vnc_terminal.json b/src/main/resources/assets/realistic_computers/models/block/vnc_terminal.json new file mode 100644 index 0000000..79f11c3 --- /dev/null +++ b/src/main/resources/assets/realistic_computers/models/block/vnc_terminal.json @@ -0,0 +1,172 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "texture_size": [32, 32], + "textures": { + "0": "realistic_computers:block/vnc_terminal/keyboard", + "1": "realistic_computers:block/vnc_terminal/mouse", + "2": "realistic_computers:block/vnc_terminal/stand", + "3": "realistic_computers:block/vnc_terminal/stand2", + "4": "realistic_computers:block/vnc_terminal/frame_long", + "5": "realistic_computers:block/vnc_terminal/frame_back", + "6": "realistic_computers:block/vnc_terminal/frame_side", + "7": "realistic_computers:block/vnc_terminal/screen", + "particle": "realistic_computers:block/vnc_terminal/keyboard" + }, + "elements": [ + { + "from": [0, 5, 12], + "to": [16, 6, 14], + "faces": { + "north": {"uv": [0, 4, 16, 5], "texture": "#4", "cullface": "north"}, + "east": {"uv": [0, 6, 2, 7], "texture": "#4", "cullface": "east"}, + "south": {"uv": [0, 5, 16, 6], "texture": "#4", "cullface": "south"}, + "west": {"uv": [2, 6, 4, 7], "texture": "#4", "cullface": "west"}, + "up": {"uv": [16, 2, 0, 0], "texture": "#4", "cullface": "up"}, + "down": {"uv": [16, 2, 0, 4], "texture": "#4", "cullface": "down"} + } + }, + { + "from": [0, 14, 12], + "to": [16, 15, 14], + "faces": { + "north": {"uv": [0, 0, 16, 1], "texture": "#4", "cullface": "north"}, + "east": {"uv": [0, 0, 2, 1], "texture": "#4", "cullface": "east"}, + "south": {"uv": [0, 0, 16, 1], "texture": "#4", "cullface": "south"}, + "west": {"uv": [0, 0, 2, 1], "texture": "#4", "cullface": "west"}, + "up": {"uv": [0, 0, 16, 2], "texture": "#4", "cullface": "up"}, + "down": {"uv": [0, 0, 16, 2], "texture": "#4", "cullface": "down"} + } + }, + { + "from": [1, 6, 13], + "to": [15, 14, 14], + "faces": { + "north": {"uv": [0, 0, 7, 4], "texture": "#5", "cullface": "north"}, + "east": {"uv": [7, 1, 7.5, 5], "texture": "#5", "cullface": "east"}, + "south": {"uv": [0, 4, 7, 8], "texture": "#5", "cullface": "south"}, + "west": {"uv": [7, 5, 7.5, 9], "texture": "#5", "cullface": "west"}, + "up": {"uv": [14, 0.5, 7, 0], "texture": "#5", "cullface": "up"}, + "down": {"uv": [14, 0.5, 7, 1], "texture": "#5", "cullface": "down"} + } + }, + { + "name": "screen", + "from": [1, 6, 12], + "to": [15, 14, 13], + "faces": { + "north": {"uv": [0, 0, 7, 4], "texture": "#7", "cullface": "north"}, + "east": {"uv": [7, 1, 7.5, 5], "texture": "#7", "cullface": "east"}, + "south": {"uv": [0, 4, 7, 8], "texture": "#7", "cullface": "south"}, + "west": {"uv": [7, 5, 7.5, 9], "texture": "#7", "cullface": "west"}, + "up": {"uv": [14, 0.5, 7, 0], "texture": "#7", "cullface": "up"}, + "down": {"uv": [14, 0.5, 7, 1], "texture": "#7", "cullface": "down"} + } + }, + { + "from": [15, 6, 12], + "to": [16, 14, 14], + "faces": { + "north": {"uv": [8, 0, 10, 16], "texture": "#6", "cullface": "north"}, + "east": {"uv": [0, 0, 4, 16], "texture": "#6", "cullface": "east"}, + "south": {"uv": [10, 0, 12, 16], "texture": "#6", "cullface": "south"}, + "west": {"uv": [4, 0, 8, 16], "texture": "#6", "cullface": "west"}, + "up": {"uv": [14, 4, 12, 0], "texture": "#6", "cullface": "up"}, + "down": {"uv": [14, 4, 12, 8], "texture": "#6", "cullface": "down"} + } + }, + { + "from": [0, 6, 12], + "to": [1, 14, 14], + "faces": { + "north": {"uv": [0, 0, 0.5, 4], "texture": "#6", "cullface": "north"}, + "east": {"uv": [0, 0, 1, 4], "texture": "#6", "cullface": "east"}, + "south": {"uv": [0, 0, 0.5, 4], "texture": "#6", "cullface": "south"}, + "west": {"uv": [0, 0, 1, 4], "texture": "#6", "cullface": "west"}, + "up": {"uv": [0, 0, 0.5, 1], "texture": "#6", "cullface": "up"}, + "down": {"uv": [0, 0, 0.5, 1], "texture": "#6", "cullface": "down"} + } + }, + { + "name": "stand1", + "from": [5, 0, 12], + "to": [11, 2, 14], + "faces": { + "north": {"uv": [0, 0, 12, 4], "texture": "#2","cullface": "north"}, + "east": {"uv": [12, 0, 16, 4], "texture": "#2", "cullface": "east"}, + "south": {"uv": [0, 4, 12, 8], "texture": "#2", "cullface": "south"}, + "west": {"uv": [12, 4, 16, 8], "texture": "#2", "cullface": "west"}, + "up": {"uv": [12, 12, 0, 8], "texture": "#2", "cullface": "up"}, + "down": {"uv": [12, 12, 0, 16], "texture": "#2", "cullface": "down"} + } + }, + { + "name": "stand2", + "from": [7, 2, 12], + "to": [9, 5, 14], + "faces": { + "north": {"uv": [0, 0, 4, 6], "texture": "#3", "cullface": "north"}, + "east": {"uv": [4, 0, 8, 6], "texture": "#3", "cullface": "east"}, + "south": {"uv": [0, 6, 4, 12], "texture": "#3", "cullface": "south"}, + "west": {"uv": [4, 6, 8, 12], "texture": "#3", "cullface": "west"}, + "up": {"uv": [12, 4, 8, 0], "texture": "#3", "cullface": "up"}, + "down": {"uv": [12, 4, 8, 8], "texture": "#3", "cullface": "down"} + } + }, + { + "name": "keyboard", + "from": [4, 0, 2], + "to": [16, 1, 8], + "faces": { + "north": {"uv": [0, 6, 6, 6.5], "texture": "#0", "cullface": "north"}, + "east": {"uv": [6, 0.5, 9, 1], "texture": "#0", "cullface": "east"}, + "south": {"uv": [6, 0, 12, 0.5], "texture": "#0", "cullface": "south"}, + "west": {"uv": [6, 1, 9, 1.5], "texture": "#0", "cullface": "west"}, + "up": {"uv": [6, 3, 0, 0], "texture": "#0", "cullface": "up"}, + "down": {"uv": [6, 3, 0, 6], "texture": "#0", "cullface": "down"} + } + }, + { + "name": "mouse", + "from": [0, 0, 2], + "to": [3, 1, 6], + "faces": { + "north": {"uv": [0, 10, 6, 12], "texture": "#1", "cullface": "north"}, + "east": {"uv": [0, 8, 8, 10], "texture": "#1", "cullface": "east"}, + "south": {"uv": [6, 10, 12, 12], "texture": "#1", "cullface": "south"}, + "west": {"uv": [8, 8, 16, 10], "texture": "#1", "cullface": "west"}, + "up": {"uv": [6, 8, 0, 0], "texture": "#1", "cullface": "up"}, + "down": {"uv": [12, 0, 6, 8], "texture": "#1", "cullface": "down"} + } + } + ], + "groups": [ + { + "name": "monitor", + "origin": [8, 8, 8], + "color": 0, + "children": [ + { + "name": "screen_frame", + "origin": [0, 0, 0], + "color": 0, + "children": [0, 1, 2, 3, 4, 5] + }, + { + "name": "stand", + "origin": [0, 0, 0], + "color": 0, + "children": [6, 7] + } + ] + }, + 8, + { + "name": "group", + "origin": [0, 0, 0], + "color": 0, + "children": [] + }, + 9 + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/realistic_computers/models/item/vnc_terminal.json b/src/main/resources/assets/realistic_computers/models/item/vnc_terminal.json new file mode 100644 index 0000000..9cbd9af --- /dev/null +++ b/src/main/resources/assets/realistic_computers/models/item/vnc_terminal.json @@ -0,0 +1,3 @@ +{ + "parent": "realistic_computers:block/vnc_terminal" +} \ No newline at end of file diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_back.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_back.png new file mode 100644 index 0000000..624cf0c Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_back.png differ diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_long.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_long.png new file mode 100644 index 0000000..7eb2c66 Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_long.png differ diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_side.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_side.png new file mode 100644 index 0000000..008a3c7 Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/frame_side.png differ diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/keyboard.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/keyboard.png new file mode 100644 index 0000000..ae29502 Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/keyboard.png differ diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/mouse.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/mouse.png new file mode 100644 index 0000000..6e5bb34 Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/mouse.png differ diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/screen.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/screen.png new file mode 100644 index 0000000..591ce6a Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/screen.png differ diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/stand.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/stand.png new file mode 100644 index 0000000..02b6de0 Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/stand.png differ diff --git a/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/stand2.png b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/stand2.png new file mode 100644 index 0000000..b5f380c Binary files /dev/null and b/src/main/resources/assets/realistic_computers/textures/block/vnc_terminal/stand2.png differ diff --git a/src/main/resources/data/realistic_computers/blocks/vnc_terminal.json b/src/main/resources/data/realistic_computers/blocks/vnc_terminal.json new file mode 100644 index 0000000..f75492b --- /dev/null +++ b/src/main/resources/data/realistic_computers/blocks/vnc_terminal.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "realistic_computers:vnc_terminal" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file