Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
feat: initial vnc terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
ajh123 committed Feb 10, 2024
1 parent 767866d commit 9f6fa70
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 8 deletions.
31 changes: 31 additions & 0 deletions src/main/java/uk/minersonline/RealisticComputers/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -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<VNCTerminalBlockEntity> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<Block, BlockState> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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 }
}
}

4 changes: 4 additions & 0 deletions src/main/resources/assets/realistic_computers/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"realistic_computers.main_group": "Realistic Computers",
"block.realistic_computers.vnc_terminal": "VNC Terminal"
}
Original file line number Diff line number Diff line change
@@ -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
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "realistic_computers:block/vnc_terminal"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "realistic_computers:vnc_terminal"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

0 comments on commit 9f6fa70

Please sign in to comment.