-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
250 additions
and
34 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
common/src/main/java/org/valkyrienskies/tournament/mixin/client/MixinBlockClient.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,33 @@ | ||
package org.valkyrienskies.tournament.mixin.client; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.valkyrienskies.tournament.util.block.WithExRenderInfo; | ||
|
||
@Mixin(Block.class) | ||
public class MixinBlockClient { | ||
@Inject(at = @At("HEAD"), method = "shouldRenderFace", cancellable = true) | ||
private static void shouldRenderFace(BlockState state, BlockGetter level, BlockPos offset, Direction face, BlockPos pos, CallbackInfoReturnable<Boolean> cir) { | ||
var blockState = level.getBlockState(pos); | ||
if (blockState.getBlock() instanceof WithExRenderInfo blockEx) { | ||
var info = blockEx.getFaceRenderType(blockState, level, pos, face); | ||
|
||
if (info == WithExRenderInfo.FaceRenderType.FORCE_RENDER) { | ||
cir.setReturnValue(true); | ||
return; | ||
} | ||
|
||
if (info == WithExRenderInfo.FaceRenderType.FORCE_NOT_RENDER) { | ||
cir.setReturnValue(false); | ||
return; | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
common/src/main/java/org/valkyrienskies/tournament/util/block/WithExRenderInfo.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,16 @@ | ||
package org.valkyrienskies.tournament.util.block; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public interface WithExRenderInfo { | ||
FaceRenderType getFaceRenderType(BlockState state, BlockGetter level, BlockPos pos, Direction face); | ||
|
||
enum FaceRenderType { | ||
NORMAL, | ||
FORCE_RENDER, | ||
FORCE_NOT_RENDER, | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.