Skip to content

Commit

Permalink
hopefully fixed some null pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Goby56 committed Sep 14, 2024
1 parent 16ac081 commit b0a0b3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/goby56/wakes/simulation/WakeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void insert(WakeNode node) {
this.trees[i] = new QuadTree(node.y);
}

if (node.validPos()) {
if (node.validPos(world)) {
this.toBeInserted[i].add(node);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/goby56/wakes/simulation/WakeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;

import java.util.*;

Expand Down Expand Up @@ -140,6 +140,7 @@ public boolean tick() {

public void floodFill() {
WakeHandler wh = WakeHandler.getInstance();
assert wh != null;
if (floodLevel > 0 && this.age > WakesClient.CONFIG_INSTANCE.ticksBeforeFill) {
if (this.NORTH == null) {
wh.insert(new WakeNode(this.x, this.y, this.z - 1, floodLevel - 1));
Expand Down Expand Up @@ -195,9 +196,9 @@ public void updateFloodLevel(int newLevel) {
}
}

public boolean validPos() {
FluidState fluidState = MinecraftClient.getInstance().world.getFluidState(this.blockPos());
FluidState fluidStateAbove = MinecraftClient.getInstance().world.getFluidState(this.blockPos().up());
public boolean validPos(World world) {
FluidState fluidState = world.getFluidState(this.blockPos());
FluidState fluidStateAbove = world.getFluidState(this.blockPos().up());
if (fluidState.isOf(Fluids.WATER) && fluidStateAbove.isEmpty()) {
return fluidState.isStill();
}
Expand Down

0 comments on commit b0a0b3b

Please sign in to comment.