mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-24 14:06:42 +01:00
Port all instances of Block.onBlockActivated
This commit is contained in:
parent
53f0524200
commit
11ae3bc820
18 changed files with 88 additions and 86 deletions
|
@ -42,14 +42,14 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock {
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (!player.isAllowEdit())
|
if (!player.isAllowEdit())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
ItemStack heldItem = player.getHeldItem(handIn);
|
ItemStack heldItem = player.getHeldItem(handIn);
|
||||||
boolean isSlimeBall = heldItem.getItem().isIn(Tags.Items.SLIMEBALLS);
|
boolean isSlimeBall = heldItem.getItem().isIn(Tags.Items.SLIMEBALLS);
|
||||||
|
|
||||||
BooleanProperty affectedSide = getGlueableSide(state, hit.getFace());
|
BooleanProperty affectedSide = getGlueableSide(state, hit.getFace());
|
||||||
if (affectedSide == null)
|
if (affectedSide == null)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
if (isSlimeBall && state.get(affectedSide)) {
|
if (isSlimeBall && state.get(affectedSide)) {
|
||||||
for (Direction face : Direction.values()) {
|
for (Direction face : Direction.values()) {
|
||||||
|
@ -58,7 +58,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock {
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
Vec3d vec = hit.getHitVec();
|
Vec3d vec = hit.getHitVec();
|
||||||
worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0);
|
worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
worldIn.playSound(null, pos, AllSoundEvents.SLIME_ADDED.get(), SoundCategory.BLOCKS, .5f, 1);
|
worldIn.playSound(null, pos, AllSoundEvents.SLIME_ADDED.get(), SoundCategory.BLOCKS, .5f, 1);
|
||||||
state = state.with(glueableSide, true);
|
state = state.with(glueableSide, true);
|
||||||
|
@ -66,22 +66,22 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock {
|
||||||
}
|
}
|
||||||
if (!worldIn.isRemote)
|
if (!worldIn.isRemote)
|
||||||
worldIn.setBlockState(pos, state);
|
worldIn.setBlockState(pos, state);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!heldItem.isEmpty() || !player.isSneaking()) && !isSlimeBall)
|
if ((!heldItem.isEmpty() || !player.isSneaking()) && !isSlimeBall)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (state.get(affectedSide) == isSlimeBall)
|
if (state.get(affectedSide) == isSlimeBall)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
Vec3d vec = hit.getHitVec();
|
Vec3d vec = hit.getHitVec();
|
||||||
worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0);
|
worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
worldIn.playSound(null, pos, AllSoundEvents.SLIME_ADDED.get(), SoundCategory.BLOCKS, .5f, 1);
|
worldIn.playSound(null, pos, AllSoundEvents.SLIME_ADDED.get(), SoundCategory.BLOCKS, .5f, 1);
|
||||||
worldIn.setBlockState(pos, state.with(affectedSide, isSlimeBall));
|
worldIn.setBlockState(pos, state.with(affectedSide, isSlimeBall));
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -55,34 +55,34 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (!player.isAllowEdit())
|
if (!player.isAllowEdit())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (!player.getHeldItem(handIn).getItem().isIn(Tags.Items.SLIMEBALLS)) {
|
if (!player.getHeldItem(handIn).getItem().isIn(Tags.Items.SLIMEBALLS)) {
|
||||||
if (player.getHeldItem(handIn).isEmpty()) {
|
if (player.getHeldItem(handIn).isEmpty()) {
|
||||||
withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true);
|
withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
if (state.get(STATE) != PistonState.RETRACTED)
|
if (state.get(STATE) != PistonState.RETRACTED)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
Direction direction = state.get(FACING);
|
Direction direction = state.get(FACING);
|
||||||
if (hit.getFace() != direction)
|
if (hit.getFace() != direction)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (((MechanicalPistonBlock) state.getBlock()).isSticky)
|
if (((MechanicalPistonBlock) state.getBlock()).isSticky)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
Vec3d vec = hit.getHitVec();
|
Vec3d vec = hit.getHitVec();
|
||||||
worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0);
|
worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
worldIn.playSound(null, pos, AllSoundEvents.SLIME_ADDED.get(), SoundCategory.BLOCKS, .5f, 1);
|
worldIn.playSound(null, pos, AllSoundEvents.SLIME_ADDED.get(), SoundCategory.BLOCKS, .5f, 1);
|
||||||
if (!player.isCreative())
|
if (!player.isCreative())
|
||||||
player.getHeldItem(handIn).shrink(1);
|
player.getHeldItem(handIn).shrink(1);
|
||||||
worldIn.setBlockState(pos, AllBlocks.STICKY_MECHANICAL_PISTON.get().getDefaultState().with(FACING, direction)
|
worldIn.setBlockState(pos, AllBlocks.STICKY_MECHANICAL_PISTON.get().getDefaultState().with(FACING, direction)
|
||||||
.with(AXIS_ALONG_FIRST_COORDINATE, state.get(AXIS_ALONG_FIRST_COORDINATE)));
|
.with(AXIS_ALONG_FIRST_COORDINATE, state.get(AXIS_ALONG_FIRST_COORDINATE)));
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,14 +46,14 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements IWithTile
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (!player.isAllowEdit())
|
if (!player.isAllowEdit())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (player.getHeldItem(handIn).isEmpty()) {
|
if (player.getHeldItem(handIn).isEmpty()) {
|
||||||
withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true);
|
withTileEntityDo(worldIn, pos, te -> te.assembleNextTick = true);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
TileEntity te = worldIn.getTileEntity(pos);
|
TileEntity te = worldIn.getTileEntity(pos);
|
||||||
if (!(te instanceof MechanicalCrafterTileEntity))
|
if (!(te instanceof MechanicalCrafterTileEntity))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te;
|
MechanicalCrafterTileEntity crafter = (MechanicalCrafterTileEntity) te;
|
||||||
boolean wrenched = AllItems.WRENCH.typeOf(heldItem);
|
boolean wrenched = AllItems.WRENCH.typeOf(heldItem);
|
||||||
|
|
||||||
|
@ -174,59 +174,59 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
if (crafter.phase != Phase.IDLE && !wrenched) {
|
if (crafter.phase != Phase.IDLE && !wrenched) {
|
||||||
crafter.ejectWholeGrid();
|
crafter.ejectWholeGrid();
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crafter.phase == Phase.IDLE && !isHand && !wrenched) {
|
if (crafter.phase == Phase.IDLE && !isHand && !wrenched) {
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
if (AllItems.SLOT_COVER.typeOf(heldItem)) {
|
if (AllItems.SLOT_COVER.typeOf(heldItem)) {
|
||||||
if (crafter.covered)
|
if (crafter.covered)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
crafter.covered = true;
|
crafter.covered = true;
|
||||||
crafter.markDirty();
|
crafter.markDirty();
|
||||||
crafter.sendData();
|
crafter.sendData();
|
||||||
if (!player.isCreative())
|
if (!player.isCreative())
|
||||||
heldItem.shrink(1);
|
heldItem.shrink(1);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyOptional<IItemHandler> capability =
|
LazyOptional<IItemHandler> capability =
|
||||||
crafter.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
crafter.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
|
||||||
if (!capability.isPresent())
|
if (!capability.isPresent())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
ItemStack remainder =
|
ItemStack remainder =
|
||||||
ItemHandlerHelper.insertItem(capability.orElse(new ItemStackHandler()), heldItem.copy(), false);
|
ItemHandlerHelper.insertItem(capability.orElse(new ItemStackHandler()), heldItem.copy(), false);
|
||||||
if (remainder.getCount() != heldItem.getCount())
|
if (remainder.getCount() != heldItem.getCount())
|
||||||
player.setHeldItem(handIn, remainder);
|
player.setHeldItem(handIn, remainder);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack inSlot = crafter.inventory.getStackInSlot(0);
|
ItemStack inSlot = crafter.inventory.getStackInSlot(0);
|
||||||
if (inSlot.isEmpty()) {
|
if (inSlot.isEmpty()) {
|
||||||
if (crafter.covered && !wrenched) {
|
if (crafter.covered && !wrenched) {
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
crafter.covered = false;
|
crafter.covered = false;
|
||||||
crafter.markDirty();
|
crafter.markDirty();
|
||||||
crafter.sendData();
|
crafter.sendData();
|
||||||
if (!player.isCreative())
|
if (!player.isCreative())
|
||||||
player.inventory.placeItemBackInInventory(worldIn, AllItems.SLOT_COVER.asStack());
|
player.inventory.placeItemBackInInventory(worldIn, AllItems.SLOT_COVER.asStack());
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
if (!isHand && !ItemHandlerHelper.canItemStacksStack(heldItem, inSlot))
|
if (!isHand && !ItemHandlerHelper.canItemStacksStack(heldItem, inSlot))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
player.inventory.placeItemBackInInventory(worldIn, inSlot);
|
player.inventory.placeItemBackInInventory(worldIn, inSlot);
|
||||||
crafter.inventory.setStackInSlot(0, ItemStack.EMPTY);
|
crafter.inventory.setStackInSlot(0, ItemStack.EMPTY);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override // TODO 1.15 register layer
|
// @Override // TODO 1.15 register layer
|
||||||
|
|
|
@ -39,10 +39,10 @@ public class HandCrankBlock extends DirectionalKineticBlock implements IWithTile
|
||||||
boolean handEmpty = player.getHeldItem(handIn).isEmpty();
|
boolean handEmpty = player.getHeldItem(handIn).isEmpty();
|
||||||
|
|
||||||
if (!handEmpty && player.isSneaking())
|
if (!handEmpty && player.isSneaking())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
withTileEntityDo(worldIn, pos, te -> te.turn(player.isSneaking()));
|
withTileEntityDo(worldIn, pos, te -> te.turn(player.isSneaking()));
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -86,12 +86,12 @@ public class DeployerBlock extends DirectionalAxisKineticBlock
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
ItemStack heldByPlayer = player.getHeldItem(handIn).copy();
|
ItemStack heldByPlayer = player.getHeldItem(handIn).copy();
|
||||||
if (AllItems.WRENCH.typeOf(heldByPlayer))
|
if (AllItems.WRENCH.typeOf(heldByPlayer))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
if (hit.getFace() != state.get(FACING))
|
if (hit.getFace() != state.get(FACING))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
withTileEntityDo(worldIn, pos, te -> {
|
withTileEntityDo(worldIn, pos, te -> {
|
||||||
ItemStack heldByDeployer = te.player.getHeldItemMainhand().copy();
|
ItemStack heldByDeployer = te.player.getHeldItemMainhand().copy();
|
||||||
|
@ -103,7 +103,7 @@ public class DeployerBlock extends DirectionalAxisKineticBlock
|
||||||
te.sendData();
|
te.sendData();
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,15 +58,15 @@ public class MillstoneBlock extends KineticBlock {
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (!player.getHeldItem(handIn).isEmpty())
|
if (!player.getHeldItem(handIn).isEmpty())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.getTileEntity(pos) == null)
|
if (worldIn.getTileEntity(pos) == null)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||||
if (!(tileEntity instanceof MillstoneTileEntity))
|
if (!(tileEntity instanceof MillstoneTileEntity))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
MillstoneTileEntity millstone = (MillstoneTileEntity) tileEntity;
|
MillstoneTileEntity millstone = (MillstoneTileEntity) tileEntity;
|
||||||
|
|
||||||
IItemHandlerModifiable inv = millstone.outputInv;
|
IItemHandlerModifiable inv = millstone.outputInv;
|
||||||
|
@ -76,7 +76,7 @@ public class MillstoneBlock extends KineticBlock {
|
||||||
}
|
}
|
||||||
millstone.markDirty();
|
millstone.markDirty();
|
||||||
millstone.sendData();
|
millstone.sendData();
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,9 +52,9 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (!player.getHeldItem(handIn).isEmpty())
|
if (!player.getHeldItem(handIn).isEmpty())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.getTileEntity(pos) == null)
|
if (worldIn.getTileEntity(pos) == null)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(pos);
|
BasinTileEntity te = (BasinTileEntity) worldIn.getTileEntity(pos);
|
||||||
IItemHandlerModifiable inv = te.inventory.orElse(new ItemStackHandler(1));
|
IItemHandlerModifiable inv = te.inventory.orElse(new ItemStackHandler(1));
|
||||||
|
@ -64,7 +64,7 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
|
||||||
}
|
}
|
||||||
te.onEmptied();
|
te.onEmptied();
|
||||||
|
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -48,18 +48,18 @@ public class AnalogLeverBlock extends HorizontalFaceBlock implements IWithTileEn
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
addParticles(state, worldIn, pos, 1.0F);
|
addParticles(state, worldIn, pos, 1.0F);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean sneak = player.isSneaking();
|
boolean sneak = player.isSneaking();
|
||||||
AnalogLeverTileEntity te = getTileEntity(worldIn, pos);
|
AnalogLeverTileEntity te = getTileEntity(worldIn, pos);
|
||||||
if (te == null)
|
if (te == null)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
|
|
||||||
te.changeState(sneak);
|
te.changeState(sneak);
|
||||||
float f = .25f + ((te.state + 5) / 15f) * .5f;
|
float f = .25f + ((te.state + 5) / 15f) * .5f;
|
||||||
worldIn.playSound(null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f);
|
worldIn.playSound(null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -81,17 +81,17 @@ public class SequencedGearshiftBlock extends HorizontalAxisKineticBlock
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
ItemStack held = player.getHeldItemMainhand();
|
ItemStack held = player.getHeldItemMainhand();
|
||||||
if (AllItems.WRENCH.typeOf(held))
|
if (AllItems.WRENCH.typeOf(held))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (held.getItem() instanceof BlockItem) {
|
if (held.getItem() instanceof BlockItem) {
|
||||||
BlockItem blockItem = (BlockItem) held.getItem();
|
BlockItem blockItem = (BlockItem) held.getItem();
|
||||||
if (blockItem.getBlock() instanceof KineticBlock && hasShaftTowards(worldIn, pos, state, hit.getFace()))
|
if (blockItem.getBlock() instanceof KineticBlock && hasShaftTowards(worldIn, pos, state, hit.getFace()))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
|
||||||
displayScreen((SequencedGearshiftTileEntity) worldIn.getTileEntity(pos));
|
displayScreen((SequencedGearshiftTileEntity) worldIn.getTileEntity(pos));
|
||||||
});
|
});
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(value = Dist.CLIENT)
|
@OnlyIn(value = Dist.CLIENT)
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (player.isSneaking() || !player.isAllowEdit())
|
if (player.isSneaking() || !player.isAllowEdit())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
ItemStack heldItem = player.getHeldItem(handIn);
|
ItemStack heldItem = player.getHeldItem(handIn);
|
||||||
boolean isShaft = heldItem.getItem() == AllBlocks.SHAFT.get().asItem();
|
boolean isShaft = heldItem.getItem() == AllBlocks.SHAFT.get().asItem();
|
||||||
boolean isCasing = heldItem.getItem() == AllBlocks.BRASS_CASING.get().asItem();
|
boolean isCasing = heldItem.getItem() == AllBlocks.BRASS_CASING.get().asItem();
|
||||||
|
@ -211,7 +211,7 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
if (isDye) {
|
if (isDye) {
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
withTileEntityDo(worldIn, pos, te -> {
|
withTileEntityDo(worldIn, pos, te -> {
|
||||||
DyeColor dyeColor = DyeColor.getColor(heldItem);
|
DyeColor dyeColor = DyeColor.getColor(heldItem);
|
||||||
if (dyeColor == null)
|
if (dyeColor == null)
|
||||||
|
@ -220,20 +220,20 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
});
|
});
|
||||||
if (!player.isCreative())
|
if (!player.isCreative())
|
||||||
heldItem.shrink(1);
|
heldItem.shrink(1);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity te = worldIn.getTileEntity(pos);
|
TileEntity te = worldIn.getTileEntity(pos);
|
||||||
if (te == null || !(te instanceof BeltTileEntity))
|
if (te == null || !(te instanceof BeltTileEntity))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
BeltTileEntity belt = (BeltTileEntity) te;
|
BeltTileEntity belt = (BeltTileEntity) te;
|
||||||
|
|
||||||
if (isHand) {
|
if (isHand) {
|
||||||
BeltTileEntity controllerBelt = belt.getControllerTE();
|
BeltTileEntity controllerBelt = belt.getControllerTE();
|
||||||
if (controllerBelt == null)
|
if (controllerBelt == null)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
controllerBelt.getInventory().forEachWithin(belt.index + .5f, .55f, (transportedItemStack) -> {
|
controllerBelt.getInventory().forEachWithin(belt.index + .5f, .55f, (transportedItemStack) -> {
|
||||||
player.inventory.placeItemBackInInventory(worldIn, transportedItemStack.stack);
|
player.inventory.placeItemBackInInventory(worldIn, transportedItemStack.stack);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -242,28 +242,28 @@ public class BeltBlock extends HorizontalKineticBlock
|
||||||
|
|
||||||
if (isShaft) {
|
if (isShaft) {
|
||||||
if (state.get(PART) != Part.MIDDLE)
|
if (state.get(PART) != Part.MIDDLE)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (worldIn.isRemote)
|
if (worldIn.isRemote)
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
if (!player.isCreative())
|
if (!player.isCreative())
|
||||||
heldItem.shrink(1);
|
heldItem.shrink(1);
|
||||||
worldIn.setBlockState(pos, state.with(PART, Part.PULLEY), 2);
|
worldIn.setBlockState(pos, state.with(PART, Part.PULLEY), 2);
|
||||||
belt.attachKinetics();
|
belt.attachKinetics();
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCasing) {
|
if (isCasing) {
|
||||||
if (state.get(CASING))
|
if (state.get(CASING))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (state.get(SLOPE) == Slope.VERTICAL)
|
if (state.get(SLOPE) == Slope.VERTICAL)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (!player.isCreative())
|
if (!player.isCreative())
|
||||||
heldItem.shrink(1);
|
heldItem.shrink(1);
|
||||||
worldIn.setBlockState(pos, state.with(CASING, true), 2);
|
worldIn.setBlockState(pos, state.with(CASING, true), 2);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock {
|
||||||
if (player.isSneaking()) {
|
if (player.isSneaking()) {
|
||||||
RedstoneLinkTileEntity te = (RedstoneLinkTileEntity) worldIn.getTileEntity(pos);
|
RedstoneLinkTileEntity te = (RedstoneLinkTileEntity) worldIn.getTileEntity(pos);
|
||||||
if (te == null)
|
if (te == null)
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
|
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
Boolean wasReceiver = state.get(RECEIVER);
|
Boolean wasReceiver = state.get(RECEIVER);
|
||||||
|
@ -133,10 +133,10 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock {
|
||||||
} else
|
} else
|
||||||
te.transmit(false);
|
te.transmit(false);
|
||||||
}
|
}
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -192,10 +192,10 @@ public class FunnelBlock extends AttachedLogisticalBlock implements IBeltAttachm
|
||||||
if (!ItemStack.areItemStacksEqual(remainder, heldItem))
|
if (!ItemStack.areItemStacksEqual(remainder, heldItem))
|
||||||
player.setHeldItem(handIn, remainder);
|
player.setHeldItem(handIn, remainder);
|
||||||
});
|
});
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean process(BeltTileEntity belt, TransportedItemStack transported, BeltAttachmentState state) {
|
public boolean process(BeltTileEntity belt, TransportedItemStack transported, BeltAttachmentState state) {
|
||||||
|
|
|
@ -6,6 +6,8 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.state.BooleanProperty;
|
import net.minecraft.state.BooleanProperty;
|
||||||
import net.minecraft.state.StateContainer.Builder;
|
import net.minecraft.state.StateContainer.Builder;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
@ -81,12 +83,12 @@ public class LatchBlock extends ToggleLatchBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean activated(World worldIn, BlockPos pos, BlockState state) {
|
protected ActionResultType activated(World worldIn, BlockPos pos, BlockState state) {
|
||||||
if (state.get(POWERED) != state.get(POWERED_SIDE))
|
if (state.get(POWERED) != state.get(POWERED_SIDE))
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (!worldIn.isRemote)
|
if (!worldIn.isRemote)
|
||||||
worldIn.setBlockState(pos, state.cycle(POWERING), 2);
|
worldIn.setBlockState(pos, state.cycle(POWERING), 2);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,9 +46,9 @@ public class ToggleLatchBlock extends RedstoneDiodeBlock {
|
||||||
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
if (!player.isAllowEdit())
|
if (!player.isAllowEdit())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
if (player.isSneaking())
|
if (player.isSneaking())
|
||||||
return false;
|
return ActionResultType.PASS;
|
||||||
return activated(worldIn, pos, state);
|
return activated(worldIn, pos, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,10 +66,10 @@ public class ToggleLatchBlock extends RedstoneDiodeBlock {
|
||||||
worldIn.setBlockState(pos, newState.cycle(POWERING), 2);
|
worldIn.setBlockState(pos, newState.cycle(POWERING), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean activated(World worldIn, BlockPos pos, BlockState state) {
|
protected ActionResultType activated(World worldIn, BlockPos pos, BlockState state) {
|
||||||
if (!worldIn.isRemote)
|
if (!worldIn.isRemote)
|
||||||
worldIn.setBlockState(pos, state.cycle(POWERING), 2);
|
worldIn.setBlockState(pos, state.cycle(POWERING), 2);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class FlexcrateBlock extends ProperDirectionalBlock {
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
|
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
TileEntity te = worldIn.getTileEntity(pos);
|
TileEntity te = worldIn.getTileEntity(pos);
|
||||||
if (te instanceof FlexcrateTileEntity) {
|
if (te instanceof FlexcrateTileEntity) {
|
||||||
|
@ -125,7 +125,7 @@ public class FlexcrateBlock extends ProperDirectionalBlock {
|
||||||
fte = fte.getMainCrate();
|
fte = fte.getMainCrate();
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, fte, fte::sendToContainer);
|
NetworkHooks.openGui((ServerPlayerEntity) player, fte, fte::sendToContainer);
|
||||||
}
|
}
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,12 @@ public class SchematicTableBlock extends HorizontalBlock {
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
|
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
SchematicTableTileEntity te = (SchematicTableTileEntity) worldIn.getTileEntity(pos);
|
SchematicTableTileEntity te = (SchematicTableTileEntity) worldIn.getTileEntity(pos);
|
||||||
if (te != null)
|
if (te != null)
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
|
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class SchematicannonBlock extends Block {
|
||||||
BlockRayTraceResult hit) {
|
BlockRayTraceResult hit) {
|
||||||
|
|
||||||
if (worldIn.isRemote) {
|
if (worldIn.isRemote) {
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
SchematicannonTileEntity te = (SchematicannonTileEntity) worldIn.getTileEntity(pos);
|
SchematicannonTileEntity te = (SchematicannonTileEntity) worldIn.getTileEntity(pos);
|
||||||
if (te != null)
|
if (te != null)
|
||||||
|
@ -70,7 +70,7 @@ public class SchematicannonBlock extends Block {
|
||||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
|
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
|
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue