inital 19w46a port
This commit is contained in:
parent
3fe62e2c77
commit
a984263b04
48 changed files with 356 additions and 339 deletions
|
@ -28,13 +28,14 @@ import net.minecraft.block.*;
|
|||
import net.minecraft.entity.EntityContext;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.item.TooltipContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
@ -106,7 +107,7 @@ public class BlockAlarm extends BaseBlockEntityProvider {
|
|||
|
||||
// Block
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
ACTIVE = BooleanProperty.of("active");
|
||||
builder.add(FACING, ACTIVE);
|
||||
}
|
||||
|
@ -124,28 +125,28 @@ public class BlockAlarm extends BaseBlockEntityProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||
|
||||
// We extended BaseTileBlock. Thus we should always have blockEntity entity. I hope.
|
||||
if (blockEntity == null) {
|
||||
return false;
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (!worldIn.isClient && playerIn.isSneaking()) {
|
||||
((AlarmBlockEntity) blockEntity).rightClick();
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,9 +34,10 @@ import net.minecraft.item.ItemPlacementContext;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.AbstractProperty;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -99,7 +100,7 @@ public class BlockCable extends BlockWithEntity {
|
|||
}
|
||||
|
||||
private BlockState makeConnections(World world, BlockPos pos) {
|
||||
Boolean down = canConnectTo(world, pos.down(), Direction.UP);
|
||||
Boolean down = canConnectTo(world, pos.method_10079(Direction.DOWN, 1), Direction.UP);
|
||||
Boolean up = canConnectTo(world, pos.up(), Direction.DOWN);
|
||||
Boolean north = canConnectTo(world, pos.north(), Direction.SOUTH);
|
||||
Boolean east = canConnectTo(world, pos.east(), Direction.WEST);
|
||||
|
@ -132,25 +133,25 @@ public class BlockCable extends BlockWithEntity {
|
|||
|
||||
// Block
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||
|
||||
// We should always have blockEntity entity. I hope.
|
||||
if (blockEntity == null) {
|
||||
return false;
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(EAST, WEST, NORTH, SOUTH, UP, DOWN);
|
||||
}
|
||||
|
||||
|
@ -207,11 +208,11 @@ public class BlockCable extends BlockWithEntity {
|
|||
entityIn.damage(new ElectrialShockSource(), 1F);
|
||||
}
|
||||
if (TechRebornConfig.uninsulatedElectrocutionSound) {
|
||||
worldIn.playSound(null, entityIn.x, entityIn.y, entityIn.z, ModSounds.CABLE_SHOCK, SoundCategory.BLOCKS,
|
||||
worldIn.playSound(null, entityIn.getX(), entityIn.getY(), entityIn.getZ(), ModSounds.CABLE_SHOCK, SoundCategory.BLOCKS,
|
||||
0.6F, 1F);
|
||||
}
|
||||
if (TechRebornConfig.uninsulatedElectrocutionParticles) {
|
||||
worldIn.addParticle(ParticleTypes.CRIT, entityIn.x, entityIn.y, entityIn.z, 0, 0, 0);
|
||||
worldIn.addParticle(ParticleTypes.CRIT, entityIn.getX(), entityIn.getY(), entityIn.getZ(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraft.sound.BlockSoundGroup;
|
|||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -56,8 +57,8 @@ public class BlockFusionCoil extends Block {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
||||
Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
||||
Hand hand, BlockHitResult hitResult) {
|
||||
|
||||
ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) {
|
||||
|
@ -65,16 +66,16 @@ public class BlockFusionCoil extends Block {
|
|||
if (playerIn.isSneaking()) {
|
||||
ItemStack drop = new ItemStack(this);
|
||||
dropStack(worldIn, pos, drop);
|
||||
worldIn.playSound(null, playerIn.x, playerIn.y, playerIn.z, ModSounds.BLOCK_DISMANTLE,
|
||||
worldIn.playSound(null, playerIn.getX(), playerIn.getY(), playerIn.getZ(), ModSounds.BLOCK_DISMANTLE,
|
||||
SoundCategory.BLOCKS, 0.6F, 1F);
|
||||
if (!worldIn.isClient) {
|
||||
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||
}
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -46,15 +47,15 @@ import java.util.List;
|
|||
public class BlockFusionControlComputer extends BlockMachineBase {
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
||||
Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
||||
Hand hand, BlockHitResult hitResult) {
|
||||
final FusionControlComputerBlockEntity blockEntityFusionControlComputer = (FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos);
|
||||
if(!playerIn.getStackInHand(hand).isEmpty() && (playerIn.getStackInHand(hand).getItem() == TRContent.Machine.FUSION_COIL.asItem())){
|
||||
List<BlockPos> coils = Torus.generate(blockEntityFusionControlComputer.getPos(), blockEntityFusionControlComputer.size);
|
||||
boolean placed = false;
|
||||
for(BlockPos coil : coils){
|
||||
if(playerIn.getStackInHand(hand).isEmpty()){
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
if(worldIn.isAir(coil) && !blockEntityFusionControlComputer.isCoil(coil)){
|
||||
worldIn.setBlockState(coil, TRContent.Machine.FUSION_COIL.block.getDefaultState());
|
||||
|
@ -65,12 +66,12 @@ public class BlockFusionControlComputer extends BlockMachineBase {
|
|||
}
|
||||
}
|
||||
if(placed){
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
blockEntityFusionControlComputer.checkCoils();
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,10 +30,11 @@ import net.minecraft.block.entity.BlockEntity;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -109,7 +110,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
|||
|
||||
// Block
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
ACTIVE = BooleanProperty.of("active");
|
||||
builder.add(FACING, ACTIVE);
|
||||
}
|
||||
|
@ -137,21 +138,21 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||
|
||||
// We extended BaseTileBlock. Thus we should always have blockEntity entity. I hope.
|
||||
if (blockEntity == null) {
|
||||
return false;
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.block.Blocks;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
|
@ -48,7 +49,7 @@ public class BlockComputerCube extends BlockMachineBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
|
||||
ItemStack tool = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
if (!tool.isEmpty() && ToolManager.INSTANCE.canHandleTool(tool)) {
|
||||
|
@ -56,19 +57,19 @@ public class BlockComputerCube extends BlockMachineBase {
|
|||
if (playerIn.isSneaking()) {
|
||||
ItemStack drop = new ItemStack(TRContent.COMPUTER_CUBE, 1);
|
||||
dropStack(worldIn, pos, drop);
|
||||
worldIn.playSound(null, playerIn.x, playerIn.y, playerIn.z, ModSounds.BLOCK_DISMANTLE,
|
||||
worldIn.playSound(null, playerIn.getX(), playerIn.getY(), playerIn.getZ(), ModSounds.BLOCK_DISMANTLE,
|
||||
SoundCategory.BLOCKS, 0.6F, 1F);
|
||||
if (!worldIn.isClient) {
|
||||
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||
}
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
else {
|
||||
rotate(worldIn.getBlockState(pos), BlockRotation.CLOCKWISE_90);
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -59,7 +59,7 @@ public class BlockNuke extends BaseBlock {
|
|||
EntityNukePrimed entitynukeprimed = new EntityNukePrimed(worldIn, (double) ((float) pos.getX() + 0.5F),
|
||||
(double) pos.getY(), (double) ((float) pos.getZ() + 0.5F), igniter);
|
||||
worldIn.spawnEntity(entitynukeprimed);
|
||||
worldIn.playSound((PlayerEntity) null, entitynukeprimed.x, entitynukeprimed.y, entitynukeprimed.z,
|
||||
worldIn.playSound((PlayerEntity) null, entitynukeprimed.getX(), entitynukeprimed.getY(), entitynukeprimed.getZ(),
|
||||
SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class BlockNuke extends BaseBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(OVERLAY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,12 +32,13 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
|||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -67,7 +68,7 @@ public class BlockRubberLog extends LogBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
super.appendProperties(builder);
|
||||
builder.add(SAP_SIDE, HAS_SAP);
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ public class BlockRubberLog extends LogBlock {
|
|||
BlockState state1 = worldIn.getBlockState(blockpos);
|
||||
if (state1.matches(BlockTags.LEAVES)) {
|
||||
state1.scheduledTick((ServerWorld) worldIn, blockpos, worldIn.getRandom());
|
||||
state1.onRandomTick((ServerWorld) worldIn, blockpos, worldIn.getRandom());
|
||||
state1.randomTick((ServerWorld) worldIn, blockpos, worldIn.getRandom());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +95,8 @@ public class BlockRubberLog extends LogBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onScheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
|
||||
super.onScheduledTick(state, worldIn, pos, random);
|
||||
public void scheduledTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
|
||||
super.scheduledTick(state, worldIn, pos, random);
|
||||
if (state.get(AXIS) != Direction.Axis.Y) {
|
||||
return;
|
||||
}
|
||||
|
@ -104,7 +105,7 @@ public class BlockRubberLog extends LogBlock {
|
|||
}
|
||||
if (random.nextInt(50) == 0) {
|
||||
Direction facing = Direction.fromHorizontal(random.nextInt(4));
|
||||
if (worldIn.getBlockState(pos.down()).getBlock() == this
|
||||
if (worldIn.getBlockState(pos.method_10079(Direction.DOWN, 1)).getBlock() == this
|
||||
&& worldIn.getBlockState(pos.up()).getBlock() == this) {
|
||||
worldIn.setBlockState(pos, state.with(HAS_SAP, true).with(SAP_SIDE, facing));
|
||||
}
|
||||
|
@ -112,12 +113,11 @@ public class BlockRubberLog extends LogBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
||||
Hand hand, BlockHitResult hitResult) {
|
||||
super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
|
||||
Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
if (stack.isEmpty()) {
|
||||
return false;
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if ((Energy.valid(stack) && Energy.of(stack).getEnergy() > 20) || stack.getItem() instanceof ItemTreeTap) {
|
||||
|
@ -139,9 +139,9 @@ public class BlockRubberLog extends LogBlock {
|
|||
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@ import net.minecraft.block.entity.BlockEntity;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -96,32 +97,32 @@ public abstract class BlockEnergyStorage extends BaseBlockEntityProvider {
|
|||
|
||||
// Block
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||
|
||||
// We extended BlockTileBase. Thus we should always have blockEntity entity. I hope.
|
||||
if (blockEntity == null) {
|
||||
return false;
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (!playerIn.isSneaking() && gui != null) {
|
||||
gui.open(playerIn, pos, worldIn);
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.block.entity.BlockEntity;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -85,22 +86,22 @@ public class BlockLSUStorage extends BaseBlockEntityProvider {
|
|||
|
||||
// Block
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||
|
||||
// We extended BaseTileBlock. Thus we should always have blockEntity entity. I hope.
|
||||
if (blockEntity == null) {
|
||||
return false;
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
|
||||
return true;
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
package techreborn.blocks.tier1;
|
||||
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -35,7 +36,7 @@ import reborncore.common.util.StringUtils;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.EnumProperty;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
|
@ -78,12 +79,12 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||
|
||||
if (blockEntity == null) {
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
|
||||
PlayerDetectorType type = state.get(TYPE);
|
||||
|
@ -96,7 +97,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
|||
if (blockEntity instanceof IToolDrop) {
|
||||
ItemStack drop = ((IToolDrop) blockEntity).getToolDrop(playerIn);
|
||||
if (drop == null) {
|
||||
return false;
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
if (!drop.isEmpty()) {
|
||||
dropStack(worldIn, pos, drop);
|
||||
|
@ -104,7 +105,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
|||
if (!worldIn.isClient) {
|
||||
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
|
||||
}
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
} else {
|
||||
if (type == PlayerDetectorType.ALL) {
|
||||
|
@ -126,7 +127,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
|||
Formatting.GRAY + StringUtils.t("techreborn.message.detects") + " " + color
|
||||
+ StringUtils.toFirstCapital(newType.asString())));
|
||||
}
|
||||
return true;
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,7 +137,7 @@ public class BlockPlayerDetector extends BlockMachineBase {
|
|||
|
||||
// Block
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
TYPE = EnumProperty.of("type", PlayerDetectorType.class);
|
||||
builder.add(TYPE);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@ import net.minecraft.block.entity.BlockEntity;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -84,26 +85,26 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
|
|||
|
||||
// Block
|
||||
@Override
|
||||
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
|
||||
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
|
||||
|
||||
// We extended BlockTileBase. Thus we should always have blockEntity entity. I hope.
|
||||
if (blockEntity == null) {
|
||||
return false;
|
||||
return ActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchUtils.handleWrench(stack, worldIn, pos, playerIn, hitResult.getSide())) {
|
||||
return true;
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
return super.activate(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue