Pix possible null value in ElectriciansWrenchItem
This commit is contained in:
@@ -52,26 +52,22 @@ public class ElectriciansWrenchItem extends Item {
|
|||||||
public InteractionResult useOn(UseOnContext context) {
|
public InteractionResult useOn(UseOnContext context) {
|
||||||
Level level = context.getLevel();
|
Level level = context.getLevel();
|
||||||
BlockPos pos = context.getClickedPos();
|
BlockPos pos = context.getClickedPos();
|
||||||
|
Player player = context.getPlayer();
|
||||||
|
|
||||||
if(!context.getPlayer().isShiftKeyDown()) {
|
if(player != null && !player.isShiftKeyDown()) {
|
||||||
if (level.getBlockEntity(pos) instanceof IElectric be && be.canBeInGroups()) {
|
if (level.getBlockEntity(pos) instanceof IElectric be && be.canBeInGroups()) {
|
||||||
be.updateNextTick();
|
be.updateNextTick();
|
||||||
be.sendStuff();
|
be.sendStuff();
|
||||||
be.getData().group.id = context.getItemInHand().get(TFMGDataComponents.CONFIGURATION_WRENCH_NUMBER);
|
be.getData().group.id = context.getItemInHand().getOrDefault(TFMGDataComponents.CONFIGURATION_WRENCH_NUMBER, 0);
|
||||||
TFMGUtils.playSound(level, pos, SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, context.getPlayer());
|
TFMGUtils.playSound(level, pos, SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, context.getPlayer());
|
||||||
if(be instanceof ElectricMotorBlockEntity kineticBE)
|
if(be instanceof ElectricMotorBlockEntity kineticBE)
|
||||||
kineticBE.delayedUpdate=true;
|
kineticBE.delayedUpdate=true;
|
||||||
|
|
||||||
|
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
if (level.getBlockEntity(pos) instanceof AbstractEngineBlockEntity be ) {
|
if (level.getBlockEntity(pos) instanceof AbstractEngineBlockEntity be ) {
|
||||||
|
|
||||||
be.changeDirection();
|
be.changeDirection();
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user