-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NPE from CompressibleMapData.createKeyFromCurrentBlocks
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/main/java/uk/protonull/civvoxelmap/mixins/catching/FixNullBlockStateIdMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters