Skip to content

Commit

Permalink
fix: Fix crash on warp plates with missing targets in last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Dec 14, 2023
1 parent 3829584 commit 5036824
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ public MenuProvider getSettingsMenuProvider() {
public void onEntityCollision(Entity entity) {
Integer ticksPassed = ticksPassedPerEntity.putIfAbsent(entity, 0);
if (ticksPassed == null || ticksPassed != -1) {
final var status = getTargetWaystone().isValid() ? WarpPlateBlock.WarpPlateStatus.ACTIVE : WarpPlateBlock.WarpPlateStatus.INVALID;
final var status = getTargetWaystone().filter(IWaystone::isValid)
.map(it -> WarpPlateBlock.WarpPlateStatus.ACTIVE)
.orElse(WarpPlateBlock.WarpPlateStatus.INVALID);
level.setBlock(worldPosition, getBlockState()
.setValue(WarpPlateBlock.ACTIVE, true)
.setValue(WarpPlateBlock.STATUS, status), 3);
Expand Down Expand Up @@ -426,9 +428,8 @@ public ItemStack getTargetAttunementStack() {
return ItemStack.EMPTY;
}

@Nullable
public IWaystone getTargetWaystone() {
return WaystonesAPI.getBoundWaystone(getTargetAttunementStack()).orElse(null);
public Optional<IWaystone> getTargetWaystone() {
return WaystonesAPI.getBoundWaystone(getTargetAttunementStack());
}

public int getMaxAttunementTicks() {
Expand Down

0 comments on commit 5036824

Please sign in to comment.