Formatting

This commit is contained in:
drcrazy 2019-07-15 10:43:08 +03:00
parent 57d0d6d3f0
commit 5d93843a1e

View file

@ -86,44 +86,45 @@ public class BlockCable extends BlockWithEntity {
public BlockCable(TRContent.Cables type) { public BlockCable(TRContent.Cables type) {
super(Block.Settings.of(Material.STONE).strength(1f, 8f)); super(Block.Settings.of(Material.STONE).strength(1f, 8f));
this.type = type; this.type = type;
setDefaultState(this.stateFactory.getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false).with(SOUTH, false).with(UP, false).with(DOWN, false)); setDefaultState(this.stateFactory.getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false)
.with(SOUTH, false).with(UP, false).with(DOWN, false));
BlockWrenchEventHandler.wrenableBlocks.add(this); BlockWrenchEventHandler.wrenableBlocks.add(this);
} }
public AbstractProperty<Boolean> getProperty(Direction facing) { public AbstractProperty<Boolean> getProperty(Direction facing) {
switch (facing) { switch (facing) {
case EAST: case EAST:
return EAST; return EAST;
case WEST: case WEST:
return WEST; return WEST;
case NORTH: case NORTH:
return NORTH; return NORTH;
case SOUTH: case SOUTH:
return SOUTH; return SOUTH;
case UP: case UP:
return UP; return UP;
case DOWN: case DOWN:
return DOWN; return DOWN;
default: default:
return EAST; return EAST;
} }
} }
private BlockState makeConnections(World world, BlockPos pos) { private BlockState makeConnections(World world, BlockPos pos) {
Boolean down = checkEnergyCapability(world, pos.down(), Direction.UP); Boolean down = canConnectTo(world, pos.down(), Direction.UP);
Boolean up = checkEnergyCapability(world, pos.up(), Direction.DOWN); Boolean up = canConnectTo(world, pos.up(), Direction.DOWN);
Boolean north = checkEnergyCapability(world, pos.north(), Direction.SOUTH); Boolean north = canConnectTo(world, pos.north(), Direction.SOUTH);
Boolean east = checkEnergyCapability(world, pos.east(), Direction.WEST); Boolean east = canConnectTo(world, pos.east(), Direction.WEST);
Boolean south = checkEnergyCapability(world, pos.south(), Direction.NORTH); Boolean south = canConnectTo(world, pos.south(), Direction.NORTH);
Boolean west = checkEnergyCapability(world, pos.west(), Direction.WEST); Boolean west = canConnectTo(world, pos.west(), Direction.WEST);
return this.getDefaultState().with(DOWN, down).with(UP, up).with(NORTH, north).with(EAST, east) return this.getDefaultState().with(DOWN, down).with(UP, up).with(NORTH, north).with(EAST, east)
.with(SOUTH, south).with(WEST, west); .with(SOUTH, south).with(WEST, west);
} }
private Boolean checkEnergyCapability(IWorld world, BlockPos pos, Direction facing) { private Boolean canConnectTo(IWorld world, BlockPos pos, Direction facing) {
BlockEntity tileEntity = world.getBlockEntity(pos); BlockEntity tileEntity = world.getBlockEntity(pos);
if (tileEntity!= null && (tileEntity instanceof IEnergyInterfaceTile)) { if (tileEntity != null && (tileEntity instanceof IEnergyInterfaceTile)) {
return Boolean.TRUE; return Boolean.TRUE;
} }
return Boolean.FALSE; return Boolean.FALSE;
@ -171,8 +172,9 @@ public class BlockCable extends BlockWithEntity {
} }
@Override @Override
public BlockState getStateForNeighborUpdate(BlockState ourState, Direction ourFacing, BlockState otherState, IWorld worldIn, BlockPos ourPos, BlockPos otherPos) { public BlockState getStateForNeighborUpdate(BlockState ourState, Direction ourFacing, BlockState otherState,
Boolean value = checkEnergyCapability(worldIn, otherPos, ourFacing.getOpposite()); IWorld worldIn, BlockPos ourPos, BlockPos otherPos) {
Boolean value = canConnectTo(worldIn, otherPos, ourFacing.getOpposite());
return ourState.with(getProperty(ourFacing), value); return ourState.with(getProperty(ourFacing), value);
} }
@ -184,8 +186,9 @@ public class BlockCable extends BlockWithEntity {
@Override @Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, EntityContext entityContext) { public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, EntityContext entityContext) {
if (type != null) { if (type != null) {
double culling = type.cableThickness / 2 ; double culling = type.cableThickness / 2;
return Block.createCuboidShape(culling , culling, culling, 16.0D - culling, 16.0D - culling, 16.0D - culling); return Block.createCuboidShape(culling, culling, culling, 16.0D - culling, 16.0D - culling,
16.0D - culling);
} }
return Block.createCuboidShape(6, 6, 6, 10, 10, 10); return Block.createCuboidShape(6, 6, 6, 10, 10, 10);
} }
@ -220,13 +223,11 @@ public class BlockCable extends BlockWithEntity {
entityIn.damage(new ElectrialShockSource(), 1F); entityIn.damage(new ElectrialShockSource(), 1F);
} }
if (uninsulatedElectrocutionSound) { if (uninsulatedElectrocutionSound) {
worldIn.playSound(null, entityIn.x, entityIn.y, entityIn.z, ModSounds.CABLE_SHOCK, worldIn.playSound(null, entityIn.x, entityIn.y, entityIn.z, ModSounds.CABLE_SHOCK, SoundCategory.BLOCKS,
SoundCategory.BLOCKS, 0.6F, 1F); 0.6F, 1F);
} }
if (uninsulatedElectrocutionParticles) { if (uninsulatedElectrocutionParticles) {
worldIn.addParticle(ParticleTypes.CRIT, entityIn.x, entityIn.y, entityIn.z, 0, 0, 0); worldIn.addParticle(ParticleTypes.CRIT, entityIn.x, entityIn.y, entityIn.z, 0, 0, 0);
} }
} }
} }