mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +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 {
|
public class LecternControllerBlockEntity extends SmartBlockEntity {
|
||||||
|
|
||||||
private ItemStack controller;
|
private ItemStack controller = ItemStack.EMPTY;
|
||||||
private UUID user;
|
private UUID user;
|
||||||
private UUID prevUser; // used only on client
|
private UUID prevUser; // used only on client
|
||||||
private boolean deactivatedThisTick; // used only on server
|
private boolean deactivatedThisTick; // used only on server
|
||||||
|
@ -161,9 +161,9 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
|
||||||
stopUsing((Player) playerEntity);
|
stopUsing((Player) playerEntity);
|
||||||
|
|
||||||
Direction dir = state.getValue(LecternControllerBlock.FACING);
|
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 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 itementity = new ItemEntity(level, x, y, z, controller.copy());
|
||||||
itementity.setDefaultPickUpDelay();
|
itementity.setDefaultPickUpDelay();
|
||||||
level.addFreshEntity(itementity);
|
level.addFreshEntity(itementity);
|
||||||
|
@ -172,8 +172,8 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
|
||||||
|
|
||||||
public static boolean playerInRange(Player player, Level world, BlockPos pos) {
|
public static boolean playerInRange(Player player, Level world, BlockPos pos) {
|
||||||
//double modifier = world.isRemote ? 0 : 1.0;
|
//double modifier = world.isRemote ? 0 : 1.0;
|
||||||
double reach = 0.4*player.getAttributeValue(ForgeMod.REACH_DISTANCE.get());// + modifier;
|
double reach = 0.4 * player.getAttributeValue(ForgeMod.REACH_DISTANCE.get());// + modifier;
|
||||||
return player.distanceToSqr(Vec3.atCenterOf(pos)) < reach*reach;
|
return player.distanceToSqr(Vec3.atCenterOf(pos)) < reach * reach;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue