textures work now lol
This commit is contained in:
parent
6beb4911ac
commit
855ec86383
|
@ -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]);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))));
|
||||
|
||||
}
|
||||
}
|
|
@ -12,6 +12,5 @@ public class glowBlocks {
|
|||
|
||||
public static void init(){
|
||||
Registry.register(Registry.BLOCK, new Identifier("glowstonewire", "glowstone_wire"), GLOWSTONEWIRE);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue