generated from TropheusJ/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 34
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
2 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
.../src/main/java/io/github/fabricators_of_create/porting_lib/model/RenderMaterialModel.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,47 @@ | ||
package io.github.fabricators_of_create.porting_lib.model; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial; | ||
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel; | ||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.BlockAndTintGetter; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
public class RenderMaterialModel extends ForwardingBakedModel { | ||
protected final RenderMaterial material; | ||
|
||
public RenderMaterialModel(BakedModel owner, RenderMaterial material) { | ||
this.wrapped = owner; | ||
this.material = material; | ||
} | ||
|
||
@Override | ||
public boolean isVanillaAdapter() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<RandomSource> randomSupplier, RenderContext context) { | ||
context.pushTransform(quad -> { | ||
quad.material(this.material); | ||
return true; | ||
}); | ||
super.emitBlockQuads(blockView, state, pos, randomSupplier, context); | ||
context.popTransform(); | ||
} | ||
|
||
@Override | ||
public void emitItemQuads(ItemStack stack, Supplier<RandomSource> randomSupplier, RenderContext context) { | ||
context.pushTransform(quad -> { | ||
quad.material(this.material); | ||
return true; | ||
}); | ||
super.emitItemQuads(stack, randomSupplier, context); | ||
context.popTransform(); | ||
} | ||
} |
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