From 7d8ccbd715f2fbeca497ea9b86022f5c2eb0bb15 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Mon, 10 Feb 2020 17:07:06 +0000 Subject: [PATCH] Fix ForwardingBakedModel not forwarding isSideLit. Closes #501 (#502) * Fix ForwardingBakedModel not forwarding isSideLit. Closes #501 * Remove unused DamageModel * Bump version --- fabric-renderer-api-v1/build.gradle | 2 +- .../v1/model/ForwardingBakedModel.java | 8 +- .../fabric/impl/renderer/DamageModel.java | 75 ------------------- 3 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/impl/renderer/DamageModel.java diff --git a/fabric-renderer-api-v1/build.gradle b/fabric-renderer-api-v1/build.gradle index ecbc6c33c..4967cfe99 100644 --- a/fabric-renderer-api-v1/build.gradle +++ b/fabric-renderer-api-v1/build.gradle @@ -1,5 +1,5 @@ archivesBaseName = "fabric-renderer-api-v1" -version = getSubprojectVersion(project, "0.2.9") +version = getSubprojectVersion(project, "0.2.10") dependencies { compile project(path: ':fabric-api-base', configuration: 'dev') diff --git a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ForwardingBakedModel.java b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ForwardingBakedModel.java index 2b2037b25..b18d5724f 100644 --- a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ForwardingBakedModel.java +++ b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/model/ForwardingBakedModel.java @@ -32,11 +32,10 @@ import net.minecraft.util.math.Direction; import net.minecraft.world.BlockRenderView; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; -import net.fabricmc.fabric.impl.renderer.DamageModel; /** * Base class for specialized model implementations that need to wrap other baked models. - * Avoids boilerplate code for pass-through methods. For example usage see {@link DamageModel}. + * Avoids boilerplate code for pass-through methods. */ public abstract class ForwardingBakedModel implements BakedModel, FabricBakedModel { /** implementations must set this somehow. */ @@ -82,6 +81,11 @@ public abstract class ForwardingBakedModel implements BakedModel, FabricBakedMod return wrapped.getSprite(); } + @Override + public boolean isSideLit() { + return wrapped.isSideLit(); + } + @Override public ModelTransformation getTransformation() { return wrapped.getTransformation(); diff --git a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/impl/renderer/DamageModel.java b/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/impl/renderer/DamageModel.java deleted file mode 100644 index 1553cf280..000000000 --- a/fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/impl/renderer/DamageModel.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.renderer; - -import java.util.Random; -import java.util.function.Supplier; - -import net.minecraft.block.BlockState; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.texture.Sprite; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockRenderView; - -import net.fabricmc.fabric.api.renderer.v1.RendererAccess; -import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial; -import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView; -import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; -import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel; -import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; - -/** - * Specialized model wrapper that implements a general-purpose - * block-breaking render for enhanced models. - * - *

Works by intercepting all model output and redirecting to dynamic - * quads that are baked with single-layer, UV-locked damage texture. - */ -public class DamageModel extends ForwardingBakedModel { - static final RenderMaterial DAMAGE_MATERIAL = RendererAccess.INSTANCE.hasRenderer() ? RendererAccess.INSTANCE.getRenderer().materialFinder().find() : null; - - private DamageTransform damageTransform = new DamageTransform(); - - public void prepare(BakedModel wrappedModel, Sprite sprite, BlockState blockState, BlockPos blockPos) { - this.damageTransform.damageSprite = sprite; - this.wrapped = wrappedModel; - } - - @Override - public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { - context.pushTransform(damageTransform); - ((FabricBakedModel) wrapped).emitBlockQuads(blockView, state, pos, randomSupplier, context); - context.popTransform(); - } - - @Override - public boolean isSideLit() { - return false; - } - - private static class DamageTransform implements RenderContext.QuadTransform { - private Sprite damageSprite; - - @Override - public boolean transform(MutableQuadView quad) { - quad.material(DAMAGE_MATERIAL); - quad.spriteBake(0, damageSprite, MutableQuadView.BAKE_LOCK_UV); - quad.colorIndex(-1); - return true; - } - } -}