From 855ec863831eb52ea2c7a2a1d402bc2c34b6bd01 Mon Sep 17 00:00:00 2001 From: Justin Parsell Date: Fri, 7 May 2021 15:05:20 -0400 Subject: [PATCH] textures work now lol --- .../parsell/glowstonewire/GlowstoneWire.java | 16 ------ .../common/GlowstoneWireBlock.java | 33 +++++------- .../glowstonewire/core/glowBlocks.java | 1 - .../blockstates/glowstone_wire.json | 50 +++++++++++++------ 4 files changed, 47 insertions(+), 53 deletions(-) diff --git a/src/main/java/me/parsell/glowstonewire/GlowstoneWire.java b/src/main/java/me/parsell/glowstonewire/GlowstoneWire.java index 71a16d6..6478394 100644 --- a/src/main/java/me/parsell/glowstonewire/GlowstoneWire.java +++ b/src/main/java/me/parsell/glowstonewire/GlowstoneWire.java @@ -1,29 +1,13 @@ package me.parsell.glowstonewire; -import java.util.Iterator; - import me.parsell.glowstonewire.core.glowBlocks; import me.parsell.glowstonewire.core.glowItems; import net.fabricmc.api.ModInitializer; -import net.minecraft.util.math.Direction; public class GlowstoneWire implements ModInitializer { @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. - - System.out.println("Hello Fabric world!"); glowBlocks.init(); glowItems.init(); - - String[] states = {"none", "broke", "side", "up"}; - //for(int i = 0; i < 4; i++) - // for (int j = 0; j < 4; j++) - // for (int k = 0; k < 4; k++) - // for (int l = 0; l < 4; l++) - // System.out.println("north: " + states[i] + " south: " + states[j] + " east: " + states[k] + " west: " + states[l]); - } } diff --git a/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java b/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java index e86ddf6..65b4726 100644 --- a/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java +++ b/src/main/java/me/parsell/glowstonewire/common/GlowstoneWireBlock.java @@ -56,20 +56,6 @@ public class GlowstoneWireBlock extends Block{ builder.add(WIRE_CONNECTION_NORTH, WIRE_CONNECTION_EAST, WIRE_CONNECTION_SOUTH, WIRE_CONNECTION_WEST); } - private static boolean isFullyConnected(BlockState state) { - return ((GlowWireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() && - ((GlowWireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() && - ((GlowWireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() && - ((GlowWireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected(); - } - - private static boolean isNotConnected(BlockState state) { - return !((GlowWireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() && - !((GlowWireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() && - !((GlowWireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() && - !((GlowWireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected(); - } - private static boolean hasConnection(BlockState state) { return ((GlowWireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() || ((GlowWireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() || @@ -88,9 +74,14 @@ public class GlowstoneWireBlock extends Block{ } private GlowWireConnection determineConnection(WorldAccess world, BlockPos pos, Direction direction){ - if(world.getBlockState(pos.offset(direction).up()).isOf(this)) - if(!world.getBlockState(pos.offset(direction).up()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) + System.out.println("Determining connections..."); + System.out.println(pos + " is checking up connection at " + pos.offset(direction).up()); + if(world.getBlockState(pos.offset(direction).up()).isOf(this)) { + if(!world.getBlockState(pos.offset(direction).up()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) { + System.out.println(pos + " has found up connection at " + pos.offset(direction).up()); return GlowWireConnection.UP; + } + } if(world.getBlockState(pos.offset(direction).down()).isOf(this)) if(!world.getBlockState(pos.offset(direction).down()).get(DIRECTION_TO_WIRE_CONNECTION.get(direction.getOpposite())).isBroken()) return GlowWireConnection.SIDE; @@ -101,6 +92,8 @@ public class GlowstoneWireBlock extends Block{ return GlowWireConnection.NONE; } + // TODO: Fix this + @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { VoxelShape voxelShape = DOT_VOXELSHAPE; Iterator var3 = Direction.Type.HORIZONTAL.iterator(); @@ -140,7 +133,7 @@ public class GlowstoneWireBlock extends Block{ default: return state; } - } + } @Override public BlockState mirror(BlockState state, BlockMirror mirror) { @@ -152,7 +145,7 @@ public class GlowstoneWireBlock extends Block{ default: return super.mirror(state, mirror); } - } + } @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit){ @@ -173,6 +166,7 @@ public class GlowstoneWireBlock extends Block{ @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { + System.out.println("Update"); if (direction != Direction.DOWN && direction != Direction.UP && !state.get(DIRECTION_TO_WIRE_CONNECTION.get(direction)).isBroken()) state = state.with(DIRECTION_TO_WIRE_CONNECTION.get(direction), determineConnection(world, pos, direction)); return state; @@ -189,7 +183,7 @@ public class GlowstoneWireBlock extends Block{ dropStacks(state, world, pos); world.removeBlock(pos, false); } - } + } static { WIRE_CONNECTION_NORTH = EnumProperty.of("north", GlowWireConnection.class); @@ -202,6 +196,5 @@ public class GlowstoneWireBlock extends Block{ DOT_VOXELSHAPE = Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D); field_24414 = Maps.newEnumMap((Map)ImmutableMap.of(Direction.NORTH, Block.createCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Direction.SOUTH, Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Direction.EAST, Block.createCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Direction.WEST, Block.createCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D))); field_24415 = Maps.newEnumMap((Map)ImmutableMap.of(Direction.NORTH, VoxelShapes.union((VoxelShape)field_24414.get(Direction.NORTH), Block.createCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 16.0D, 1.0D)), Direction.SOUTH, VoxelShapes.union((VoxelShape)field_24414.get(Direction.SOUTH), Block.createCuboidShape(3.0D, 0.0D, 15.0D, 13.0D, 16.0D, 16.0D)), Direction.EAST, VoxelShapes.union((VoxelShape)field_24414.get(Direction.EAST), Block.createCuboidShape(15.0D, 0.0D, 3.0D, 16.0D, 16.0D, 13.0D)), Direction.WEST, VoxelShapes.union((VoxelShape)field_24414.get(Direction.WEST), Block.createCuboidShape(0.0D, 0.0D, 3.0D, 1.0D, 16.0D, 13.0D)))); - } } \ No newline at end of file diff --git a/src/main/java/me/parsell/glowstonewire/core/glowBlocks.java b/src/main/java/me/parsell/glowstonewire/core/glowBlocks.java index e6a1647..007b63a 100644 --- a/src/main/java/me/parsell/glowstonewire/core/glowBlocks.java +++ b/src/main/java/me/parsell/glowstonewire/core/glowBlocks.java @@ -12,6 +12,5 @@ public class glowBlocks { public static void init(){ Registry.register(Registry.BLOCK, new Identifier("glowstonewire", "glowstone_wire"), GLOWSTONEWIRE); - } } diff --git a/src/main/resources/assets/glowstonewire/blockstates/glowstone_wire.json b/src/main/resources/assets/glowstonewire/blockstates/glowstone_wire.json index d46af9f..314b3b7 100644 --- a/src/main/resources/assets/glowstonewire/blockstates/glowstone_wire.json +++ b/src/main/resources/assets/glowstonewire/blockstates/glowstone_wire.json @@ -4,10 +4,10 @@ "when": { "OR": [ { - "south": "none", - "north": "none", - "west": "none", - "east": "none" + "south": "none|broke", + "north": "none|broke", + "west": "none|broke", + "east": "none|broke" }, { "north": "side|up", @@ -39,9 +39,9 @@ }, { "south": "side|up", - "north": "none", - "west": "none", - "east": "none" + "north": "none|broke", + "west": "none|broke", + "east": "none|broke" } ] }, @@ -56,10 +56,16 @@ "south": "side|up" }, { - "south": "none", + "south": "none|broke", "north": "side|up", - "west": "none", - "east": "none" + "west": "none|broke", + "east": "none|broke" + }, + { + "south": "broke", + "north": "side|up", + "west": "broke", + "east": "broke" } ] }, @@ -74,10 +80,16 @@ "east": "side|up" }, { - "south": "none", - "north": "none", + "south": "none|broke", + "north": "none|broke", "west": "side|up", - "east": "none" + "east": "none|broke" + }, + { + "south": "broke", + "north": "broke", + "west": "side|up", + "east": "broke" } ] }, @@ -93,9 +105,15 @@ "west": "side|up" }, { - "south": "none", - "north": "none", - "west": "none", + "south": "none|broke", + "north": "none|broke", + "west": "none|broke", + "east": "side|up" + }, + { + "south": "broke", + "north": "broke", + "west": "broke", "east": "side|up" } ]