did some stuff iunno

This commit is contained in:
Justin Parsell 2021-04-27 21:34:20 -04:00
parent a38a20d523
commit 46e19769be
1 changed files with 89 additions and 67 deletions

View File

@ -7,6 +7,7 @@ import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.enums.WireConnection;
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.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class GlowstoneWireBlock extends Block{
// These are the states of the wires coming off our block
@ -75,6 +77,16 @@ public class GlowstoneWireBlock extends Block{
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) {
switch(rotation) {
case CLOCKWISE_180:
@ -110,26 +122,36 @@ public class GlowstoneWireBlock extends Block{
public void update(World world, BlockPos pos, BlockState state){
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){
System.out.println("Update neighbors");
if (world.getBlockState(pos).isOf(this)) {
world.updateNeighborsAlways(pos, this);
Direction[] var3 = Direction.values();
int var4 = var3.length;
//Direction[] d = Direction.values();
//int dl = d.length;
for(int var5 = 0; var5 < var4; ++var5) {
Direction direction = var3[var5];
world.updateNeighborsAlways(pos.offset(direction), this);
}
//for(int i = 0; i < dl; ++i) {
// Direction direction = d[i];
// world.updateNeighborsAlways(pos.offset(direction), this);
//}
}
}
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 {