From 001433cc206deb12ec10abc08c4b83c281698455 Mon Sep 17 00:00:00 2001 From: alexbegt Date: Thu, 26 Mar 2020 01:21:24 -0400 Subject: [PATCH] Add the new rendering methods to all of our Baked models that allows for IModelData. --- .../client/model/BakedCompositeModel.java | 11 ++++++- .../mantle/client/model/BakedSimple.java | 19 +++++++++++- .../mantle/client/model/BakedWrapper.java | 27 +++++++++++++++-- .../client/model/BlockItemModelWrapper.java | 29 +++++++++++++++++-- 4 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java b/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java index 9cbe6f1..d118410 100644 --- a/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java +++ b/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java @@ -8,6 +8,8 @@ import net.minecraft.block.BlockState; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.util.Direction; +import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.client.model.data.IModelData; import java.util.List; import java.util.Random; @@ -31,7 +33,14 @@ public class BakedCompositeModel extends BakedWrapper { @Nonnull @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + @Deprecated + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { + return this.getQuads(state, side, rand, EmptyModelData.INSTANCE); + } + + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { return this.parts.get(Optional.fromNullable(side)); } diff --git a/src/main/java/slimeknights/mantle/client/model/BakedSimple.java b/src/main/java/slimeknights/mantle/client/model/BakedSimple.java index 50441fd..39ed1db 100644 --- a/src/main/java/slimeknights/mantle/client/model/BakedSimple.java +++ b/src/main/java/slimeknights/mantle/client/model/BakedSimple.java @@ -12,6 +12,8 @@ import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; import net.minecraftforge.client.model.PerspectiveMapWrapper; +import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.client.model.data.IModelData; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -60,7 +62,14 @@ public class BakedSimple implements IBakedModel { @Nonnull @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { + @Deprecated + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { + return this.getQuads(state, side, rand, EmptyModelData.INSTANCE); + } + + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { return this.quads; } @@ -86,12 +95,20 @@ public class BakedSimple implements IBakedModel { @Nonnull @Override + @Deprecated public TextureAtlasSprite getParticleTexture() { return this.particle; } @Nonnull @Override + public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) { + return this.particle; + } + + @Nonnull + @Override + @Deprecated public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } diff --git a/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java b/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java index 860e90d..e4aa2e5 100644 --- a/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BakedWrapper.java @@ -10,7 +10,11 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ILightReader; import net.minecraftforge.client.model.PerspectiveMapWrapper; +import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.client.model.data.IModelData; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -28,8 +32,14 @@ public class BakedWrapper implements IBakedModel { @Nonnull @Override @Deprecated - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { - return this.parent.getQuads(state, side, rand); + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { + return this.getQuads(state, side, rand, EmptyModelData.INSTANCE); + } + + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { + return this.parent.getQuads(state, side, rand, extraData); } @Override @@ -54,10 +64,17 @@ public class BakedWrapper implements IBakedModel { @Nonnull @Override + @Deprecated public TextureAtlasSprite getParticleTexture() { return this.parent.getParticleTexture(); } + @Nonnull + @Override + public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) { + return this.parent.getParticleTexture(data); + } + @Nonnull @Override @Deprecated @@ -71,6 +88,12 @@ public class BakedWrapper implements IBakedModel { return this.parent.getOverrides(); } + @Nonnull + @Override + public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { + return this.parent.getModelData(world, pos, state, tileData); + } + public static class Perspective extends BakedWrapper implements IBakedModel { protected final ImmutableMap transforms; diff --git a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java index cf5318e..d600e92 100644 --- a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.model; +import com.google.common.base.Optional; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.TransformationMatrix; @@ -9,6 +10,10 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ILightReader; +import net.minecraftforge.client.model.data.EmptyModelData; +import net.minecraftforge.client.model.data.IModelData; import slimeknights.mantle.client.ModelHelper; import javax.annotation.Nonnull; @@ -46,8 +51,15 @@ public class BlockItemModelWrapper implements IBakedModel { @Nonnull @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { - return this.parent.getQuads(state, side, rand); + @Deprecated + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { + return this.getQuads(state, side, rand, EmptyModelData.INSTANCE); + } + + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { + return this.parent.getQuads(state, side, rand, extraData); } @Override @@ -72,10 +84,23 @@ public class BlockItemModelWrapper implements IBakedModel { @Nonnull @Override + @Deprecated public TextureAtlasSprite getParticleTexture() { return this.parent.getParticleTexture(); } + @Nonnull + @Override + public TextureAtlasSprite getParticleTexture(@Nonnull IModelData data) { + return this.parent.getParticleTexture(data); + } + + @Nonnull + @Override + public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData) { + return this.parent.getModelData(world, pos, state, tileData); + } + @Nonnull @Override @Deprecated