Skip to content

Commit 7e953c7

Browse files
committed
Fix Chest Atlas registration for Iron Chest Models to no longer unintentionally add non-chest textures to the chest atlas, fix block names missing and bump version
1 parent d187fba commit 7e953c7

File tree

11 files changed

+141
-44
lines changed

11 files changed

+141
-44
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod_name=Iron Chests
3131
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3232
mod_license=GNU General Public License v3.0
3333
# The mod version. See https://semver.org/
34-
mod_version=16.0
34+
mod_version=16.1
3535
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
3636
# This should match the base package used for the mod sources.
3737
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// 1.21.3 2025-01-05T17:50:41.718282 atlases generator for ironchest
2-
bba03f0849be21ea0fb2f99f25b892838b1ec7a2 assets/minecraft/atlases/chests.json
1+
// 1.21.3 2025-01-11T20:23:38.755165 atlases generator for ironchest
2+
34291928e0b4986474567815a26c170f6e6e270d assets/minecraft/atlases/chests.json
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// 1.21.3 2025-01-11T19:53:35.266962 Pack Metadata
2+
796aa3de45caa2aa28f39ce30c7723751feabdad pack.mcmeta
Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,60 @@
11
{
22
"sources": [
33
{
4-
"type": "minecraft:directory",
5-
"prefix": "model/",
6-
"source": "model"
4+
"type": "minecraft:single",
5+
"resource": "ironchest:model/iron_chest"
6+
},
7+
{
8+
"type": "minecraft:single",
9+
"resource": "ironchest:model/trapped_iron_chest"
10+
},
11+
{
12+
"type": "minecraft:single",
13+
"resource": "ironchest:model/gold_chest"
14+
},
15+
{
16+
"type": "minecraft:single",
17+
"resource": "ironchest:model/trapped_gold_chest"
18+
},
19+
{
20+
"type": "minecraft:single",
21+
"resource": "ironchest:model/diamond_chest"
22+
},
23+
{
24+
"type": "minecraft:single",
25+
"resource": "ironchest:model/trapped_diamond_chest"
26+
},
27+
{
28+
"type": "minecraft:single",
29+
"resource": "ironchest:model/copper_chest"
30+
},
31+
{
32+
"type": "minecraft:single",
33+
"resource": "ironchest:model/trapped_copper_chest"
34+
},
35+
{
36+
"type": "minecraft:single",
37+
"resource": "ironchest:model/crystal_chest"
38+
},
39+
{
40+
"type": "minecraft:single",
41+
"resource": "ironchest:model/trapped_crystal_chest"
42+
},
43+
{
44+
"type": "minecraft:single",
45+
"resource": "ironchest:model/obsidian_chest"
46+
},
47+
{
48+
"type": "minecraft:single",
49+
"resource": "ironchest:model/trapped_obsidian_chest"
50+
},
51+
{
52+
"type": "minecraft:single",
53+
"resource": "ironchest:model/dirt_chest"
54+
},
55+
{
56+
"type": "minecraft:single",
57+
"resource": "ironchest:model/trapped_dirt_chest"
758
}
859
]
960
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"pack": {
3+
"description": "Resources for Iron Chests",
4+
"pack_format": 57,
5+
"supported_formats": [
6+
0,
7+
2147483647
8+
]
9+
}
10+
}

src/main/java/com/progwml6/ironchest/IronChests.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313
import com.progwml6.ironchest.common.inventory.IronChestsMenuTypes;
1414
import com.progwml6.ironchest.common.item.IronChestsItems;
1515
import com.progwml6.ironchest.common.network.TopStacksSyncPacket;
16+
import net.minecraft.DetectedVersion;
1617
import net.minecraft.core.HolderLookup;
1718
import net.minecraft.data.DataGenerator;
1819
import net.minecraft.data.PackOutput;
20+
import net.minecraft.data.metadata.PackMetadataGenerator;
21+
import net.minecraft.network.chat.Component;
1922
import net.minecraft.resources.ResourceLocation;
23+
import net.minecraft.server.packs.PackType;
24+
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
25+
import net.minecraft.util.InclusiveRange;
2026
import net.neoforged.bus.api.IEventBus;
2127
import net.neoforged.fml.common.Mod;
2228
import net.neoforged.neoforge.capabilities.Capabilities;
@@ -26,10 +32,9 @@
2632
import net.neoforged.neoforge.items.wrapper.InvWrapper;
2733
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
2834
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
29-
import org.apache.logging.log4j.LogManager;
30-
import org.apache.logging.log4j.Logger;
3135

3236
import java.util.Locale;
37+
import java.util.Optional;
3338
import java.util.concurrent.CompletableFuture;
3439

3540
@Mod(IronChests.MODID)
@@ -63,6 +68,10 @@ public void gatherData(GatherDataEvent event) {
6368
gen.addProvider(event.includeClient(), new IronChestsBlockTags(packOutput, lookupProvider, ext));
6469
gen.addProvider(event.includeClient(), new IronChestsSpriteSourceProvider(packOutput, ext, lookupProvider));
6570
gen.addProvider(event.includeClient(), new IronChestsLanguageProvider(packOutput, "en_us"));
71+
gen.addProvider(true, new PackMetadataGenerator(packOutput).add(PackMetadataSection.TYPE, new PackMetadataSection(
72+
Component.literal("Resources for Iron Chests"),
73+
DetectedVersion.BUILT_IN.getPackVersion(PackType.SERVER_DATA),
74+
Optional.of(new InclusiveRange<>(0, Integer.MAX_VALUE)))));
6675
}
6776

6877
public void setupPackets(RegisterPayloadHandlersEvent event) {

src/main/java/com/progwml6/ironchest/client/model/IronChestsModels.java

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,59 @@
22

33
import com.progwml6.ironchest.IronChests;
44
import com.progwml6.ironchest.common.block.IronChestsTypes;
5+
import net.minecraft.client.renderer.Sheets;
6+
import net.minecraft.client.resources.model.Material;
57
import net.minecraft.resources.ResourceLocation;
68
import org.jetbrains.annotations.NotNull;
79

810
public class IronChestsModels {
911

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) {
2931
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);
3133
} 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);
3335
}
3436
}
3537

3638
@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) {
3840
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;
4749
};
4850
}
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+
}
4960
}

src/main/java/com/progwml6/ironchest/client/render/IronChestRenderer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import net.minecraft.client.Minecraft;
1616
import net.minecraft.client.renderer.MultiBufferSource;
1717
import net.minecraft.client.renderer.RenderType;
18-
import net.minecraft.client.renderer.Sheets;
1918
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
2019
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
2120
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@@ -93,7 +92,7 @@ public void render(T blockEntity, float partialTick, PoseStack poseStack, MultiB
9392

9493
boolean trapped = blockEntity instanceof AbstractTrappedIronChestBlockEntity;
9594

96-
Material material = new Material(Sheets.CHEST_SHEET, IronChestsModels.chooseChestTexture(chestType, trapped));
95+
Material material = IronChestsModels.chooseChestMaterial(chestType, trapped);
9796
VertexConsumer vertexConsumer = material.buffer(bufferSource, RenderType::entityCutout);
9897
this.render(poseStack, vertexConsumer, this.model, openness, packedLight, packedOverlay);
9998

src/main/java/com/progwml6/ironchest/common/block/IronChestsBlocks.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ public class IronChestsBlocks {
5353
public static final DeferredBlock<TrappedDirtChestBlock> TRAPPED_DIRT_CHEST = registerWithItem("trapped_dirt_chest", TrappedDirtChestBlock::new, () -> properties, IronChestsTypes.DIRT, true);
5454

5555
public static <T extends Block> DeferredBlock<T> registerWithItem(String name, Function<BlockBehaviour.Properties, T> block, Supplier<BlockBehaviour.Properties> properties, IronChestsTypes chestType, Boolean trapped) {
56-
DeferredBlock<T> ret = BLOCKS.register(name, () -> block.apply(properties.get().setId(ResourceKey.create(Registries.BLOCK, IronChests.prefix(name)))));
57-
IronChestsItems.register(name, itemProps -> new IronChestBlockItem(ret.get(), itemProps, chestType, trapped), Item.Properties::new);
56+
ResourceKey<Block> blockResourceKey = ResourceKey.create(Registries.BLOCK, IronChests.prefix(name));
57+
DeferredBlock<T> ret = BLOCKS.register(name, () -> block.apply(properties.get().setId(blockResourceKey)));
58+
IronChestsItems.register(name, itemProps -> new IronChestBlockItem(ret.get(), itemProps, chestType, trapped), Item.Properties::new, blockResourceKey);
5859
return ret;
5960
}
6061
}

src/main/java/com/progwml6/ironchest/common/data/IronChestsSpriteSourceProvider.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.progwml6.ironchest.common.data;
22

33
import com.progwml6.ironchest.IronChests;
4-
import net.minecraft.client.renderer.texture.atlas.sources.DirectoryLister;
4+
import com.progwml6.ironchest.client.model.IronChestsModels;
5+
import com.progwml6.ironchest.common.block.IronChestsTypes;
6+
import net.minecraft.client.renderer.texture.atlas.sources.SingleFile;
57
import net.minecraft.core.HolderLookup.Provider;
68
import net.minecraft.data.PackOutput;
79
import net.neoforged.neoforge.common.data.ExistingFileHelper;
810
import net.neoforged.neoforge.common.data.SpriteSourceProvider;
911

12+
import java.util.Optional;
1013
import java.util.concurrent.CompletableFuture;
1114

1215
public class IronChestsSpriteSourceProvider extends SpriteSourceProvider {
@@ -17,6 +20,12 @@ public IronChestsSpriteSourceProvider(PackOutput output, ExistingFileHelper file
1720

1821
@Override
1922
protected void gather() {
20-
atlas(CHESTS_ATLAS).addSource(new DirectoryLister("model", "model/"));
23+
for (IronChestsTypes type : IronChestsTypes.values()) {
24+
if (type == IronChestsTypes.WOOD) {
25+
continue;
26+
}
27+
atlas(CHESTS_ATLAS).addSource(new SingleFile(IronChestsModels.chooseChestMaterial(type, false).texture(), Optional.empty()));
28+
atlas(CHESTS_ATLAS).addSource(new SingleFile(IronChestsModels.chooseChestMaterial(type, true).texture(), Optional.empty()));
29+
}
2130
}
2231
}

0 commit comments

Comments
 (0)