Skip to content

Commit

Permalink
Add try-catch and mark as todo
Browse files Browse the repository at this point in the history
A cleaner fix would be to use our own copycat base block state, but that would require a lot more work
  • Loading branch information
hlysine committed Sep 15, 2024
1 parent bfc9eb8 commit dcbe5a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ public class BlockStateBaseCacheMixin {
)
private boolean canCopycatOcclude(BlockState instance,
Operation<Boolean> original) {
if (instance.getBlockHolder().is(Mods.CREATE.rl("copycat_base"))) {
return false;
try {
if (instance.getBlockHolder().is(Mods.CREATE.rl("copycat_base"))) {
return false;
}
} catch (IllegalStateException e) {
// todo: illegal access if resource location is accessed before registry is initialized
}
if (instance.getBlock() instanceof BracketBlock) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.copycatsplus.copycats.mixin.foundation.copycat;

import com.copycatsplus.copycats.compat.Mods;
import com.simibubi.create.content.decoration.bracket.BracketBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -16,8 +17,12 @@ public class BlockStateBaseMixin {
)
private void customOcclusion(CallbackInfoReturnable<Boolean> cir) {
BlockBehaviour.BlockStateBase instance = (BlockBehaviour.BlockStateBase) (Object) this;
if (instance.getBlock().getClass().toString().equals("com.copycatsplus.copycats.foundation.copycat.CopycatBaseBlock.class")) {
cir.setReturnValue(false);
try {
if (instance.getBlockHolder().is(Mods.CREATE.rl("copycat_base"))) {
cir.setReturnValue(false);
}
} catch (IllegalStateException e) {
// todo: illegal access if resource location is accessed before registry is initialized
}
if (instance.getBlock() instanceof BracketBlock) {
cir.setReturnValue(false);
Expand Down

0 comments on commit dcbe5a6

Please sign in to comment.