Skip to content

Commit

Permalink
fix: npe when placing getting from cached block positions
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Oct 21, 2024
1 parent c4589e4 commit de85888
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
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;
}
}
15 changes: 8 additions & 7 deletions src/main/resources/blueprint.mixins.json
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
}
}

0 comments on commit de85888

Please sign in to comment.