mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fix leaf flowers rendering on fast graphics
This commit is contained in:
parent
de016d30dd
commit
cdfc4babb4
15 changed files with 113 additions and 147 deletions
|
@ -44,6 +44,7 @@ repositories {
|
||||||
maven { name 'minelp-snapshot'; url 'https://repo.minelittlepony-mod.com/maven/snapshot' }
|
maven { name 'minelp-snapshot'; url 'https://repo.minelittlepony-mod.com/maven/snapshot' }
|
||||||
maven { name 'minelp-releases'; url 'https://repo.minelittlepony-mod.com/maven/release' }
|
maven { name 'minelp-releases'; url 'https://repo.minelittlepony-mod.com/maven/release' }
|
||||||
maven { name 'TerraformersMC'; url 'https://maven.terraformersmc.com/' }
|
maven { name 'TerraformersMC'; url 'https://maven.terraformersmc.com/' }
|
||||||
|
maven { name 'Nodium'; url 'https://maven.cafeteria.dev/releases/' }
|
||||||
maven { name 'Modrinth'; url 'https://api.modrinth.com/maven' }
|
maven { name 'Modrinth'; url 'https://api.modrinth.com/maven' }
|
||||||
maven { name 'JitPack'; url 'https://jitpack.io'; content { includeGroup "com.github.Virtuoel" } }
|
maven { name 'JitPack'; url 'https://jitpack.io'; content { includeGroup "com.github.Virtuoel" } }
|
||||||
}
|
}
|
||||||
|
@ -74,6 +75,9 @@ dependencies {
|
||||||
modImplementation "com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraformer_api_version}"
|
modImplementation "com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraformer_api_version}"
|
||||||
include "com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraformer_api_version}"
|
include "com.terraformersmc.terraform-api:terraform-wood-api-v1:${project.terraformer_api_version}"
|
||||||
|
|
||||||
|
modImplementation "me.luligabi:NoIndium:${project.nodium_version}"
|
||||||
|
include "me.luligabi:NoIndium:${project.nodium_version}"
|
||||||
|
|
||||||
modCompileOnly "maven.modrinth:farmers-delight-fabric:${project.farmers_delight_version}", { exclude group: "net.fabricmc.fabric-api" }
|
modCompileOnly "maven.modrinth:farmers-delight-fabric:${project.farmers_delight_version}", { exclude group: "net.fabricmc.fabric-api" }
|
||||||
if (project.use_pehkui == '1') {
|
if (project.use_pehkui == '1') {
|
||||||
modCompileOnly "maven.modrinth:pehkui:${project.pehkui_version}", { exclude group: "net.fabricmc.fabric-api" }
|
modCompileOnly "maven.modrinth:pehkui:${project.pehkui_version}", { exclude group: "net.fabricmc.fabric-api" }
|
||||||
|
@ -81,8 +85,9 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.use_sodium == '1') {
|
if (project.use_sodium == '1') {
|
||||||
|
modCompileOnly "maven.modrinth:indium:${project.indium_version}", { exclude group: "net.fabricmc.fabric-api" }
|
||||||
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}", { exclude group: "net.fabricmc.fabric-api" }
|
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}", { exclude group: "net.fabricmc.fabric-api" }
|
||||||
modCompileOnly "maven.modrinth:iris:${project.iris_version}", { exclude group: "net.fabricmc.fabric-api" }
|
// modCompileOnly "maven.modrinth:iris:${project.iris_version}", { exclude group: "net.fabricmc.fabric-api" }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.tmi_type == 'emi') {
|
if (project.tmi_type == 'emi') {
|
||||||
|
|
|
@ -4,9 +4,9 @@ org.gradle.daemon=false
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.20.1
|
||||||
yarn_mappings=1.20.1+build.9
|
yarn_mappings=1.20.1+build.10
|
||||||
loader_version=0.14.21
|
loader_version=0.15.7
|
||||||
fabric_version=0.85.0+1.20.1
|
fabric_version=0.92.0+1.20.1
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
group=com.minelittlepony
|
group=com.minelittlepony
|
||||||
|
@ -27,6 +27,7 @@ org.gradle.daemon=false
|
||||||
reach_attributes_version=2.3.4
|
reach_attributes_version=2.3.4
|
||||||
trinkets_version=3.7.1
|
trinkets_version=3.7.1
|
||||||
terraformer_api_version=7.0.0-beta.1
|
terraformer_api_version=7.0.0-beta.1
|
||||||
|
nodium_version=1.1.0+1.20
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
use_pehkui=0
|
use_pehkui=0
|
||||||
|
@ -34,8 +35,9 @@ org.gradle.daemon=false
|
||||||
|
|
||||||
farmers_delight_version=1.4.3
|
farmers_delight_version=1.4.3
|
||||||
pehkui_version=3.7.8+1.14.4-1.20.1
|
pehkui_version=3.7.8+1.14.4-1.20.1
|
||||||
iris_version=1.6.8+1.20.1
|
iris_version=1.6.17+1.20.1
|
||||||
sodium_version=mc1.20.1-0.5.2
|
sodium_version=mc1.20.1-0.5.8
|
||||||
|
indium_version=1.0.30+mc1.20.4
|
||||||
|
|
||||||
# TMI Testing
|
# TMI Testing
|
||||||
tmi_type=emi
|
tmi_type=emi
|
||||||
|
|
|
@ -156,6 +156,7 @@ public interface URenderers {
|
||||||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(), UBlocks.SEMI_TRANSPARENT_BLOCKS.stream().toArray(Block[]::new));
|
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(), UBlocks.SEMI_TRANSPARENT_BLOCKS.stream().toArray(Block[]::new));
|
||||||
// for lava boats
|
// for lava boats
|
||||||
BlockRenderLayerMap.INSTANCE.putFluids(RenderLayer.getTranslucent(), Fluids.LAVA, Fluids.FLOWING_LAVA);
|
BlockRenderLayerMap.INSTANCE.putFluids(RenderLayer.getTranslucent(), Fluids.LAVA, Fluids.FLOWING_LAVA);
|
||||||
|
LeavesAdditionsModel.bootstrap();
|
||||||
|
|
||||||
TerraformBoatClientHelper.registerModelLayers(Unicopia.id("palm"), false);
|
TerraformBoatClientHelper.registerModelLayers(Unicopia.id("palm"), false);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.minelittlepony.unicopia.client.render;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.block.FruitBearingBlock;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
|
||||||
|
import net.fabricmc.fabric.api.client.model.loading.v1.ModelModifier;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.material.MaterialFinder;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
|
||||||
|
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.random.Random;
|
||||||
|
import net.minecraft.world.BlockRenderView;
|
||||||
|
|
||||||
|
public final class LeavesAdditionsModel extends ForwardingBakedModel {
|
||||||
|
public static void bootstrap() {
|
||||||
|
ModelLoadingPlugin.register(ctx -> {
|
||||||
|
ctx.modifyModelAfterBake().register(ModelModifier.WRAP_PHASE, (model, context) -> {
|
||||||
|
Identifier id = context.id();
|
||||||
|
if (!id.getPath().endsWith("_flowering") || !(Registries.BLOCK.get(id.withPath(p -> p.replace("block/", "").replace("_flowering", ""))) instanceof FruitBearingBlock)) {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
return model == null ? null : new LeavesAdditionsModel(model);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private LeavesAdditionsModel(BakedModel model) {
|
||||||
|
this.wrapped = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVanillaAdapter() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
|
||||||
|
MaterialFinder finder = RendererAccess.INSTANCE.getRenderer().materialFinder();
|
||||||
|
context.pushTransform(quad -> {
|
||||||
|
quad.material(finder.copyFrom(quad.material()).blendMode(BlendMode.CUTOUT).find());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
super.emitBlockQuads(blockView, state, pos, randomSupplier, context);
|
||||||
|
context.popTransform();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.compat.sodium;
|
|
||||||
|
|
||||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
|
||||||
import net.fabricmc.fabric.api.util.TriState;
|
|
||||||
|
|
||||||
public class Impl implements SodiumDelegate {
|
|
||||||
static Impl INSTANCE = new Impl();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TriState isFancyLeavesOrBetter() {
|
|
||||||
return switch (SodiumClientMod.options().quality.leavesQuality) {
|
|
||||||
case FAST -> TriState.FALSE;
|
|
||||||
case FANCY -> TriState.TRUE;
|
|
||||||
case DEFAULT -> TriState.DEFAULT;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.compat.sodium;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.util.TriState;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
|
|
||||||
public interface SodiumDelegate {
|
|
||||||
SodiumDelegate EMPTY = new SodiumDelegate() {};
|
|
||||||
|
|
||||||
static SodiumDelegate getInstance() {
|
|
||||||
if (FabricLoader.getInstance().isModLoaded("sodium")) {
|
|
||||||
return Impl.INSTANCE;
|
|
||||||
}
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
default TriState isFancyLeavesOrBetter() {
|
|
||||||
return TriState.DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,6 +5,8 @@ import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
|
|
||||||
public class StressfulEnchantment extends SimpleEnchantment {
|
public class StressfulEnchantment extends SimpleEnchantment {
|
||||||
|
|
||||||
protected StressfulEnchantment(Options options) {
|
protected StressfulEnchantment(Options options) {
|
||||||
|
@ -13,8 +15,18 @@ public class StressfulEnchantment extends SimpleEnchantment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserTick(Living<?> user, int level) {
|
public void onUserTick(Living<?> user, int level) {
|
||||||
if (user instanceof Pony) {
|
if (user instanceof Pony pony && pony.asEntity().age % 10 == 0) {
|
||||||
Bar bar = ((Pony)user).getMagicalReserves().getEnergy();
|
int range = (level + 1) * 3;
|
||||||
|
if (pony.asWorld().getEntitiesByClass(HostileEntity.class, user.asEntity().getBoundingBox().expand(range, 0, range), enemy -> {
|
||||||
|
return enemy != null
|
||||||
|
&& enemy.canTarget(user.asEntity())
|
||||||
|
&& enemy.canSee(user.asEntity())
|
||||||
|
&& enemy.getTarget() == user.asEntity();
|
||||||
|
}).isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bar bar = pony.getMagicalReserves().getEnergy();
|
||||||
float targetPercent = (level / (float)getMaxLevel()) * 0.05125F;
|
float targetPercent = (level / (float)getMaxLevel()) * 0.05125F;
|
||||||
float increase = 1F + (level * level)/100F;
|
float increase = 1F + (level * level)/100F;
|
||||||
if (bar.getPercentFill() < targetPercent) {
|
if (bar.getPercentFill() < targetPercent) {
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package com.minelittlepony.unicopia.mixin.client;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.block.FruitBearingBlock;
|
|
||||||
import com.minelittlepony.unicopia.compat.sodium.SodiumDelegate;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.render.block.BlockModels;
|
|
||||||
|
|
||||||
@Mixin(BlockModels.class)
|
|
||||||
abstract class MixinBlockModels {
|
|
||||||
@ModifyVariable(
|
|
||||||
method = "getModel(Lnet/minecraft/block/BlockState;)Lnet/minecraft/client/render/model/BakedModel;",
|
|
||||||
at = @At("HEAD"),
|
|
||||||
argsOnly = true,
|
|
||||||
ordinal = 0
|
|
||||||
)
|
|
||||||
private BlockState getAppearance(BlockState state) {
|
|
||||||
if (state.contains(FruitBearingBlock.STAGE)
|
|
||||||
&& !SodiumDelegate.getInstance().isFancyLeavesOrBetter().orElse(MinecraftClient.isFancyGraphicsOrBetter())) {
|
|
||||||
return state.with(FruitBearingBlock.STAGE, FruitBearingBlock.Stage.IDLE);
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +1,11 @@
|
||||||
{
|
{
|
||||||
"variants": {
|
"multipart": [
|
||||||
"stage=flowering": {
|
{
|
||||||
"model": "unicopia:block/green_apple_leaves_flowering"
|
"apply": { "model": "unicopia:block/green_apple_leaves" }
|
||||||
},
|
},
|
||||||
"stage=idle": {
|
{
|
||||||
"model": "unicopia:block/green_apple_leaves"
|
"apply": { "model": "unicopia:block/green_apple_leaves_flowering" },
|
||||||
},
|
"when": { "stage": "flowering" }
|
||||||
"stage=fruiting": {
|
|
||||||
"model": "unicopia:block/green_apple_leaves"
|
|
||||||
},
|
|
||||||
"stage=withering": {
|
|
||||||
"model": "unicopia:block/green_apple_leaves"
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
{
|
{
|
||||||
"variants": {
|
"multipart": [
|
||||||
"stage=flowering": {
|
{
|
||||||
"model": "unicopia:block/sour_apple_leaves_flowering"
|
"apply": { "model": "unicopia:block/sour_apple_leaves" }
|
||||||
},
|
},
|
||||||
"stage=idle": {
|
{
|
||||||
"model": "unicopia:block/sour_apple_leaves"
|
"apply": { "model": "unicopia:block/sour_apple_leaves_flowering" },
|
||||||
},
|
"when": { "stage": "flowering" }
|
||||||
"stage=fruiting": {
|
|
||||||
"model": "unicopia:block/sour_apple_leaves"
|
|
||||||
},
|
|
||||||
"stage=withering": {
|
|
||||||
"model": "unicopia:block/sour_apple_leaves"
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
{
|
{
|
||||||
"variants": {
|
"multipart": [
|
||||||
"stage=flowering": {
|
{
|
||||||
"model": "unicopia:block/sweet_apple_leaves_flowering"
|
"apply": { "model": "unicopia:block/sweet_apple_leaves" }
|
||||||
},
|
},
|
||||||
"stage=idle": {
|
{
|
||||||
"model": "unicopia:block/sweet_apple_leaves"
|
"apply": { "model": "unicopia:block/sweet_apple_leaves_flowering" },
|
||||||
},
|
"when": { "stage": "flowering" }
|
||||||
"stage=fruiting": {
|
|
||||||
"model": "unicopia:block/sweet_apple_leaves"
|
|
||||||
},
|
|
||||||
"stage=withering": {
|
|
||||||
"model": "unicopia:block/sweet_apple_leaves"
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"parent": "unicopia:block/sweet_apple_leaves_flowering",
|
"parent": "minecraft:block/cube_all",
|
||||||
"textures": {
|
"textures": {
|
||||||
"all": "unicopia:block/green_apple_leaves",
|
"all": "unicopia:block/green_apple_leaves_flowering"
|
||||||
"overlay": "unicopia:block/green_apple_leaves_flowering"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"parent": "unicopia:block/sweet_apple_leaves_flowering",
|
"parent": "minecraft:block/cube_all",
|
||||||
"textures": {
|
"textures": {
|
||||||
"all": "unicopia:block/sour_apple_leaves",
|
"all": "unicopia:block/sour_apple_leaves_flowering"
|
||||||
"overlay": "unicopia:block/sour_apple_leaves_flowering"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,31 +1,6 @@
|
||||||
{ "parent": "minecraft:block/block",
|
{
|
||||||
"textures": {
|
"parent": "minecraft:block/cube_all",
|
||||||
"all": "unicopia:block/sweet_apple_leaves",
|
"textures": {
|
||||||
"particle": "#all",
|
"all": "unicopia:block/sweet_apple_leaves_flowering"
|
||||||
"overlay": "unicopia:block/sweet_apple_leaves_flowering"
|
}
|
||||||
},
|
|
||||||
"elements": [
|
|
||||||
{ "from": [ 0, 0, 0 ],
|
|
||||||
"to": [ 16, 16, 16 ],
|
|
||||||
"faces": {
|
|
||||||
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "down" },
|
|
||||||
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "up" },
|
|
||||||
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "north" },
|
|
||||||
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "south" },
|
|
||||||
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "west" },
|
|
||||||
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "tintindex": 0, "cullface": "east" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ "from": [ 0, 0, 0 ],
|
|
||||||
"to": [ 16, 16, 16 ],
|
|
||||||
"faces": {
|
|
||||||
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "cullface": "down" },
|
|
||||||
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "cullface": "up" },
|
|
||||||
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "cullface": "north" },
|
|
||||||
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "cullface": "south" },
|
|
||||||
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "cullface": "west" },
|
|
||||||
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "cullface": "east" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
|
@ -65,7 +65,6 @@
|
||||||
"client.MixinAnimalModel",
|
"client.MixinAnimalModel",
|
||||||
"client.MixinArmorFeatureRenderer",
|
"client.MixinArmorFeatureRenderer",
|
||||||
"client.MixinBackgroundRenderer",
|
"client.MixinBackgroundRenderer",
|
||||||
"client.MixinBlockModels",
|
|
||||||
"client.MixinCamera",
|
"client.MixinCamera",
|
||||||
"client.MixinClientWorld",
|
"client.MixinClientWorld",
|
||||||
"client.MixinClientPlayNetworkHandler",
|
"client.MixinClientPlayNetworkHandler",
|
||||||
|
|
Loading…
Reference in a new issue