forked from Nyan-Work/oh-my-minecraft-client
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hendrix-Shen <[email protected]>
- Loading branch information
1 parent
17b552c
commit c4dc36d
Showing
11 changed files
with
109 additions
and
16 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
...y/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.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,9 @@ | ||
package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; | ||
|
||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public class BlockRenderer { | ||
public native void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin); | ||
} |
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
41 changes: 41 additions & 0 deletions
41
.../java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.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,41 @@ | ||
package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; | ||
|
||
import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; | ||
import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; | ||
import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; | ||
import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; | ||
import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
|
||
@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.6- <0.7-")) | ||
@Pseudo | ||
@Mixin(value = BlockRenderer.class, remap = false) | ||
public abstract class MixinBlockRenderer_0_6 { | ||
@Dynamic | ||
@WrapOperation( | ||
method = "renderModel", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/block/state/BlockState;hasOffsetFunction()Z", | ||
ordinal = 0, | ||
remap = true | ||
), | ||
remap = false | ||
) | ||
private boolean blockModelNoOffset(BlockState blockState, Operation<Boolean> original) { | ||
if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { | ||
return false; | ||
} | ||
|
||
return original.call(blockState); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
...ava/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.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 com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; | ||
|
||
import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; | ||
import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; | ||
import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.spongepowered.asm.mixin.*; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; | ||
import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; | ||
|
||
@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.6- <0.7-")) | ||
@Pseudo | ||
@Mixin(value = BlockRenderer.class, remap = false) | ||
public abstract class MixinBlockRenderer_0_6 { | ||
@Shadow(remap = false) | ||
public abstract void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin); | ||
|
||
@Unique | ||
private final ThreadLocal<Boolean> ommc$renderTag = ThreadLocal.withInitial(() -> false); | ||
|
||
@Dynamic | ||
@Inject(method = "renderModel", at = @At("RETURN")) | ||
private void postRenderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) { | ||
if (WorldEaterMineHelper.shouldUseCustomModel(state, pos) && !this.ommc$renderTag.get()) { | ||
BakedModel customModel = WorldEaterMineHelper.customModels.get(state.getBlock()); | ||
|
||
if (customModel != null) { | ||
this.ommc$renderTag.set(true); | ||
int originalLightEmission = state.getLightEmission(); | ||
((AccessorBlockStateBase) state).setLightEmission(15); | ||
this.renderModel(customModel, state, pos, origin); | ||
((AccessorBlockStateBase) state).setLightEmission(originalLightEmission); | ||
this.ommc$renderTag.set(false); | ||
} | ||
} | ||
} | ||
} |
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