-
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 when placing getting from cached block positions
- Loading branch information
Showing
2 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/net/mcbrawls/blueprint/mixin/CachedBlockPositionMixin.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,17 @@ | ||
package net.mcbrawls.blueprint.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.pattern.CachedBlockPosition; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(CachedBlockPosition.class) | ||
public class CachedBlockPositionMixin { | ||
// fix crashes when getBlockState happens to return null | ||
@ModifyReturnValue(method = "getBlockState", at = @At("RETURN")) | ||
private BlockState onGetBlockState(BlockState original) { | ||
return original == null ? Blocks.AIR.getDefaultState() : original; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
{ | ||
"required": true, | ||
"package": "net.mcbrawls.blueprint.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"required": true, | ||
"package": "net.mcbrawls.blueprint.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"CachedBlockPositionMixin", | ||
"ServerPlayerEntityMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |