Skip to content

Commit

Permalink
Merge pull request #39 from maximumpower55/mixes
Browse files Browse the repository at this point in the history
Registry Clash Fix
  • Loading branch information
falkreon authored Jul 16, 2023
2 parents ed52993 + 56d4943 commit d4d0510
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class VanillaIntegration implements ArchExIntegration {
private static final BlockGroup BAMBOO_ROD = BlockGroup.of(new BlockGroup.GroupedBlock("bamboo", Blocks.BAMBOO, (type, textureId) -> "minecraft:block/bamboo_stalk", RecipeConfigurator.simple("bamboo_rod"), MapColor.PLANT));
private static final BlockGroup COPPER_ROD = BlockGroup.of(new BlockGroup.GroupedBlock("copper", Blocks.LIGHTNING_ROD, (type, textureId) -> "architecture_extensions:block/copper_rod", RecipeConfigurator.simple("copper_rod"), MapColor.ORANGE));
private static final BlockGroup IRON_ROD = BlockGroup.of(new BlockGroup.GroupedBlock("iron", Blocks.IRON_BARS, (type, textureId) -> "minecraft:block/iron_bars", RecipeConfigurator.simple("iron_rod")));
private static final BlockGroup IRON_H_BEAM = BlockGroup.of(new BlockGroup.GroupedBlock("iron", Blocks.ANVIL, (type, textureId) -> "architecture_extensions:block/iron_tube_metal", RecipeConfigurator.simple("iron_h_beam"), MapColor.METAL));
private static final BlockGroup IRON_H_BEAM = BlockGroup.of(new BlockGroup.GroupedBlock("iron", Blocks.ANVIL, (type, textureId) -> "architecture_extensions:block/iron_tube_metal", RecipeConfigurator.CRAFTING, MapColor.METAL));


private static final BlockGroup TUBE_METAL = BlockGroup.of(
Expand All @@ -23,13 +23,13 @@ public class VanillaIntegration implements ArchExIntegration {
case "texture_up" -> "architecture_extensions:block/iron_tube_metal_top";
default -> "architecture_extensions:block/iron_tube_metal";
};
}, RecipeConfigurator.simple("iron_tube_metal"), MapColor.METAL),
}, RecipeConfigurator.CRAFTING, MapColor.METAL),
new BlockGroup.GroupedBlock("copper", Blocks.ANVIL, (type, textureId) -> {
return switch (textureId) {
case "texture_up" -> "architecture_extensions:block/copper_tube_metal_top";
default -> "architecture_extensions:block/copper_tube_metal";
};
}, RecipeConfigurator.simple("copper_tube_metal"), MapColor.METAL)
}, RecipeConfigurator.CRAFTING, MapColor.METAL)
);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public String toString() {

public TypedGroupedBlock register(BlockGroup group, BlockGroup.GroupedBlock groupedBlock, BlockCreationCallback callback, String modId) {
// Note: the mod id parameter isn't used here by purpose, that parameter is there so we can easily debug where registration is coming from.
Identifier id = new Identifier(ArchitectureExtensions.MOD_CONTAINER.metadata().id(), groupedBlock.id().getPath() + "_" + this);
Identifier id = new Identifier(ArchitectureExtensions.MOD_CONTAINER.metadata().id(), String.format("%s/%s", groupedBlock.id().getNamespace(), groupedBlock.id().getPath() + "_" + this));
var baseBlock = groupedBlock.baseBlock().get();

var blockSettings = QuiltBlockSettings.copyOf(baseBlock).strength(strength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ static RecipeConfigurator simple(String id) {
templateConsumer.accept(new RecipeTemplate("wall_to_post", false));
templateConsumer.accept(new RecipeTemplate("post_to_wall", false));
break;
case H_BEAM:
templateConsumer.accept(new RecipeTemplate("h_beam", false));
break;
case I_BEAM:
templateConsumer.accept(new RecipeTemplate("i_beam", false));
break;
case TUBE_METAL:
templateConsumer.accept(new RecipeTemplate("tube_metal", false));
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@

import java.util.Map;

import com.mojang.datafixers.util.Pair;

import io.github.debuggyteam.architecture_extensions.api.BlockType;
import net.minecraft.util.Identifier;

public final class LanguageGeneration {
private static String getLangKey(Identifier id) {
return "block." + id.getNamespace() + "." + id.getPath();
return "block." + id.getNamespace() + "." + id.getPath().replace("/", ".");
}

public static void generate(Map<String, String> langEntries) {
for (BlockType.TypedGroupedBlock block : DataGeneration.BLOCKS) {
final var groupedBlockComponent = Component.GROUPED_BLOCK.translate(langEntries, block.groupedBlock().id().getPath());
var groupedBlockComponent = Component.GROUPED_BLOCK.translate(langEntries, block.groupedBlock().id().toTranslationKey());
if (groupedBlockComponent.getSecond()) groupedBlockComponent = Component.GROUPED_BLOCK.translate(langEntries, block.groupedBlock().id().getPath());
final var blockTypeComponent = Component.BLOCK_TYPE.translate(langEntries, block.type().toString());

langEntries.put(getLangKey(block.id()), String.format(langEntries.get("architecture_extensions.block_type_block"), groupedBlockComponent, blockTypeComponent));
langEntries.put(getLangKey(block.id()), String.format(langEntries.get("architecture_extensions.block_type_block"), groupedBlockComponent.getFirst(), blockTypeComponent.getFirst()));
}
}

Expand All @@ -29,8 +32,11 @@ private static enum Component {
this.key = key;
}

public String translate(Map<String, String> langEntries, String id) {
return langEntries.get(key + "." + id);
public Pair<String, Boolean> translate(Map<String, String> langEntries, String id) {
final var entryId = key + "." + id;
final var entry = langEntries.get(entryId);
if (entry != null) return Pair.of(entry, false);
return Pair.of(entryId, true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
],
"key": {
"#": {
"item": "minecraft:bamboo"
"item": "{group}"
}
},
"result": {
"item": "architecture_extensions:bamboo_rod",
"item": "{result}",
"count": 6
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
],
"key": {
"c": {
"item": "minecraft:copper_ingot"
"item": "{group}_ingot"
}
},
"result": {
"item": "architecture_extensions:copper_rod",
"item": "{result}",
"count": 8
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
],
"key": {
"i": {
"item": "minecraft:iron_ingot"
"item": "{group}_ingot"
},
"I": {
"item": "minecraft:iron_block"
"item": "{group}_block"
}
},
"result": {
"item": "architecture_extensions:iron_h_beam"
"item": "{result}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
],
"key": {
"i": {
"item": "minecraft:iron_ingot"
"item": "{group}_ingot"
}
},
"result": {
"item": "architecture_extensions:iron_h_beam"
"item": "{result}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
],
"key": {
"i": {
"item": "minecraft:iron_ingot"
"item": "{group}_ingot"
}
},
"result": {
"item": "architecture_extensions:iron_rod",
"item": "{result}",
"count": 8
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
],
"key": {
"i": {
"item": "minecraft:iron_ingot"
"item": "{group}_ingot"
}
},
"result": {
"item": "architecture_extensions:iron_tube_metal",
"item": "{result}",
"count": 1
}
}

0 comments on commit d4d0510

Please sign in to comment.