did some stuff iunno
This commit is contained in:
parent
a38a20d523
commit
46e19769be
|
@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
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.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
import net.minecraft.block.enums.WireConnection;
|
import net.minecraft.block.enums.WireConnection;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -24,6 +25,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.WorldView;
|
||||||
|
|
||||||
public class GlowstoneWireBlock extends Block{
|
public class GlowstoneWireBlock extends Block{
|
||||||
// These are the states of the wires coming off our block
|
// These are the states of the wires coming off our block
|
||||||
|
@ -75,6 +77,16 @@ public class GlowstoneWireBlock extends Block{
|
||||||
return this.getDefaultState();
|
return this.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||||
|
BlockPos blockPos = pos.down();
|
||||||
|
BlockState blockState = world.getBlockState(blockPos);
|
||||||
|
return this.canRunOnTop(world, blockPos, blockState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canRunOnTop(BlockView world, BlockPos pos, BlockState floor) {
|
||||||
|
return floor.isSideSolidFullSquare(world, pos, Direction.UP) || floor.isOf(Blocks.HOPPER);
|
||||||
|
}
|
||||||
|
|
||||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||||
switch(rotation) {
|
switch(rotation) {
|
||||||
case CLOCKWISE_180:
|
case CLOCKWISE_180:
|
||||||
|
@ -110,26 +122,36 @@ public class GlowstoneWireBlock extends Block{
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// isnt system.out BUT will update neighors?
|
// Check if I'm this,
|
||||||
|
// then update all my neighbors
|
||||||
|
// then tell my neighbors to update all their neighbors (why?)
|
||||||
public void updateNeighbors(World world, BlockPos pos){
|
public void updateNeighbors(World world, BlockPos pos){
|
||||||
System.out.println("Update neighbors");
|
|
||||||
if (world.getBlockState(pos).isOf(this)) {
|
if (world.getBlockState(pos).isOf(this)) {
|
||||||
world.updateNeighborsAlways(pos, this);
|
world.updateNeighborsAlways(pos, this);
|
||||||
Direction[] var3 = Direction.values();
|
//Direction[] d = Direction.values();
|
||||||
int var4 = var3.length;
|
//int dl = d.length;
|
||||||
|
|
||||||
for(int var5 = 0; var5 < var4; ++var5) {
|
//for(int i = 0; i < dl; ++i) {
|
||||||
Direction direction = var3[var5];
|
// Direction direction = d[i];
|
||||||
world.updateNeighborsAlways(pos.offset(direction), this);
|
// world.updateNeighborsAlways(pos.offset(direction), this);
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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){
|
||||||
System.out.println("Neighbor update");
|
if (!world.isClient) {
|
||||||
|
if (state.canPlaceAt(world, pos)) {
|
||||||
|
this.update(world, pos, state);
|
||||||
|
} else {
|
||||||
|
dropStacks(state, world, pos);
|
||||||
|
world.removeBlock(pos, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
Loading…
Reference in New Issue