Formatting for PlayerDetectorBlock

This commit is contained in:
drcrazy 2020-09-08 16:00:20 +03:00
parent bb13b2cafc
commit efad3e6411
3 changed files with 12 additions and 10 deletions

View file

@ -32,8 +32,8 @@ import net.minecraft.util.math.Direction;
import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.WorldUtils;
import techreborn.blocks.machine.tier1.BlockPlayerDetector;
import techreborn.blocks.machine.tier1.BlockPlayerDetector.PlayerDetectorType;
import techreborn.blocks.machine.tier1.PlayerDetectorBlock;
import techreborn.blocks.machine.tier1.PlayerDetectorBlock.PlayerDetectorType;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@ -62,7 +62,7 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
if (canUseEnergy(TechRebornConfig.playerDetectorEuPerTick)) {
for (PlayerEntity player : world.getPlayers()) {
if (player.distanceTo(player) <= 256.0D) {
PlayerDetectorType type = world.getBlockState(pos).get(BlockPlayerDetector.TYPE);
PlayerDetectorType type = world.getBlockState(pos).get(PlayerDetectorBlock.TYPE);
if (type == PlayerDetectorType.ALL) {// ALL
redstone = true;
} else if (type == PlayerDetectorType.OTHERS) {// Others

View file

@ -54,11 +54,11 @@ import reborncore.common.util.StringUtils;
import techreborn.blockentity.machine.tier1.PlayerDectectorBlockEntity;
import techreborn.utils.MessageIDs;
public class BlockPlayerDetector extends BlockMachineBase {
public class PlayerDetectorBlock extends BlockMachineBase {
public static EnumProperty<PlayerDetectorType> TYPE;
public BlockPlayerDetector() {
public PlayerDetectorBlock() {
super(Block.Settings.of(Material.METAL).strength(2f, 2f), true);
this.setDefaultState(this.getStateManager().getDefaultState().with(TYPE, PlayerDetectorType.ALL));
}
@ -70,8 +70,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
}
@Override
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer,
ItemStack stack) {
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
super.onPlaced(worldIn, pos, state, placer, stack);
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
if (blockEntity instanceof PlayerDectectorBlockEntity) {
@ -142,18 +141,20 @@ public class BlockPlayerDetector extends BlockMachineBase {
return null;
}
// Block
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
TYPE = EnumProperty.of("type", PlayerDetectorType.class);
builder.add(TYPE);
}
// AbstractBlock
@SuppressWarnings("deprecation")
@Override
public boolean emitsRedstonePower(BlockState state) {
return true;
}
@SuppressWarnings("deprecation")
@Override
public int getWeakRedstonePower(BlockState blockState, BlockView blockAccess, BlockPos pos, Direction side) {
BlockEntity entity = blockAccess.getBlockEntity(pos);
@ -163,6 +164,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
return 0;
}
@SuppressWarnings("deprecation")
@Override
public int getStrongRedstonePower(BlockState blockState, BlockView blockAccess, BlockPos pos, Direction side) {
BlockEntity entity = blockAccess.getBlockEntity(pos);

View file

@ -63,7 +63,7 @@ import techreborn.blocks.generator.GenericGeneratorBlock;
import techreborn.blocks.lighting.BlockLamp;
import techreborn.blocks.machine.tier0.IronAlloyFurnaceBlock;
import techreborn.blocks.machine.tier0.IronFurnaceBlock;
import techreborn.blocks.machine.tier1.BlockPlayerDetector;
import techreborn.blocks.machine.tier1.PlayerDetectorBlock;
import techreborn.blocks.machine.tier1.ResinBasinBlock;
import techreborn.blocks.misc.*;
import techreborn.blocks.storage.energy.*;
@ -560,7 +560,7 @@ public class TRContent {
CHUNK_LOADER(new GenericMachineBlock(GuiType.CHUNK_LOADER, ChunkLoaderBlockEntity::new)),
LAMP_INCANDESCENT(new BlockLamp(4, 10, 8)),
LAMP_LED(new BlockLamp(1, 1, 12)),
PLAYER_DETECTOR(new BlockPlayerDetector());
PLAYER_DETECTOR(new PlayerDetectorBlock());
public final String name;
public final Block block;