Skip to content

Commit

Permalink
generate compat code
Browse files Browse the repository at this point in the history
  • Loading branch information
lumiscosity committed Jul 18, 2024
1 parent c33edb0 commit c0805c4
Show file tree
Hide file tree
Showing 12 changed files with 500 additions and 71 deletions.
61 changes: 52 additions & 9 deletions generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ def add_treated_plank(m, n):

# item tag
file = JsonFile(source_path="src/main/resources/data/rounded/tags/item/treated_planks.json").data
print(file)
file["values"].append(
{
"required": False,
"id": f"rounded:compat/{m}/{t}"
}
)
JsonFile(file).dump(origin="./", path="src/main/resources/data/rounded/tags/item/treated_planks.json")
tag = {
"required": False,
"id": f"rounded:compat/{m}/{t}"
}

if tag not in file["values"]:
file["values"].append(tag)
JsonFile(file).dump(origin="./", path="src/main/resources/data/rounded/tags/item/treated_planks.json")

# blockstate
file = {
Expand Down Expand Up @@ -200,6 +200,49 @@ def add_treated_plank(m, n):
JsonFile(file).dump(origin="./", path="src/client/resources/assets/rounded/lang/en_us.json")


def add_treated_plank_code(m, l):
module_name = m.replace("_", " ").title().replace(" ", "") + "Compat"
file = """package com.lumiscosity.rounded.compat;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import static com.lumiscosity.rounded.blocks.RegisterBlocks.register_treated_plank;
public class {} {{""".format(module_name)

for i in l:
p = f"{i}_planks"
t = f"treated_{p}"

file += f"""
public static final Block {t.upper()} = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("{m}", "{p}")))
);
public static final Item {t.upper()}_ITEM = new BlockItem({t.upper()}, new Item.Settings());
"""

file += " public static void register() {"

for i in l:
t = f"treated_{i}_planks"

file += f' register_treated_plank("compat/{m}/{t}", {t.upper()}, {t.upper()}_ITEM, "{m}", "{i}");\n'

file += """
}
}"""

module = open(f"src/main/java/com/lumiscosity/rounded/compat/{module_name}.java", "w")
module.write(file)
module.close()

for i in compat_generated.keys():
add_treated_plank_code(i, compat_generated[i])
for j in compat_generated[i]:
add_treated_plank(i, j)
add_treated_plank(i, j)
3 changes: 0 additions & 3 deletions src/client/resources/assets/rounded/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@
"block.rounded.lustershroom_block": "Lustershroom Block",
"block.rounded.luster_cluster": "Luster Cluster",
"block.rounded.trough": "Trough",

"subtitles.rounded.block.trough_fill": "Trough filled",
"subtitles.rounded.block.trough_consume": "Trough consumed",
"subtitles.rounded.block.trough_rustle": "Feed rustles",

"tag.worldgen.biome.rounded.has_lustershrooms": "Has Lustershrooms",
"tag.worldgen.biome.rounded.has_more_lustershrooms": "Has more Lustershrooms",
"tag.item.rounded.trough_feed": "Trough Feed",
"tag.item.rounded.treated_planks": "Treated Planks",
"tag.item.c.grain": "Grain",
"tag.item.c.mushrooms": "Mushrooms",
"tag.item.c.mushroom_caps": "Mushroom Caps",

"block.rounded.compat.treated_hevea_brasiliensis_planks": "Treated Hevea Brasiliensis Planks",
"block.rounded.compat.betterend.treated_dragon_tree_planks": "Treated Dragon Tree Planks",
"block.rounded.compat.betterend.treated_end_lotus_planks": "Treated End Lotus Planks",
Expand Down
24 changes: 21 additions & 3 deletions src/main/java/com/lumiscosity/rounded/Rounded.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.lumiscosity.rounded;

import com.lumiscosity.rounded.blocks.RegisterBlocks;
import com.lumiscosity.rounded.compat.ExtravaganzaCompat;
import com.lumiscosity.rounded.compat.WilderWildCompat;
import com.lumiscosity.rounded.compat.*;
import com.lumiscosity.rounded.misc.RegisterSounds;
import com.lumiscosity.rounded.misc.RegisterTrades;
import net.fabricmc.api.ModInitializer;
Expand All @@ -24,8 +23,27 @@ public void onInitialize() {
if (FabricLoader.getInstance().isModLoaded("extravaganza")) {
ExtravaganzaCompat.register();
}

if (FabricLoader.getInstance().isModLoaded("betterend")) {
BetterendCompat.register();
}
if (FabricLoader.getInstance().isModLoaded("betternether")) {
BetternetherCompat.register();
}
if (FabricLoader.getInstance().isModLoaded("biomesoplenty")) {
BiomesoplentyCompat.register();
}
if (FabricLoader.getInstance().isModLoaded("cinderscapes")) {
CinderscapesCompat.register();
}
if (FabricLoader.getInstance().isModLoaded("terrestria")) {
TerrestriaCompat.register();
}
if (FabricLoader.getInstance().isModLoaded("traverse")) {
TraverseCompat.register();
}
if (FabricLoader.getInstance().isModLoaded("wilderwild")) {
WilderWildCompat.register();
WilderwildCompat.register();
}

LOGGER.info("Rounded init complete!");
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/com/lumiscosity/rounded/compat/BetterEndCompat.java

This file was deleted.

84 changes: 84 additions & 0 deletions src/main/java/com/lumiscosity/rounded/compat/BetterendCompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.lumiscosity.rounded.compat;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;

import static com.lumiscosity.rounded.blocks.RegisterBlocks.register_treated_plank;

public class BetterendCompat {
public static final Block TREATED_DRAGON_TREE_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "dragon_tree_planks")))
);
public static final Item TREATED_DRAGON_TREE_PLANKS_ITEM = new BlockItem(TREATED_DRAGON_TREE_PLANKS, new Item.Settings());


public static final Block TREATED_END_LOTUS_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "end_lotus_planks")))
);
public static final Item TREATED_END_LOTUS_PLANKS_ITEM = new BlockItem(TREATED_END_LOTUS_PLANKS, new Item.Settings());


public static final Block TREATED_HELIX_TREE_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "helix_tree_planks")))
);
public static final Item TREATED_HELIX_TREE_PLANKS_ITEM = new BlockItem(TREATED_HELIX_TREE_PLANKS, new Item.Settings());


public static final Block TREATED_JELLYSHROOM_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "jellyshroom_planks")))
);
public static final Item TREATED_JELLYSHROOM_PLANKS_ITEM = new BlockItem(TREATED_JELLYSHROOM_PLANKS, new Item.Settings());


public static final Block TREATED_LACUGROVE_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "lacugrove_planks")))
);
public static final Item TREATED_LACUGROVE_PLANKS_ITEM = new BlockItem(TREATED_LACUGROVE_PLANKS, new Item.Settings());


public static final Block TREATED_LUCERNIA_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "lucernia_planks")))
);
public static final Item TREATED_LUCERNIA_PLANKS_ITEM = new BlockItem(TREATED_LUCERNIA_PLANKS, new Item.Settings());


public static final Block TREATED_MOSSY_GLOWSHROOM_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "mossy_glowshroom_planks")))
);
public static final Item TREATED_MOSSY_GLOWSHROOM_PLANKS_ITEM = new BlockItem(TREATED_MOSSY_GLOWSHROOM_PLANKS, new Item.Settings());


public static final Block TREATED_PYTHADENDRON_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "pythadendron_planks")))
);
public static final Item TREATED_PYTHADENDRON_PLANKS_ITEM = new BlockItem(TREATED_PYTHADENDRON_PLANKS, new Item.Settings());


public static final Block TREATED_TENANEA_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "tenanea_planks")))
);
public static final Item TREATED_TENANEA_PLANKS_ITEM = new BlockItem(TREATED_TENANEA_PLANKS, new Item.Settings());


public static final Block TREATED_UMBRELLA_TREE_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betterend", "umbrella_tree_planks")))
);
public static final Item TREATED_UMBRELLA_TREE_PLANKS_ITEM = new BlockItem(TREATED_UMBRELLA_TREE_PLANKS, new Item.Settings());

public static void register() { register_treated_plank("compat/betterend/treated_dragon_tree_planks", TREATED_DRAGON_TREE_PLANKS, TREATED_DRAGON_TREE_PLANKS_ITEM, "betterend", "dragon_tree");
register_treated_plank("compat/betterend/treated_end_lotus_planks", TREATED_END_LOTUS_PLANKS, TREATED_END_LOTUS_PLANKS_ITEM, "betterend", "end_lotus");
register_treated_plank("compat/betterend/treated_helix_tree_planks", TREATED_HELIX_TREE_PLANKS, TREATED_HELIX_TREE_PLANKS_ITEM, "betterend", "helix_tree");
register_treated_plank("compat/betterend/treated_jellyshroom_planks", TREATED_JELLYSHROOM_PLANKS, TREATED_JELLYSHROOM_PLANKS_ITEM, "betterend", "jellyshroom");
register_treated_plank("compat/betterend/treated_lacugrove_planks", TREATED_LACUGROVE_PLANKS, TREATED_LACUGROVE_PLANKS_ITEM, "betterend", "lacugrove");
register_treated_plank("compat/betterend/treated_lucernia_planks", TREATED_LUCERNIA_PLANKS, TREATED_LUCERNIA_PLANKS_ITEM, "betterend", "lucernia");
register_treated_plank("compat/betterend/treated_mossy_glowshroom_planks", TREATED_MOSSY_GLOWSHROOM_PLANKS, TREATED_MOSSY_GLOWSHROOM_PLANKS_ITEM, "betterend", "mossy_glowshroom");
register_treated_plank("compat/betterend/treated_pythadendron_planks", TREATED_PYTHADENDRON_PLANKS, TREATED_PYTHADENDRON_PLANKS_ITEM, "betterend", "pythadendron");
register_treated_plank("compat/betterend/treated_tenanea_planks", TREATED_TENANEA_PLANKS, TREATED_TENANEA_PLANKS_ITEM, "betterend", "tenanea");
register_treated_plank("compat/betterend/treated_umbrella_tree_planks", TREATED_UMBRELLA_TREE_PLANKS, TREATED_UMBRELLA_TREE_PLANKS_ITEM, "betterend", "umbrella_tree");

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.lumiscosity.rounded.compat;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;

import static com.lumiscosity.rounded.blocks.RegisterBlocks.register_treated_plank;

public class BetternetherCompat {
public static final Block TREATED_ANCHOR_TREE_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "anchor_tree_planks")))
);
public static final Item TREATED_ANCHOR_TREE_PLANKS_ITEM = new BlockItem(TREATED_ANCHOR_TREE_PLANKS, new Item.Settings());


public static final Block TREATED_MUSHROOM_FIR_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "mushroom_fir_planks")))
);
public static final Item TREATED_MUSHROOM_FIR_PLANKS_ITEM = new BlockItem(TREATED_MUSHROOM_FIR_PLANKS, new Item.Settings());


public static final Block TREATED_NETHER_MUSHROOM_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "nether_mushroom_planks")))
);
public static final Item TREATED_NETHER_MUSHROOM_PLANKS_ITEM = new BlockItem(TREATED_NETHER_MUSHROOM_PLANKS, new Item.Settings());


public static final Block TREATED_NETHER_REED_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "nether_reed_planks")))
);
public static final Item TREATED_NETHER_REED_PLANKS_ITEM = new BlockItem(TREATED_NETHER_REED_PLANKS, new Item.Settings());


public static final Block TREATED_NETHER_SAKURA_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "nether_sakura_planks")))
);
public static final Item TREATED_NETHER_SAKURA_PLANKS_ITEM = new BlockItem(TREATED_NETHER_SAKURA_PLANKS, new Item.Settings());


public static final Block TREATED_RUBEUS_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "rubeus_planks")))
);
public static final Item TREATED_RUBEUS_PLANKS_ITEM = new BlockItem(TREATED_RUBEUS_PLANKS, new Item.Settings());


public static final Block TREATED_STALAGNATE_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "stalagnate_planks")))
);
public static final Item TREATED_STALAGNATE_PLANKS_ITEM = new BlockItem(TREATED_STALAGNATE_PLANKS, new Item.Settings());


public static final Block TREATED_WART_PLANKS_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "wart_planks_planks")))
);
public static final Item TREATED_WART_PLANKS_PLANKS_ITEM = new BlockItem(TREATED_WART_PLANKS_PLANKS, new Item.Settings());


public static final Block TREATED_WILLOW_PLANKS_PLANKS = new Block(
AbstractBlock.Settings.copy(Registries.BLOCK.get(Identifier.of("betternether", "willow_planks_planks")))
);
public static final Item TREATED_WILLOW_PLANKS_PLANKS_ITEM = new BlockItem(TREATED_WILLOW_PLANKS_PLANKS, new Item.Settings());

public static void register() { register_treated_plank("compat/betternether/treated_anchor_tree_planks", TREATED_ANCHOR_TREE_PLANKS, TREATED_ANCHOR_TREE_PLANKS_ITEM, "betternether", "anchor_tree");
register_treated_plank("compat/betternether/treated_mushroom_fir_planks", TREATED_MUSHROOM_FIR_PLANKS, TREATED_MUSHROOM_FIR_PLANKS_ITEM, "betternether", "mushroom_fir");
register_treated_plank("compat/betternether/treated_nether_mushroom_planks", TREATED_NETHER_MUSHROOM_PLANKS, TREATED_NETHER_MUSHROOM_PLANKS_ITEM, "betternether", "nether_mushroom");
register_treated_plank("compat/betternether/treated_nether_reed_planks", TREATED_NETHER_REED_PLANKS, TREATED_NETHER_REED_PLANKS_ITEM, "betternether", "nether_reed");
register_treated_plank("compat/betternether/treated_nether_sakura_planks", TREATED_NETHER_SAKURA_PLANKS, TREATED_NETHER_SAKURA_PLANKS_ITEM, "betternether", "nether_sakura");
register_treated_plank("compat/betternether/treated_rubeus_planks", TREATED_RUBEUS_PLANKS, TREATED_RUBEUS_PLANKS_ITEM, "betternether", "rubeus");
register_treated_plank("compat/betternether/treated_stalagnate_planks", TREATED_STALAGNATE_PLANKS, TREATED_STALAGNATE_PLANKS_ITEM, "betternether", "stalagnate");
register_treated_plank("compat/betternether/treated_wart_planks_planks", TREATED_WART_PLANKS_PLANKS, TREATED_WART_PLANKS_PLANKS_ITEM, "betternether", "wart_planks");
register_treated_plank("compat/betternether/treated_willow_planks_planks", TREATED_WILLOW_PLANKS_PLANKS, TREATED_WILLOW_PLANKS_PLANKS_ITEM, "betternether", "willow_planks");

}
}
Loading

0 comments on commit c0805c4

Please sign in to comment.