mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
Merge pull request #6460 from IThundxr/mc1.18/controller-lectern-fix
Fix NPE caused by empty lectern controller in a debug world
This commit is contained in:
commit
50db9bc826
1 changed files with 5 additions and 5 deletions
|
@ -28,7 +28,7 @@ import net.minecraftforge.fml.DistExecutor;
|
|||
|
||||
public class LecternControllerBlockEntity extends SmartBlockEntity {
|
||||
|
||||
private ItemStack controller;
|
||||
private ItemStack controller = ItemStack.EMPTY;
|
||||
private UUID user;
|
||||
private UUID prevUser; // used only on client
|
||||
private boolean deactivatedThisTick; // used only on server
|
||||
|
@ -161,9 +161,9 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
|
|||
stopUsing((Player) playerEntity);
|
||||
|
||||
Direction dir = state.getValue(LecternControllerBlock.FACING);
|
||||
double x = worldPosition.getX() + 0.5 + 0.25*dir.getStepX();
|
||||
double x = worldPosition.getX() + 0.5 + 0.25 * dir.getStepX();
|
||||
double y = worldPosition.getY() + 1;
|
||||
double z = worldPosition.getZ() + 0.5 + 0.25*dir.getStepZ();
|
||||
double z = worldPosition.getZ() + 0.5 + 0.25 * dir.getStepZ();
|
||||
ItemEntity itementity = new ItemEntity(level, x, y, z, controller.copy());
|
||||
itementity.setDefaultPickUpDelay();
|
||||
level.addFreshEntity(itementity);
|
||||
|
@ -172,8 +172,8 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
|
|||
|
||||
public static boolean playerInRange(Player player, Level world, BlockPos pos) {
|
||||
//double modifier = world.isRemote ? 0 : 1.0;
|
||||
double reach = 0.4*player.getAttributeValue(ForgeMod.REACH_DISTANCE.get());// + modifier;
|
||||
return player.distanceToSqr(Vec3.atCenterOf(pos)) < reach*reach;
|
||||
double reach = 0.4 * player.getAttributeValue(ForgeMod.REACH_DISTANCE.get());// + modifier;
|
||||
return player.distanceToSqr(Vec3.atCenterOf(pos)) < reach * reach;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue