Skip to content

Commit

Permalink
Added Tags to items to Close Issue #13 and added Fluid-Tag-Based Reci…
Browse files Browse the repository at this point in the history
…pe Gen Extensibility to Close Issue #7

Signed-off-by: Type-32 <[email protected]>
  • Loading branch information
Type-32 committed Jun 29, 2024
1 parent b6bc12e commit c9ca7aa
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 32 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod_name=Precise Manufacturing
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=0.2.5-alpha
mod_version=0.2.6-alpha

is_nightly=true
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class ModFluids {
public static final FluidEntry<? extends VirtualFluid>
MOLTEN_COPPER = Main.REGISTRATE.extendedVirtualFluid("molten_copper", MoltenCopperFluid::new)
.lang("Molten Copper")
.tag(ModTags.forgeFluidTag("molten_metals"))
.tag(ModTags.forgeFluidTag("molten_metals"), ModTags.moltenCoppersTag())
.register(),
MOLTEN_BRASS = Main.REGISTRATE.extendedVirtualFluid("molten_brass", MoltenBrassFluid::new)
.lang("Molten Brass")
.tag(ModTags.forgeFluidTag("molten_metals"))
.tag(ModTags.forgeFluidTag("molten_metals"), ModTags.moltenBrassesTag())
.register(),
MOLTEN_BASALT_INFUSED_IRON = Main.REGISTRATE.extendedVirtualFluid("molten_basalt_infused_iron", MoltenBasaltInfusedIronFluid::new)
.lang("Molten Basalt-Infused Iron")
.tag(ModTags.forgeFluidTag("molten_metals"))
.tag(ModTags.forgeFluidTag("molten_metals"), ModTags.moltenIronsTag())
.register();

public static void register(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ public static RegistryEntry<Item> addToList(RegistryEntry<Item> entry, ModCreati

// Powders
public static final RegistryEntry<Item>
RAW_ZINC_POWDER = addToList(Main.REGISTRATE.item("raw_zinc_powder", Item::new).register()),
RAW_COPPER_POWDER = addToList(Main.REGISTRATE.item("raw_copper_powder", Item::new).register()),
BASALT_POWDER = addToList(Main.REGISTRATE.item("basalt_powder",Item::new).register()),
RAW_SULFUR_POWDER = addToList(Main.REGISTRATE.item("raw_sulfur_powder",Item::new).register()),
GUNPOWDER_PELLETS = addToList(Main.REGISTRATE.item("gunpowder_pellets",Item::new).register());
RAW_ZINC_POWDER = addToList(Main.REGISTRATE.item("raw_zinc_powder", Item::new).tag(ModTags.materialsTag()).register()),
RAW_COPPER_POWDER = addToList(Main.REGISTRATE.item("raw_copper_powder", Item::new).tag(ModTags.materialsTag()).register()),
BASALT_POWDER = addToList(Main.REGISTRATE.item("basalt_powder",Item::new).tag(ModTags.materialsTag()).register()),
RAW_SULFUR_POWDER = addToList(Main.REGISTRATE.item("raw_sulfur_powder",Item::new).tag(ModTags.materialsTag()).register()),
GUNPOWDER_PELLETS = addToList(Main.REGISTRATE.item("gunpowder_pellets",Item::new).tag(ModTags.materialsTag()).register());

// Misc Items
public static final RegistryEntry<Item>
CRUSHED_BASALT = addToList(Main.REGISTRATE.item("crushed_basalt", Item::new).register()),
UNFORMED_BASALT = addToList(Main.REGISTRATE.item("unformed_basalt", Item::new).register()),
STRAIGHT_SMALL_COIL = addToList(Main.REGISTRATE.item("straight_small_coil", Item::new).register()),
STRAIGHT_LARGE_COIL = addToList(Main.REGISTRATE.item("straight_large_coil", Item::new).register()),
STRAIGHT_FLAT_COIL = addToList(Main.REGISTRATE.item("straight_flat_coil", Item::new).register()),
LOCKING_RETURN_COIL = addToList(Main.REGISTRATE.item("locking_return_coil", Item::new).register()),
FLAT_HEAD_SCREW = addToList(Main.REGISTRATE.item("flat_head_screw", Item::new).register()),
M_SCREW = addToList(Main.REGISTRATE.item("m_screw", Item::new).register()),
THIN_SMALL_ROD = addToList(Main.REGISTRATE.item("thin_small_rod", Item::new).register()),
THICK_SMALL_ROD = addToList(Main.REGISTRATE.item("thick_small_rod", Item::new).register()),
STRAIGHT_SMALL_COIL = addToList(Main.REGISTRATE.item("straight_small_coil", Item::new).tag(ModTags.componentsTag()).register()),
STRAIGHT_LARGE_COIL = addToList(Main.REGISTRATE.item("straight_large_coil", Item::new).tag(ModTags.componentsTag()).register()),
STRAIGHT_FLAT_COIL = addToList(Main.REGISTRATE.item("straight_flat_coil", Item::new).tag(ModTags.componentsTag()).register()),
LOCKING_RETURN_COIL = addToList(Main.REGISTRATE.item("locking_return_coil", Item::new).tag(ModTags.componentsTag()).register()),
FLAT_HEAD_SCREW = addToList(Main.REGISTRATE.item("flat_head_screw", Item::new).tag(ModTags.componentsTag()).register()),
M_SCREW = addToList(Main.REGISTRATE.item("m_screw", Item::new).tag(ModTags.componentsTag()).register()),
THIN_SMALL_ROD = addToList(Main.REGISTRATE.item("thin_small_rod", Item::new).tag(ModTags.componentsTag()).register()),
THICK_SMALL_ROD = addToList(Main.REGISTRATE.item("thick_small_rod", Item::new).tag(ModTags.componentsTag()).register()),
BLANK_BLUEPRINT = addToList(Main.REGISTRATE.item("blank_blueprint", Item::new).register()),
BLANK_CAST = addToList(Main.REGISTRATE.item("blank_cast", Item::new).register());

Expand Down Expand Up @@ -125,19 +125,19 @@ public static RegistryEntry<Item> addToList(RegistryEntry<Item> entry, ModCreati
.replaceAssemblySequence(CartridgeAssemblySequence.GUNPOWDER, CartridgeAssemblySequence.GUNPOWDER_PELLET)
.insertAssemblySequence(1, CartridgeAssemblySequence.GUNPOWDER_PELLET)
.insertAssemblySequence(1, CartridgeAssemblySequence.GUNPOWDER_PELLET))
.setModuleData(0, d -> d.setFillingAmount(110).setFillingFluid(ModFluids.MOLTEN_BASALT_INFUSED_IRON))
.setModuleData(0, d -> d.setFillingAmount(110).setFillingFluid(ModTags.moltenIronsTag()))
.setModuleData(1, d -> d.setFillingAmount(90)),

FIVE_EIGHT_X_FOUR_TWO = new CartridgeBase("58x42", CartridgeBase.STANDARD_CARTRIDGE
.replaceAssemblySequence(CartridgeAssemblySequence.GUNPOWDER, CartridgeAssemblySequence.GUNPOWDER_PELLET)
.insertAssemblySequence(1, CartridgeAssemblySequence.GUNPOWDER_PELLET))
.setModuleData(0, d -> d.setFillingAmount(100).setFillingFluid(ModFluids.MOLTEN_BASALT_INFUSED_IRON))
.setModuleData(0, d -> d.setFillingAmount(100).setFillingFluid(ModTags.moltenIronsTag()))
.setModuleData(1, d -> d.setFillingAmount(70)),

SIX_EIGHT_X_FIVE_ONE_FURY = new CartridgeBase("68x51fury", CartridgeBase.STANDARD_CARTRIDGE
.replaceAssemblySequence(CartridgeAssemblySequence.GUNPOWDER, CartridgeAssemblySequence.GUNPOWDER_PELLET)
.insertAssemblySequence(1, CartridgeAssemblySequence.GUNPOWDER_PELLET))
.setModuleData(0, d -> d.setFillingAmount(90).setFillingFluid(ModFluids.MOLTEN_BASALT_INFUSED_IRON))
.setModuleData(0, d -> d.setFillingAmount(90).setFillingFluid(ModTags.moltenIronsTag()))
.setModuleData(1, d -> d.setFillingAmount(80)),

RPG_ROCKET = new CartridgeBase("rpg_rocket", CartridgeBase.ROCKET_CARTRIDGE),
Expand Down Expand Up @@ -171,7 +171,7 @@ public static RegistryEntry<Item> addToList(RegistryEntry<Item> entry, ModCreati
SEVEN_SIX_TWO_X_THREE_NINE = new CartridgeBase("762x39", CartridgeBase.STANDARD_CARTRIDGE
.replaceAssemblySequence(CartridgeAssemblySequence.GUNPOWDER, CartridgeAssemblySequence.GUNPOWDER_PELLET)
.insertAssemblySequence(1, CartridgeAssemblySequence.GUNPOWDER_PELLET))
.setModuleData(0, d -> d.setFillingAmount(100).setFillingFluid(ModFluids.MOLTEN_BASALT_INFUSED_IRON))
.setModuleData(0, d -> d.setFillingAmount(100).setFillingFluid(ModTags.moltenIronsTag()))
.setModuleData(1, d -> d.setFillingAmount(60)),

SEVEN_SIX_TWO_X_FIVE_FOUR = new CartridgeBase("762x54", CartridgeBase.STANDARD_CARTRIDGE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.crtlprototypestudios.precisemanufacturing.foundation;

import cn.crtlprototypestudios.precisemanufacturing.util.Reference;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
Expand All @@ -21,6 +22,10 @@ public static <T> TagKey<T> forgeTag(IForgeRegistry<T> registry, String path) {
return optionalTag(registry, new ResourceLocation("forge", path));
}

public static <T> TagKey<T> modTag(IForgeRegistry<T> registry, String path) {
return optionalTag(registry, new ResourceLocation(Reference.MOD_ID, path));
}

public static TagKey<Block> forgeBlockTag(String path) {
return forgeTag(ForgeRegistries.BLOCKS, path);
}
Expand All @@ -33,7 +38,63 @@ public static TagKey<Fluid> forgeFluidTag(String path) {
return forgeTag(ForgeRegistries.FLUIDS, path);
}

public static TagKey<Item> modItemTag(String path) {
return modTag(ForgeRegistries.ITEMS, path);
}

public static TagKey<Fluid> modFluidTag(String path){
return modTag(ForgeRegistries.FLUIDS, path);
}

public static void register(){
// Do not delete; for loading the class
}

public static TagKey<Item> weaponBlueprintTag(){
return modItemTag("weapon_blueprints");
}

public static TagKey<Item> ammoBlueprintTag(){
return modItemTag("ammo_blueprints");
}

public static TagKey<Item> weaponCastTag(){
return modItemTag("weapon_casts");
}

public static TagKey<Item> ammoCastTag(){
return modItemTag("ammo_casts");
}

public static TagKey<Item> weaponComponentTag(){
return modItemTag("weapon_components");
}

public static TagKey<Item> ammoHeadTag(){
return modItemTag("ammo_head_components");
}

public static TagKey<Item> ammoCasingTag(){
return modItemTag("ammo_casing_components");
}

public static TagKey<Item> componentsTag(){
return modItemTag("components");
}

public static TagKey<Item> materialsTag(){
return modItemTag("materials");
}

public static TagKey<Fluid> moltenIronsTag(){
return modFluidTag("molten_iron_fluids");
}

public static TagKey<Fluid> moltenCoppersTag(){
return modFluidTag("molten_copper_fluids");
}

public static TagKey<Fluid> moltenBrassesTag(){
return modFluidTag("molten_brass_fluids");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModCreativeModTabs;
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModFluids;
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModItems;
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModTags;
import cn.crtlprototypestudios.precisemanufacturing.foundation.data.generators.recipe.ModDecomponentalizingRecipesGen;
import cn.crtlprototypestudios.precisemanufacturing.foundation.data.providers.ModItemModelProvider;
import cn.crtlprototypestudios.precisemanufacturing.foundation.data.providers.ModRecipeProvider;
Expand Down Expand Up @@ -77,10 +78,10 @@ public class CartridgeBase extends AmmunitionBase {
ROCKET_CARTRIDGE = new CartridgeModuleBuilder(
new CartridgeModule[]{
CartridgeModule.CASING_MODULE.setData(d -> d
.setFillingFluid(ModFluids.MOLTEN_BASALT_INFUSED_IRON)
.setFillingFluid(ModTags.moltenIronsTag())
.setFillingAmount(150)),
CartridgeModule.HEAD_MODULE.setData(d -> d
.setFillingFluid(ModFluids.MOLTEN_BASALT_INFUSED_IRON)
.setFillingFluid(ModTags.moltenIronsTag())
.setFillingAmount(100))
},
new CartridgeAssemblySequence[]{
Expand Down Expand Up @@ -178,12 +179,15 @@ private RegistryEntry<Item> registerModule(String id, CartridgeModule module) {
assert ModCreativeModTabs.MOD_BLUEPRINTS_TAB.getKey() != null;
RegistryEntry<Item>
blueprintModule = Main.REGISTRATE.item(name + "_blueprint", Item::new)
.tag(ModTags.ammoBlueprintTag())
.model(ModItemModelProvider.genericItemModel(true, "cartridges", String.format("general_%s_blueprint", module)))
.register(),
castModule = Main.REGISTRATE.item(name + "_cast", Item::new)
.tag(ModTags.ammoCastTag())
.model(ModItemModelProvider.genericItemModel(true, "cartridges", String.format("general_%s_cast", module)))
.register(),
mainModule = Main.REGISTRATE.item(name, Item::new)
.tag(name.contains("casing") ? ModTags.ammoCasingTag() : ModTags.ammoHeadTag())
.model(ModItemModelProvider.genericItemModel(true, "cartridges", id, name))
.register();

Expand Down Expand Up @@ -231,7 +235,7 @@ public void registerRecipes(){

ModRecipeProvider.addCreateRecipeBuilder(new ProcessingRecipeBuilder<FillingRecipe>(FillingRecipe::new, ResourceHelper.find(String.format("cartridges/%s/%s", getCoreId(), name)))
.require(castModule.get())
.require(m.getData().getFillingFluid().get(), m.getData().getFillingAmount())
.require(m.getData().getFillingFluid(), m.getData().getFillingAmount())
.output(mainModule.get()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package cn.crtlprototypestudios.precisemanufacturing.foundation.item.bases.ammunition;

import cn.crtlprototypestudios.precisemanufacturing.foundation.ModFluids;
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModTags;
import cn.crtlprototypestudios.precisemanufacturing.foundation.item.bases.ModuleBase;
import com.simibubi.create.content.fluids.VirtualFluid;
import com.tterrag.registrate.util.entry.FluidEntry;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.material.Fluid;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -48,9 +51,9 @@ public boolean equals(Object obj) {

public static class Data {
private int fillingAmount;
private @NotNull FluidEntry<? extends VirtualFluid> fillingFluid;
private @NotNull TagKey<Fluid> fillingFluid;

public Data(int fillingAmount, FluidEntry<? extends VirtualFluid> fillingFluid){
public Data(int fillingAmount, TagKey<Fluid> fillingFluid){
this.fillingAmount = fillingAmount;
this.fillingFluid = fillingFluid;
}
Expand All @@ -63,18 +66,18 @@ public Data setFillingAmount(int fillingAmount) {
return new Data(fillingAmount, fillingFluid);
}

public FluidEntry<? extends VirtualFluid> getFillingFluid() {
public TagKey<Fluid> getFillingFluid() {
return fillingFluid;
}

public Data setFillingFluid(FluidEntry<? extends VirtualFluid> fillingFluid) {
public Data setFillingFluid(TagKey<Fluid> fillingFluid) {
return new Data(fillingAmount, fillingFluid);
}
}

public static final CartridgeModule
CASING_MODULE = new CartridgeModule(CartridgeModuleType.CASING, new Data(100, ModFluids.MOLTEN_BRASS)),
HEAD_MODULE = new CartridgeModule(CartridgeModuleType.HEAD, new Data(80, ModFluids.MOLTEN_COPPER)),
PELLET_MODULE = new CartridgeModule(CartridgeModuleType.PELLET, new Data(60, ModFluids.MOLTEN_BASALT_INFUSED_IRON)),
UNFINISHED_MODULE = new CartridgeModule(CartridgeModuleType.UNFINISHED, new Data(0, ModFluids.MOLTEN_BRASS));
CASING_MODULE = new CartridgeModule(CartridgeModuleType.CASING, new Data(100, ModTags.moltenBrassesTag())),
HEAD_MODULE = new CartridgeModule(CartridgeModuleType.HEAD, new Data(80, ModTags.moltenCoppersTag())),
PELLET_MODULE = new CartridgeModule(CartridgeModuleType.PELLET, new Data(60, ModTags.moltenIronsTag())),
UNFINISHED_MODULE = new CartridgeModule(CartridgeModuleType.UNFINISHED, new Data(0, ModTags.moltenBrassesTag()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModCreativeModTabs;
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModFluids;
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModItems;
import cn.crtlprototypestudios.precisemanufacturing.foundation.ModTags;
import cn.crtlprototypestudios.precisemanufacturing.foundation.data.generators.recipe.ModDecomponentalizingRecipesGen;
import cn.crtlprototypestudios.precisemanufacturing.foundation.data.providers.ModItemModelProvider;
import cn.crtlprototypestudios.precisemanufacturing.foundation.data.providers.ModRecipeProvider;
Expand Down Expand Up @@ -170,12 +171,15 @@ private RegistryEntry<Item> registerModule(String id, RifleModule module, Item.P
// Register the module
RegistryEntry<Item>
mainModule = Main.REGISTRATE.item(name, Item::new)
.tag(ModTags.weaponComponentTag())
.model(ModItemModelProvider.genericItemModel(true, "weapons", "general","guns", "modules", "general_" + module))
.register(),
castModule = Main.REGISTRATE.item(name + "_cast", Item::new)
.tag(ModTags.weaponCastTag())
.model(ModItemModelProvider.genericItemModel(true, "weapons", "general", "guns", "casts", "general_" + module + "_cast"))
.register(),
blueprintModule = Main.REGISTRATE.item(name + "_blueprint", Item::new)
.tag(ModTags.weaponBlueprintTag())
.model(ModItemModelProvider.genericItemModel(true, "weapons", "general", "guns", "blueprints", "general_" + module + "_blueprint"))
.register();

Expand Down

0 comments on commit c9ca7aa

Please sign in to comment.