Skip to content

Commit

Permalink
Fixed qibs not getting registered properly Noxcrew#105
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Oct 1, 2024
1 parent e970805 commit b67f67b
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.world.phys.AABB;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -16,11 +17,26 @@
@Mixin(Entity.class)
public abstract class SpatialEntityMixin {

@Unique
private boolean noxesium$initialized = false;

@Shadow
public abstract AABB getBoundingBox();

@Inject(method = "setId", at = @At("RETURN"))
public void setId(int i, CallbackInfo ci) {
// When the entity id is set we trigger a spatial container update!
if (((Object) this) instanceof Interaction interaction) {
noxesium$initialized = true;
SpatialInteractionEntityTree.update(interaction);
}
}

@Inject(method = "setBoundingBox", at = @At("HEAD"))
public void onUpdateBoundingBox(AABB aABB, CallbackInfo ci) {
// Ignore updates until the entity id has been set
if (!noxesium$initialized) return;

// Ignore if we're already at the exact same position!
if (((Object) this) instanceof Interaction interaction && !aABB.equals(getBoundingBox())) {
SpatialInteractionEntityTree.update(interaction);
Expand Down

0 comments on commit b67f67b

Please sign in to comment.