diff --git a/src/main/java/com/ferreusveritas/dynamictrees/event/handler/BakedModelEventHandler.java b/src/main/java/com/ferreusveritas/dynamictrees/event/handler/BakedModelEventHandler.java index 29f38b042..6f130069b 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/event/handler/BakedModelEventHandler.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/event/handler/BakedModelEventHandler.java @@ -3,7 +3,6 @@ import com.ferreusveritas.dynamictrees.DynamicTrees; import com.ferreusveritas.dynamictrees.block.PottedSaplingBlock; import com.ferreusveritas.dynamictrees.models.baked.BakedModelBlockBonsaiPot; -import com.ferreusveritas.dynamictrees.models.baked.BranchBlockBakedModel; import com.ferreusveritas.dynamictrees.models.loader.BranchBlockModelLoader; import com.ferreusveritas.dynamictrees.models.loader.RootBlockModelLoader; import com.ferreusveritas.dynamictrees.models.loader.ThickBranchBlockModelLoader; @@ -36,10 +35,6 @@ public static void onModelRegistryEvent(RegisterGeometryLoaders event) { @SubscribeEvent public static void onModelBake(BakingCompleted event) { - // Setup branch baked models (bakes cores and sleeves). - BranchBlockBakedModel.INSTANCES.forEach(BranchBlockBakedModel::setupModels); - BranchBlockBakedModel.INSTANCES.clear(); - // Put bonsai pot baked model into its model location. BakedModel flowerPotModel = event.getModelManager().getModel(new ModelResourceLocation(PottedSaplingBlock.REG_NAME, "")); event.getModels().put(new ModelResourceLocation(PottedSaplingBlock.REG_NAME, ""), diff --git a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/BasicBranchBlockBakedModel.java b/src/main/java/com/ferreusveritas/dynamictrees/models/baked/BasicBranchBlockBakedModel.java index 7d63cfdb4..fcb15af73 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/BasicBranchBlockBakedModel.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/models/baked/BasicBranchBlockBakedModel.java @@ -7,55 +7,58 @@ import com.google.common.collect.Maps; import com.mojang.math.Vector3f; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.BlockElement; -import net.minecraft.client.renderer.block.model.BlockElementFace; -import net.minecraft.client.renderer.block.model.BlockFaceUV; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BlockModelRotation; +import net.minecraft.client.resources.model.Material; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.AxisDirection; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.model.IDynamicBakedModel; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.data.ModelData; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Function; @OnlyIn(Dist.CLIENT) -public class BasicBranchBlockBakedModel extends BranchBlockBakedModel { +public class BasicBranchBlockBakedModel implements IDynamicBakedModel { - protected TextureAtlasSprite barkTexture; - protected TextureAtlasSprite ringsTexture; + protected final BlockModel blockModel; + + protected final ResourceLocation modelLocation; + + protected final TextureAtlasSprite barkTexture; + protected final TextureAtlasSprite ringsTexture; // 74 Baked models per tree family to achieve this. I guess it's not my problem. Wasn't my idea anyway. private final BakedModel[][] sleeves = new BakedModel[6][7]; private final BakedModel[][] cores = new BakedModel[3][8]; // 8 Cores for 3 axis with the bark texture all all 6 sides rotated appropriately. private final BakedModel[] rings = new BakedModel[8]; // 8 Cores with the ring textures on all 6 sides. - public BasicBranchBlockBakedModel(ResourceLocation modelResLoc, ResourceLocation barkResLoc, ResourceLocation ringsResLoc) { - super(modelResLoc, barkResLoc, ringsResLoc); + public BasicBranchBlockBakedModel(ResourceLocation modelLocation, ResourceLocation barkTextureLocation, ResourceLocation ringsTextureLocation, + Function spriteGetter) { + this.blockModel = new BlockModel(null, new ArrayList<>(), new HashMap<>(), false, BlockModel.GuiLight.FRONT, + ItemTransforms.NO_TRANSFORMS, new ArrayList<>()); + this.modelLocation = modelLocation; + this.barkTexture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, barkTextureLocation)); + this.ringsTexture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, ringsTextureLocation)); + initModels(); } - @Override - public void setupModels() { - this.barkTexture = ModelUtils.getTexture(this.barkResLoc); - this.ringsTexture = ModelUtils.getTexture(this.ringsResLoc); - + private void initModels() { for (int i = 0; i < 8; i++) { int radius = i + 1; if (radius < 8) { @@ -67,7 +70,7 @@ public void setupModels() { cores[1][i] = bakeCore(radius, Axis.Z, barkTexture); //NORTH<->SOUTH cores[2][i] = bakeCore(radius, Axis.X, barkTexture); //WEST<->EAST - rings[i] = bakeCore(radius, Axis.Y, this.ringsTexture); + rings[i] = bakeCore(radius, Axis.Y, ringsTexture); } } @@ -114,7 +117,7 @@ public BakedModel bakeSleeve(int radius, Direction dir, TextureAtlasSprite bark) for (Map.Entry e : part.faces.entrySet()) { Direction face = e.getKey(); - builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), bark, face, BlockModelRotation.X0_Y0, this.modelResLoc)); + builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), bark, face, BlockModelRotation.X0_Y0, this.modelLocation)); } return builder.build(); @@ -137,7 +140,7 @@ public BakedModel bakeCore(int radius, Axis axis, TextureAtlasSprite icon) { for (Map.Entry e : part.faces.entrySet()) { Direction face = e.getKey(); - builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), icon, face, BlockModelRotation.X0_Y0, this.modelResLoc)); + builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), icon, face, BlockModelRotation.X0_Y0, this.modelLocation)); } return builder.build(); diff --git a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/BranchBlockBakedModel.java b/src/main/java/com/ferreusveritas/dynamictrees/models/baked/BranchBlockBakedModel.java deleted file mode 100644 index 2d52050c8..000000000 --- a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/BranchBlockBakedModel.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.ferreusveritas.dynamictrees.models.baked; - -import com.ferreusveritas.dynamictrees.event.handler.BakedModelEventHandler; -import net.minecraft.client.renderer.block.model.BlockModel; -import net.minecraft.client.renderer.block.model.ItemTransforms; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.model.IDynamicBakedModel; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -/** - * Holds general model data and sets up a {@link BlockModel} for branch block baked models. - * - *

Main implementation is {@link BasicBranchBlockBakedModel}, which is the baked model - * for dynamic branches with radius 1-8.

- * - * @author Harley O'Connor - */ -public abstract class BranchBlockBakedModel implements IDynamicBakedModel { - - /** - * A list of {@link BranchBlockBakedModel} instances, so that {@link #setupModels} can be called in {@link - * BakedModelEventHandler}. - */ - public static final List INSTANCES = new ArrayList<>(); - - protected final BlockModel blockModel; - - protected final ResourceLocation modelResLoc; - protected final ResourceLocation barkResLoc; - protected final ResourceLocation ringsResLoc; - - public BranchBlockBakedModel(ResourceLocation modelResLoc, ResourceLocation barkResLoc, ResourceLocation ringsResLoc) { - this.blockModel = new BlockModel(null, new ArrayList<>(), new HashMap<>(), false, BlockModel.GuiLight.FRONT, ItemTransforms.NO_TRANSFORMS, new ArrayList<>()); - - this.modelResLoc = modelResLoc; - this.barkResLoc = barkResLoc; - this.ringsResLoc = ringsResLoc; - - INSTANCES.add(this); - } - - /** - * BakedModelEventHandler#onModelBake(ModelBakeEvent)}, once the textures have been stitched and so can be baked - * onto models. - */ - public abstract void setupModels(); - -} \ No newline at end of file diff --git a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/RootBlockBakedModel.java b/src/main/java/com/ferreusveritas/dynamictrees/models/baked/RootBlockBakedModel.java index 8d813446a..c9bc5ea11 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/RootBlockBakedModel.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/models/baked/RootBlockBakedModel.java @@ -7,51 +7,53 @@ import com.google.common.collect.Maps; import com.mojang.math.Vector3f; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.BlockElement; -import net.minecraft.client.renderer.block.model.BlockElementFace; -import net.minecraft.client.renderer.block.model.BlockFaceUV; -import net.minecraft.client.renderer.block.model.ItemOverrides; +import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BlockModelRotation; +import net.minecraft.client.resources.model.Material; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.model.IDynamicBakedModel; import net.minecraftforge.client.model.IModelBuilder; import net.minecraftforge.client.model.data.ModelData; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.function.Function; @OnlyIn(Dist.CLIENT) -public class RootBlockBakedModel extends BranchBlockBakedModel { +public class RootBlockBakedModel implements IDynamicBakedModel { - private TextureAtlasSprite barkTexture; + private final BlockModel blockModel; + + private final ResourceLocation modelLocation; + + private final TextureAtlasSprite barkTexture; private final BakedModel[][] sleeves = new BakedModel[4][7]; private final BakedModel[][] cores = new BakedModel[2][8]; //8 Cores for 2 axis(X, Z) with the bark texture on all 6 sides rotated appropriately. private final BakedModel[][] verts = new BakedModel[4][8]; - public RootBlockBakedModel(ResourceLocation modelResLoc, ResourceLocation barkResLoc) { - super(modelResLoc, barkResLoc, null); + public RootBlockBakedModel(ResourceLocation modelLocation, ResourceLocation barkTextureLocation, Function spriteGetter) { + this.blockModel = new BlockModel(null, new ArrayList<>(), new HashMap<>(), false, BlockModel.GuiLight.FRONT, + ItemTransforms.NO_TRANSFORMS, new ArrayList<>()); + this.modelLocation = modelLocation; + this.barkTexture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, barkTextureLocation)); + initModels(); } - @Override - public void setupModels() { - this.barkTexture = ModelUtils.getTexture(this.barkResLoc); - + public void initModels() { for (int r = 0; r < 8; r++) { int radius = r + 1; if (radius < 8) { @@ -112,7 +114,7 @@ public BakedModel bakeSleeve(int radius, Direction dir) { for (Map.Entry e : part.faces.entrySet()) { Direction face = e.getKey(); - builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), this.barkTexture, face, BlockModelRotation.X0_Y0, this.modelResLoc)); + builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), this.barkTexture, face, BlockModelRotation.X0_Y0, this.modelLocation)); } return builder.build(); @@ -137,7 +139,7 @@ private BakedModel bakeVert(int radius, Direction dir) { Vector3f[] limits = ModelUtils.AABBLimits(pieceBoundary); BlockElement part = new BlockElement(limits[0], limits[1], mapFacesIn, null, true); - builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, part.faces.get(face), this.barkTexture, face, BlockModelRotation.X0_Y0, this.modelResLoc)); + builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, part.faces.get(face), this.barkTexture, face, BlockModelRotation.X0_Y0, this.modelLocation)); } } @@ -169,7 +171,7 @@ public BakedModel bakeCore(int radius, Direction.Axis axis, TextureAtlasSprite i for (Map.Entry e : part.faces.entrySet()) { Direction face = e.getKey(); - builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), icon, face, BlockModelRotation.X0_Y0, this.modelResLoc)); + builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, e.getValue(), icon, face, BlockModelRotation.X0_Y0, this.modelLocation)); } return builder.build(); diff --git a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/ThickBranchBlockBakedModel.java b/src/main/java/com/ferreusveritas/dynamictrees/models/baked/ThickBranchBlockBakedModel.java index 3dbb1878c..a0611fc7a 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/models/baked/ThickBranchBlockBakedModel.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/models/baked/ThickBranchBlockBakedModel.java @@ -17,12 +17,14 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BlockModelRotation; +import net.minecraft.client.resources.model.Material; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.core.Vec3i; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -37,40 +39,26 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Function; @OnlyIn(Dist.CLIENT) public class ThickBranchBlockBakedModel extends BasicBranchBlockBakedModel { - protected final ResourceLocation thickRingsResLoc; - private final BakedModel[] trunksBark = new BakedModel[16]; // The trunk will always feature bark on its sides. private final BakedModel[] trunksTopBark = new BakedModel[16]; // The trunk will feature bark on its top when there's a branch on top of it. private final BakedModel[] trunksTopRings = new BakedModel[16]; // The trunk will feature rings on its top when there's no branches on top of it. private final BakedModel[] trunksBotRings = new BakedModel[16]; // The trunk will always feature rings on its bottom surface if nothing is below it. - public ThickBranchBlockBakedModel(ResourceLocation modelResLoc, ResourceLocation barkResLoc, ResourceLocation ringsResLoc, ResourceLocation thickRingsResLoc) { - super(modelResLoc, barkResLoc, ringsResLoc); - this.thickRingsResLoc = thickRingsResLoc; - } - - private boolean isTextureNull(@Nullable TextureAtlasSprite sprite) { - return sprite == null || sprite.equals(ModelUtils.getTexture(new ResourceLocation(""))); + public ThickBranchBlockBakedModel(ResourceLocation modelLocation, ResourceLocation barkTextureLocation, ResourceLocation ringsTextureLocation, + ResourceLocation thickRingsTextureLocation, Function spriteGetter) { + super(modelLocation, barkTextureLocation, ringsTextureLocation, spriteGetter); + initThickModels(spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, thickRingsTextureLocation))); } - @Override - public void setupModels() { - super.setupModels(); - - TextureAtlasSprite thickRingsTexture = ModelUtils.getTexture(this.thickRingsResLoc); - - //if (isTextureNull(thickRingsTexture)){ - //thickRingsTexture = ThickRingTextureManager.uploader.getTextureAtlas().getSprite(thickRingsResLoc); - //thickRingsTexture = ModelUtils.getTexture(thickRingsResLoc, ThickRingTextureManager.LOCATION_THICKRINGS_TEXTURE); - + public void initThickModels(TextureAtlasSprite thickRingsTexture) { if (isTextureNull(thickRingsTexture)) { thickRingsTexture = this.ringsTexture; } - //} for (int i = 0; i < ThickBranchBlock.MAX_RADIUS_THICK - ThickBranchBlock.MAX_RADIUS; i++) { int radius = i + ThickBranchBlock.MAX_RADIUS + 1; @@ -81,6 +69,10 @@ public void setupModels() { } } + private boolean isTextureNull(@Nullable TextureAtlasSprite sprite) { + return sprite == null || sprite.getName().equals(new ResourceLocation("")); + } + public BakedModel bakeTrunkBark(int radius, TextureAtlasSprite bark, boolean side) { IModelBuilder builder = ModelUtils.getModelBuilder(this.blockModel.customData, bark); @@ -110,7 +102,7 @@ public BakedModel bakeTrunkBark(int radius, TextureAtlasSprite bark, boolean sid mapFacesIn.put(face, new BlockElementFace(null, -1, null, uvface)); BlockElement part = new BlockElement(limits[0], limits[1], mapFacesIn, null, true); - builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, part.faces.get(face), bark, face, BlockModelRotation.X0_Y0, this.modelResLoc)); + builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, part.faces.get(face), bark, face, BlockModelRotation.X0_Y0, this.modelLocation)); } } @@ -158,7 +150,7 @@ public BakedModel bakeTrunkRings(int radius, TextureAtlasSprite ring, Direction mapFacesIn.put(face, new BlockElementFace(null, -1, null, uvface)); BlockElement part = new BlockElement(posFrom, posTo, mapFacesIn, null, true); - builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, part.faces.get(face), ring, face, BlockModelRotation.X0_Y0, this.modelResLoc)); + builder.addCulledFace(face, ModelUtils.makeBakedQuad(part, part.faces.get(face), ring, face, BlockModelRotation.X0_Y0, this.modelLocation)); } return builder.build(); diff --git a/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/BranchBlockModelGeometry.java b/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/BranchBlockModelGeometry.java index 22b609df3..56d101d0b 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/BranchBlockModelGeometry.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/BranchBlockModelGeometry.java @@ -7,14 +7,10 @@ import com.ferreusveritas.dynamictrees.tree.family.Family; import com.mojang.datafixers.util.Pair; import net.minecraft.client.renderer.block.model.ItemOverrides; -import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.client.resources.model.*; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.InventoryMenu; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.geometry.IGeometryBakingContext; @@ -40,32 +36,32 @@ public class BranchBlockModelGeometry implements IUnbakedGeometry { protected final Set textures = new HashSet<>(); - protected final ResourceLocation barkResLoc; - protected final ResourceLocation ringsResLoc; + protected final ResourceLocation barkTextureLocation; + protected final ResourceLocation ringsTextureLocation; protected final boolean forceThickness; - protected ResourceLocation familyResLoc; + protected ResourceLocation familyName; protected Family family; - protected ResourceLocation thickRingsResLoc; + protected ResourceLocation thickRingsTextureLocation; - public BranchBlockModelGeometry(@Nullable final ResourceLocation barkResLoc, @Nullable final ResourceLocation ringsResLoc, @Nullable final ResourceLocation familyResLoc, final boolean forceThickness) { - this.barkResLoc = barkResLoc; - this.ringsResLoc = ringsResLoc; - this.familyResLoc = familyResLoc; + public BranchBlockModelGeometry(@Nullable final ResourceLocation barkTextureLocation, @Nullable final ResourceLocation ringsTextureLocation, @Nullable final ResourceLocation familyName, final boolean forceThickness) { + this.barkTextureLocation = barkTextureLocation; + this.ringsTextureLocation = ringsTextureLocation; + this.familyName = familyName; this.forceThickness = forceThickness; - this.addTextures(barkResLoc, ringsResLoc); + this.addTextures(barkTextureLocation, ringsTextureLocation); } /** * Adds the given texture {@link ResourceLocation} objects to the list. Checks they're not null before adding them * so {@link Nullable} objects can be fed safely. * - * @param textureResourceLocations Texture {@link ResourceLocation} objects. + * @param textureLocations Texture {@link ResourceLocation} objects. */ - protected void addTextures(final ResourceLocation... textureResourceLocations) { - for (ResourceLocation resourceLocation : textureResourceLocations) { + protected void addTextures(final ResourceLocation... textureLocations) { + for (ResourceLocation resourceLocation : textureLocations) { if (resourceLocation != null) { this.textures.add(resourceLocation); } @@ -75,22 +71,22 @@ protected void addTextures(final ResourceLocation... textureResourceLocations) { @Override public BakedModel bake(IGeometryBakingContext owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { if (!this.useThickModel(this.setFamily(modelLocation))) { - return new BasicBranchBlockBakedModel(modelLocation, this.barkResLoc, this.ringsResLoc); + return new BasicBranchBlockBakedModel(modelLocation, this.barkTextureLocation, this.ringsTextureLocation, spriteGetter); } else { - return new ThickBranchBlockBakedModel(modelLocation, this.barkResLoc, this.ringsResLoc, this.thickRingsResLoc); + return new ThickBranchBlockBakedModel(modelLocation, this.barkTextureLocation, this.ringsTextureLocation, this.thickRingsTextureLocation, spriteGetter); } } - private ResourceLocation setFamilyResLoc(final ResourceLocation modelResLoc) { - if (this.familyResLoc == null) { - this.familyResLoc = new ResourceLocation(modelResLoc.getNamespace(), modelResLoc.getPath().replace("block/", "").replace("_branch", "").replace("stripped_", "")); + private ResourceLocation setFamilyName(final ResourceLocation modelLocation) { + if (this.familyName == null) { + this.familyName = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath().replace("block/", "").replace("_branch", "").replace("stripped_", "")); } - return this.familyResLoc; + return this.familyName; } private Family setFamily(final ResourceLocation modelResLoc) { if (this.family == null) { - this.family = Family.REGISTRY.get(this.setFamilyResLoc(modelResLoc)); + this.family = Family.REGISTRY.get(this.setFamilyName(modelResLoc)); } return this.family; } @@ -102,13 +98,13 @@ private boolean useThickModel(final Family family) { @SuppressWarnings("deprecation") @Override public Collection getMaterials(IGeometryBakingContext owner, Function modelGetter, Set> missingTextureErrors) { - if (this.thickRingsResLoc == null && this.useThickModel(this.setFamily(new ResourceLocation(owner.getModelName())))) { - this.thickRingsResLoc = ThickRingTextureManager.addRingTextureLocation(this.ringsResLoc); - this.addTextures(this.thickRingsResLoc); + if (this.thickRingsTextureLocation == null && this.useThickModel(this.setFamily(new ResourceLocation(owner.getModelName())))) { + this.thickRingsTextureLocation = ThickRingTextureManager.addRingTextureLocation(this.ringsTextureLocation); + this.addTextures(this.thickRingsTextureLocation); } return this.textures.stream() - .map(resourceLocation -> new Material(TextureAtlas.LOCATION_BLOCKS, resourceLocation)) + .map(resourceLocation -> new Material(InventoryMenu.BLOCK_ATLAS, resourceLocation)) .collect(Collectors.toList()); } diff --git a/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/RootBlockModelGeometry.java b/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/RootBlockModelGeometry.java index 3c55c72bf..83ea1be3c 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/RootBlockModelGeometry.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/models/geometry/RootBlockModelGeometry.java @@ -26,7 +26,7 @@ public RootBlockModelGeometry(final ResourceLocation barkResLoc) { @Override public BakedModel bake(IGeometryBakingContext owner, ModelBakery bakery, Function spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) { - return new RootBlockBakedModel(modelLocation, this.barkResLoc); + return new RootBlockBakedModel(modelLocation, this.barkTextureLocation, spriteGetter); } } \ No newline at end of file diff --git a/src/main/java/com/ferreusveritas/dynamictrees/models/loader/BranchBlockModelLoader.java b/src/main/java/com/ferreusveritas/dynamictrees/models/loader/BranchBlockModelLoader.java index 851e841f6..f4d67f3ad 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/models/loader/BranchBlockModelLoader.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/models/loader/BranchBlockModelLoader.java @@ -33,10 +33,10 @@ public class BranchBlockModelLoader implements IGeometryLoader