From 04a307e8aabdac39f597292e0f696fc29ca0947e Mon Sep 17 00:00:00 2001 From: Alexander Behrhof Date: Tue, 10 Mar 2020 17:00:20 -0400 Subject: [PATCH] Hopefully fix the crash regarding loading the Atlas textures during mod construction. Closes #212 --- .../com/progwml6/ironchest/IronChests.java | 3 -- .../IronChestTileEntityRenderer.java | 2 +- .../client/tileentity/IronChestsModels.java | 54 +++++++------------ 3 files changed, 20 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/progwml6/ironchest/IronChests.java b/src/main/java/com/progwml6/ironchest/IronChests.java index 4e739cb..43dc027 100644 --- a/src/main/java/com/progwml6/ironchest/IronChests.java +++ b/src/main/java/com/progwml6/ironchest/IronChests.java @@ -3,9 +3,7 @@ package com.progwml6.ironchest; import com.progwml6.ironchest.client.data.IronChestsLangProvider; import com.progwml6.ironchest.client.screen.IronChestScreen; import com.progwml6.ironchest.client.tileentity.IronChestTileEntityRenderer; -import com.progwml6.ironchest.client.tileentity.IronChestsModels; import com.progwml6.ironchest.common.block.IronChestsBlocks; -import com.progwml6.ironchest.common.block.IronChestsTypes; import com.progwml6.ironchest.common.block.tileentity.IronChestsTileEntityTypes; import com.progwml6.ironchest.common.inventory.IronChestsContainerTypes; import com.progwml6.ironchest.common.item.IronChestsItems; @@ -47,7 +45,6 @@ public class IronChests { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { // Client setup modBus.addListener(this::setupClient); - new IronChestsModels(); }); // Registry objects diff --git a/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestTileEntityRenderer.java b/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestTileEntityRenderer.java index 1f6a6b5..800d65a 100644 --- a/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestTileEntityRenderer.java +++ b/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestTileEntityRenderer.java @@ -82,7 +82,7 @@ public class IronChestTileEntityRenderer exten f1 = 1.0F - f1 * f1 * f1; int i = iCallbackWrapper.apply(new DualBrightnessCallback<>()).applyAsInt(combinedLightIn); - Material material = IronChestsModels.chooseChestModel(tileEntity, chestType); + Material material = new Material(Atlases.CHEST_ATLAS, IronChestsModels.chooseChestTexture(chestType)); IVertexBuilder ivertexbuilder = material.getBuffer(bufferIn, RenderType::getEntityCutout); this.handleModelRender(matrixStackIn, ivertexbuilder, this.chestLid, this.chestLock, this.chestBottom, f1, i, combinedOverlayIn); diff --git a/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestsModels.java b/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestsModels.java index c2a7109..089dfb3 100644 --- a/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestsModels.java +++ b/src/main/java/com/progwml6/ironchest/client/tileentity/IronChestsModels.java @@ -16,33 +16,17 @@ import java.util.function.Consumer; @Mod.EventBusSubscriber(modid = IronChests.MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) public class IronChestsModels { - public static final ResourceLocation chestAtlas = new ResourceLocation("textures/atlas/chest.png"); + public static final ResourceLocation IRON_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/iron_chest"); + public static final ResourceLocation GOLD_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/gold_chest"); + public static final ResourceLocation DIAMOND_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/diamond_chest"); + public static final ResourceLocation COPPER_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/copper_chest"); + public static final ResourceLocation SILVER_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/silver_chest"); + public static final ResourceLocation CRYSTAL_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/crystal_chest"); + public static final ResourceLocation OBSIDIAN_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/obsidian_chest"); + public static final ResourceLocation DIRT_CHEST_LOCATION = new ResourceLocation(IronChests.MODID, "model/dirt_chest"); + public static final ResourceLocation VANLLA_CHEST_LOCATION = new ResourceLocation("entity/chest/normal"); - public static final Material IRON_CHEST_LOCATION = getChestMaterial("iron"); - public static final Material GOLD_CHEST_LOCATION = getChestMaterial("gold"); - public static final Material DIAMOND_CHEST_LOCATION = getChestMaterial("diamond"); - public static final Material COPPER_CHEST_LOCATION = getChestMaterial("copper"); - public static final Material SILVER_CHEST_LOCATION = getChestMaterial("silver"); - public static final Material CRYSTAL_CHEST_LOCATION = getChestMaterial("crystal"); - public static final Material OBSIDIAN_CHEST_LOCATION = getChestMaterial("obsidian"); - public static final Material DIRT_CHEST_LOCATION = getChestMaterial("dirt"); - - public static void addTextures(Consumer p_228775_0_) { - p_228775_0_.accept(IRON_CHEST_LOCATION); - p_228775_0_.accept(GOLD_CHEST_LOCATION); - p_228775_0_.accept(DIAMOND_CHEST_LOCATION); - p_228775_0_.accept(COPPER_CHEST_LOCATION); - p_228775_0_.accept(SILVER_CHEST_LOCATION); - p_228775_0_.accept(CRYSTAL_CHEST_LOCATION); - p_228775_0_.accept(OBSIDIAN_CHEST_LOCATION); - p_228775_0_.accept(DIRT_CHEST_LOCATION); - } - - private static Material getChestMaterial(String name) { - return new Material(Atlases.CHEST_ATLAS, new ResourceLocation(IronChests.MODID, "model/" + name + "_chest")); - } - - public static Material chooseChestModel(TileEntity tileEntity, IronChestsTypes type) { + public static ResourceLocation chooseChestTexture(IronChestsTypes type) { switch (type) { case IRON: return IRON_CHEST_LOCATION; @@ -62,7 +46,7 @@ public class IronChestsModels { return DIRT_CHEST_LOCATION; case WOOD: default: - return Atlases.CHEST_MATERIAL; + return VANLLA_CHEST_LOCATION; } } @@ -72,13 +56,13 @@ public class IronChestsModels { return; } - event.addSprite(IRON_CHEST_LOCATION.getTextureLocation()); - event.addSprite(GOLD_CHEST_LOCATION.getTextureLocation()); - event.addSprite(DIAMOND_CHEST_LOCATION.getTextureLocation()); - event.addSprite(COPPER_CHEST_LOCATION.getTextureLocation()); - event.addSprite(SILVER_CHEST_LOCATION.getTextureLocation()); - event.addSprite(CRYSTAL_CHEST_LOCATION.getTextureLocation()); - event.addSprite(OBSIDIAN_CHEST_LOCATION.getTextureLocation()); - event.addSprite(DIRT_CHEST_LOCATION.getTextureLocation()); + event.addSprite(IRON_CHEST_LOCATION); + event.addSprite(GOLD_CHEST_LOCATION); + event.addSprite(DIAMOND_CHEST_LOCATION); + event.addSprite(COPPER_CHEST_LOCATION); + event.addSprite(SILVER_CHEST_LOCATION); + event.addSprite(CRYSTAL_CHEST_LOCATION); + event.addSprite(OBSIDIAN_CHEST_LOCATION); + event.addSprite(DIRT_CHEST_LOCATION); } }