|
2 | 2 |
|
3 | 3 | import com.progwml6.ironchest.IronChests; |
4 | 4 | import com.progwml6.ironchest.common.block.IronChestsTypes; |
| 5 | +import net.minecraft.client.renderer.Sheets; |
| 6 | +import net.minecraft.client.resources.model.Material; |
5 | 7 | import net.minecraft.resources.ResourceLocation; |
6 | 8 | import org.jetbrains.annotations.NotNull; |
7 | 9 |
|
8 | 10 | public class IronChestsModels { |
9 | 11 |
|
10 | | - public static final ResourceLocation IRON_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/iron_chest"); |
11 | | - public static final ResourceLocation GOLD_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/gold_chest"); |
12 | | - public static final ResourceLocation DIAMOND_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/diamond_chest"); |
13 | | - public static final ResourceLocation COPPER_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/copper_chest"); |
14 | | - public static final ResourceLocation CRYSTAL_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/crystal_chest"); |
15 | | - public static final ResourceLocation OBSIDIAN_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/obsidian_chest"); |
16 | | - public static final ResourceLocation DIRT_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/dirt_chest"); |
17 | | - public static final ResourceLocation VANILLA_CHEST_LOCATION = ResourceLocation.withDefaultNamespace("entity/chest/normal"); |
18 | | - |
19 | | - public static final ResourceLocation TRAPPED_IRON_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/trapped_iron_chest"); |
20 | | - public static final ResourceLocation TRAPPED_GOLD_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/trapped_gold_chest"); |
21 | | - public static final ResourceLocation TRAPPED_DIAMOND_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/trapped_diamond_chest"); |
22 | | - public static final ResourceLocation TRAPPED_COPPER_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/trapped_copper_chest"); |
23 | | - public static final ResourceLocation TRAPPED_CRYSTAL_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/trapped_crystal_chest"); |
24 | | - public static final ResourceLocation TRAPPED_OBSIDIAN_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/trapped_obsidian_chest"); |
25 | | - public static final ResourceLocation TRAPPED_DIRT_CHEST_LOCATION = ResourceLocation.fromNamespaceAndPath(IronChests.MODID, "model/trapped_dirt_chest"); |
26 | | - public static final ResourceLocation TRAPPED_VANILLA_CHEST_LOCATION = ResourceLocation.withDefaultNamespace("entity/chest/trapped"); |
27 | | - |
28 | | - public static ResourceLocation chooseChestTexture(IronChestsTypes type, boolean trapped) { |
| 12 | + public static final Material IRON_CHEST_LOCATION = chestMaterial(false, "model/iron_chest"); |
| 13 | + public static final Material GOLD_CHEST_LOCATION = chestMaterial(false, "model/gold_chest"); |
| 14 | + public static final Material DIAMOND_CHEST_LOCATION = chestMaterial(false, "model/diamond_chest"); |
| 15 | + public static final Material COPPER_CHEST_LOCATION = chestMaterial(false, "model/copper_chest"); |
| 16 | + public static final Material CRYSTAL_CHEST_LOCATION = chestMaterial(false, "model/crystal_chest"); |
| 17 | + public static final Material OBSIDIAN_CHEST_LOCATION = chestMaterial(false, "model/obsidian_chest"); |
| 18 | + public static final Material DIRT_CHEST_LOCATION = chestMaterial(false, "model/dirt_chest"); |
| 19 | + public static final Material VANILLA_CHEST_LOCATION = chestMaterial(true, "normal"); |
| 20 | + |
| 21 | + public static final Material TRAPPED_IRON_CHEST_LOCATION = chestMaterial(false, "model/trapped_iron_chest"); |
| 22 | + public static final Material TRAPPED_GOLD_CHEST_LOCATION = chestMaterial(false, "model/trapped_gold_chest"); |
| 23 | + public static final Material TRAPPED_DIAMOND_CHEST_LOCATION = chestMaterial(false, "model/trapped_diamond_chest"); |
| 24 | + public static final Material TRAPPED_COPPER_CHEST_LOCATION = chestMaterial(false, "model/trapped_copper_chest"); |
| 25 | + public static final Material TRAPPED_CRYSTAL_CHEST_LOCATION = chestMaterial(false, "model/trapped_crystal_chest"); |
| 26 | + public static final Material TRAPPED_OBSIDIAN_CHEST_LOCATION = chestMaterial(false, "model/trapped_obsidian_chest"); |
| 27 | + public static final Material TRAPPED_DIRT_CHEST_LOCATION = chestMaterial(false, "model/trapped_dirt_chest"); |
| 28 | + public static final Material TRAPPED_VANILLA_CHEST_LOCATION = chestMaterial(true, "trapped"); |
| 29 | + |
| 30 | + public static Material chooseChestMaterial(IronChestsTypes type, boolean trapped) { |
29 | 31 | if (trapped) { |
30 | | - return getResourceLocation(type, TRAPPED_IRON_CHEST_LOCATION, TRAPPED_GOLD_CHEST_LOCATION, TRAPPED_DIAMOND_CHEST_LOCATION, TRAPPED_COPPER_CHEST_LOCATION, TRAPPED_CRYSTAL_CHEST_LOCATION, TRAPPED_OBSIDIAN_CHEST_LOCATION, TRAPPED_DIRT_CHEST_LOCATION, TRAPPED_VANILLA_CHEST_LOCATION); |
| 32 | + return getMaterial(type, TRAPPED_IRON_CHEST_LOCATION, TRAPPED_GOLD_CHEST_LOCATION, TRAPPED_DIAMOND_CHEST_LOCATION, TRAPPED_COPPER_CHEST_LOCATION, TRAPPED_CRYSTAL_CHEST_LOCATION, TRAPPED_OBSIDIAN_CHEST_LOCATION, TRAPPED_DIRT_CHEST_LOCATION, TRAPPED_VANILLA_CHEST_LOCATION); |
31 | 33 | } else { |
32 | | - return getResourceLocation(type, IRON_CHEST_LOCATION, GOLD_CHEST_LOCATION, DIAMOND_CHEST_LOCATION, COPPER_CHEST_LOCATION, CRYSTAL_CHEST_LOCATION, OBSIDIAN_CHEST_LOCATION, DIRT_CHEST_LOCATION, VANILLA_CHEST_LOCATION); |
| 34 | + return getMaterial(type, IRON_CHEST_LOCATION, GOLD_CHEST_LOCATION, DIAMOND_CHEST_LOCATION, COPPER_CHEST_LOCATION, CRYSTAL_CHEST_LOCATION, OBSIDIAN_CHEST_LOCATION, DIRT_CHEST_LOCATION, VANILLA_CHEST_LOCATION); |
33 | 35 | } |
34 | 36 | } |
35 | 37 |
|
36 | 38 | @NotNull |
37 | | - private static ResourceLocation getResourceLocation(IronChestsTypes type, ResourceLocation ironChestLocation, ResourceLocation goldChestLocation, ResourceLocation diamondChestLocation, ResourceLocation copperChestLocation, ResourceLocation crystalChestLocation, ResourceLocation obsidianChestLocation, ResourceLocation dirtChestLocation, ResourceLocation vanillaChestLocation) { |
| 39 | + private static Material getMaterial(IronChestsTypes type, Material ironChestMaterial, Material goldChestMaterial, Material diamondChestMaterial, Material copperChestMaterial, Material crystalChestMaterial, Material obsidianChestMaterial, Material dirtChestMaterial, Material vanillaChestMaterial) { |
38 | 40 | return switch (type) { |
39 | | - case IRON -> ironChestLocation; |
40 | | - case GOLD -> goldChestLocation; |
41 | | - case DIAMOND -> diamondChestLocation; |
42 | | - case COPPER -> copperChestLocation; |
43 | | - case CRYSTAL -> crystalChestLocation; |
44 | | - case OBSIDIAN -> obsidianChestLocation; |
45 | | - case DIRT -> dirtChestLocation; |
46 | | - default -> vanillaChestLocation; |
| 41 | + case IRON -> ironChestMaterial; |
| 42 | + case GOLD -> goldChestMaterial; |
| 43 | + case DIAMOND -> diamondChestMaterial; |
| 44 | + case COPPER -> copperChestMaterial; |
| 45 | + case CRYSTAL -> crystalChestMaterial; |
| 46 | + case OBSIDIAN -> obsidianChestMaterial; |
| 47 | + case DIRT -> dirtChestMaterial; |
| 48 | + default -> vanillaChestMaterial; |
47 | 49 | }; |
48 | 50 | } |
| 51 | + |
| 52 | + private static Material chestMaterial(boolean vanillaChest, String chestName) { |
| 53 | + if (vanillaChest) { |
| 54 | + return new Material(Sheets.CHEST_SHEET, ResourceLocation.withDefaultNamespace("entity/chest/" + chestName)); |
| 55 | + } else { |
| 56 | + return new Material(Sheets.CHEST_SHEET, IronChests.prefix(chestName)); |
| 57 | + } |
| 58 | + |
| 59 | + } |
49 | 60 | } |
0 commit comments