attempt to get lines to work
This commit is contained in:
parent
4360b0381a
commit
bafe5feca3
|
@ -1,10 +1,14 @@
|
||||||
package me.parsell.glowstonewire.common;
|
package me.parsell.glowstonewire.common;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import me.parsell.glowstonewire.core.glowBlocks;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
@ -15,6 +19,7 @@ import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.state.StateManager;
|
import net.minecraft.state.StateManager;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.state.property.Property;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.BlockMirror;
|
import net.minecraft.util.BlockMirror;
|
||||||
import net.minecraft.util.BlockRotation;
|
import net.minecraft.util.BlockRotation;
|
||||||
|
@ -25,6 +30,7 @@ import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldAccess;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
|
|
||||||
public class GlowstoneWireBlock extends Block{
|
public class GlowstoneWireBlock extends Block{
|
||||||
|
@ -73,8 +79,27 @@ public class GlowstoneWireBlock extends Block{
|
||||||
return DOT_SHAPE;
|
return DOT_SHAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This decides what I should look like when I'm placed
|
||||||
public BlockState getPlacecmentState(ItemPlacementContext ctx){
|
public BlockState getPlacecmentState(ItemPlacementContext ctx){
|
||||||
return this.getDefaultState();
|
World world = ctx.getWorld();
|
||||||
|
BlockPos placePos = ctx.getBlockPos();
|
||||||
|
BlockState state = this.getDefaultState();
|
||||||
|
if(world.getBlockState(placePos.offset(Direction.NORTH)).isOf(this))
|
||||||
|
state = state.with(WIRE_CONNECTION_NORTH, WireConnection.SIDE);
|
||||||
|
if(world.getBlockState(placePos.offset(Direction.SOUTH)).isOf(this))
|
||||||
|
state = state.with(WIRE_CONNECTION_SOUTH, WireConnection.SIDE);
|
||||||
|
if(world.getBlockState(placePos.offset(Direction.EAST)).isOf(this))
|
||||||
|
state = state.with(WIRE_CONNECTION_EAST, WireConnection.SIDE);
|
||||||
|
if(world.getBlockState(placePos.offset(Direction.WEST)).isOf(this))
|
||||||
|
state = state.with(WIRE_CONNECTION_WEST, WireConnection.SIDE);
|
||||||
|
System.out.println(state.toString());
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This decides what I should look like whens something around me happens
|
||||||
|
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
|
||||||
|
System.out.println("state for neighbor update w: " + state.toString() + ", " + direction.toString() + ", " + pos.toString() + ", " + posFrom.toString());
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
|
@ -120,7 +145,7 @@ public class GlowstoneWireBlock extends Block{
|
||||||
return ActionResult.SUCCESS;
|
return ActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(World world, BlockPos pos, BlockState state){
|
/* public void update(World world, BlockPos pos, BlockState state){
|
||||||
System.out.println("Update");
|
System.out.println("Update");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -128,7 +153,7 @@ public class GlowstoneWireBlock extends Block{
|
||||||
// Check if I'm this,
|
// Check if I'm this,
|
||||||
// then update all my neighbors
|
// then update all my neighbors
|
||||||
// then tell my neighbors to update all their neighbors (why?)
|
// then tell my neighbors to update all their neighbors (why?)
|
||||||
public void updateNeighbors(World world, BlockPos pos){
|
/* public void updateNeighbors(World world, BlockPos pos){
|
||||||
if (world.getBlockState(pos).isOf(this)) {
|
if (world.getBlockState(pos).isOf(this)) {
|
||||||
world.updateNeighborsAlways(pos, this);
|
world.updateNeighborsAlways(pos, this);
|
||||||
//Direction[] d = Direction.values();
|
//Direction[] d = Direction.values();
|
||||||
|
@ -140,19 +165,19 @@ public class GlowstoneWireBlock extends Block{
|
||||||
//}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify){
|
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify){
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
if (state.canPlaceAt(world, pos)) {
|
if (state.canPlaceAt(world, pos)) {
|
||||||
this.update(world, pos, state);
|
return;
|
||||||
} else {
|
} else {
|
||||||
dropStacks(state, world, pos);
|
dropStacks(state, world, pos);
|
||||||
world.removeBlock(pos, false);
|
world.removeBlock(pos, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
WIRE_CONNECTION_NORTH = Properties.NORTH_WIRE_CONNECTION;
|
WIRE_CONNECTION_NORTH = Properties.NORTH_WIRE_CONNECTION;
|
||||||
|
|
Loading…
Reference in New Issue