Skip to content

Commit

Permalink
Fix NPE from CompressibleMapData.createKeyFromCurrentBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Protonull committed Jul 24, 2024
1 parent 24271ee commit 6343774
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package uk.protonull.civvoxelmap.mixins.catching;

import com.mamiyaotaru.voxelmap.persistent.CompressibleMapData;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

/**
* TODO: This should no longer be an issue after 1.21 update
* @see <a href="https://github.com/fantahund/VoxelMap/commit/2982c416fd8ecf4c0331bc103e0c11bf65e511cc">2982c416fd8ecf4c0331bc103e0c11bf65e511cc</a>
*/
@Mixin(CompressibleMapData.class)
public abstract class FixNullBlockStateIdMixin {
@ModifyVariable(
method = "createKeyFromCurrentBlocks",
at = @At(
value = "INVOKE",
target = "Lcom/mamiyaotaru/voxelmap/persistent/CompressibleMapData;setData(IIIB)V",
shift = At.Shift.BEFORE,
opcode = Opcodes.ASTORE
),
remap = false
)
protected @NotNull Integer cvm$createKeyFromCurrentBlocks$zeroOutNullIds(
final Integer id
) {
return id == null ? 0 : id;
}

@ModifyVariable(
method = "getIDFromState",
at = @At("TAIL"),
remap = false
)
protected @NotNull Integer cvm$getIDFromState$zeroOutNullIds(
final Integer id
) {
return id == null ? 0 : id;
}
}
1 change: 1 addition & 0 deletions src/main/resources/civvoxelmap.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"catching.ChatWaypointSafelyClickMixin",
"catching.ChatWaypointSafelyParseMixin",
"catching.FixEnumErrorMixin",
"catching.FixNullBlockStateIdMixin",
"commands.DisableVoxelMapCommands",
"commands.ReplaceVoxelMapCommands",
"elevation.ObscureElevationMixin",
Expand Down

0 comments on commit 6343774

Please sign in to comment.