Jump to content

BaseMetals API


KewaiiGamer

Recommended Posts

MetaPaxel.java

package main.java.com.kewaiigamer.multitools.plugin.basemetals;

import java.util.HashSet;
import java.util.Set;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;

import cyano.basemetals.items.ItemMetalPickaxe;
import cyano.basemetals.material.MetalMaterial;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;

public class MetalPaxel extends ItemMetalPickaxe {

public MetalPaxel(MetalMaterial metal) {
	super(metal);
}

	public Set<String> getToolClasses(ItemStack stack) {
		return ImmutableSet.of("pickaxe", "spade");
	}
	private static HashSet<Block> effectiveAgainst = Sets.newHashSet(new Block[] {
		    Blocks.GRASS, Blocks.DIRT, Blocks.SAND, Blocks.GRAVEL, 
		    Blocks.SNOW_LAYER, Blocks.SNOW, Blocks.CLAY, Blocks.FARMLAND, 
		    Blocks.SOUL_SAND, Blocks.MYCELIUM, Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, 
		    Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN});

	@Override
	public boolean canHarvestBlock(IBlockState blockIn) {
			return effectiveAgainst.contains(blockIn) ? true : super.canHarvestBlock(blockIn);
	}

	@Override
	public float getStrVsBlock(ItemStack stack, IBlockState state) {
		 if (state.getMaterial() == Material.WOOD || state.getMaterial() == Material.VINE || state.getMaterial() == Material.PLANTS || state.getMaterial() == Material.GROUND || state.getMaterial() == Material.GRASS || state.getMaterial() == Material.SAND)
		        return this.efficiencyOnProperMaterial;
		 return effectiveAgainst.contains(state) ? this.efficiencyOnProperMaterial : super.getStrVsBlock(stack, state);
	}

}

ModItems.java

package main.java.com.kewaiigamer.multitools.item;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cyano.basemetals.init.Materials;
import cyano.basemetals.material.MetalMaterial;
import main.java.com.kewaiigamer.multitools.CreativeTab;
import main.java.com.kewaiigamer.multitools.Main;
import main.java.com.kewaiigamer.multitools.RegistryUtils;
import main.java.com.kewaiigamer.multitools.plugin.basemetals.MetalPaxel;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModItems {

public static Item woodpaxel;
public static Item stonepaxel;
public static Item ironpaxel;
public static Item goldpaxel;
public static Item diamondpaxel;
public static Item ingotCopper;
public static Item bronzepaxel;

private static Map<Item,String> itemRegistry = new HashMap<>();
private static Map<MetalMaterial,List<Item>> itemsByMetal = new HashMap<>();

public ModItems() {
	createItems();
	createMetalItems();

}
public static void createItems() {
	woodpaxel = new WoodPaxel(ToolMaterial.WOOD).setCreativeTab(CreativeTab.tabMultiTools);
	RegistryUtils.setNames(woodpaxel, "woodpaxel");
	GameRegistry.register(woodpaxel);
	stonepaxel = new StonePaxel(ToolMaterial.STONE).setCreativeTab(CreativeTab.tabMultiTools);
	RegistryUtils.setNames(stonepaxel, "stonepaxel");
	GameRegistry.register(stonepaxel);
	ironpaxel = new IronPaxel(ToolMaterial.IRON).setCreativeTab(CreativeTab.tabMultiTools);
	RegistryUtils.setNames(ironpaxel, "ironpaxel");
	GameRegistry.register(ironpaxel);
	goldpaxel = new GoldPaxel(ToolMaterial.GOLD).setCreativeTab(CreativeTab.tabMultiTools);
	RegistryUtils.setNames(goldpaxel, "goldpaxel");
	GameRegistry.register(goldpaxel);
	diamondpaxel = new DiamondPaxel(ToolMaterial.DIAMOND).setCreativeTab(CreativeTab.tabMultiTools);
	RegistryUtils.setNames(diamondpaxel, "diamondpaxel");
	GameRegistry.register(diamondpaxel);
}
public static void createMetalItems() {
    	bronzepaxel = createPaxel(Materials.bronze);
}
private static Item registerItem(Item item, String name, MetalMaterial metal, CreativeTabs tab){
	item.setRegistryName(Main.MODID, name);
	item.setUnlocalizedName(Main.MODID+"."+name);
	GameRegistry.register(item); 
	itemRegistry.put(item, name);
	if(tab != null){
		item.setCreativeTab(tab);
	}
	if(metal != null){
		itemsByMetal.computeIfAbsent(metal, (MetalMaterial g)->new ArrayList<>());
		itemsByMetal.get(metal).add(item);
	}
	return item;

}

private static Item createPaxel(MetalMaterial metal){
	return registerItem(new MetalPaxel(metal), metal.getName()+"_"+"paxel", metal, CreativeTab.tabMultiTools);
}
    
    


}

 

When I start minecraft it crashes with this log: https://paste.ee/p/UYkWs

Link to comment
Share on other sites

Good job, you created an identifier.

 

You might want to set it equal to something.

 

http://stackoverflow.com/questions/2614072/java-define-terms-initialization-declaration-and-assignment

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I replaced that line of code I replied before with

public static MetalMaterial bronze = Materials.bronze;

and the method createMetalItems() is now

public static void createMetalItems() {
    	bronzepaxel = createPaxel(bronze);

 

but it still gives the same error. (No use to post the log.It's the same)

Link to comment
Share on other sites

The bronze material is initialized in Materials.java:

public abstract class Materials {

private static Map<String,MetalMaterial> allMaterials = new HashMap<>();
private static Map<MetalMaterial,ArmorMaterial> armorMaterialMap= new HashMap<>();
private static Map<MetalMaterial,ToolMaterial> toolMaterialMap= new HashMap<>();

public static MetalMaterial copper;
public static MetalMaterial silver;
public static MetalMaterial tin;
public static MetalMaterial lead;
public static MetalMaterial nickel;
public static MetalMaterial bronze;
public static MetalMaterial brass;
public static MetalMaterial steel;
public static MetalMaterial invar;
public static MetalMaterial electrum;
public static MetalMaterial coldiron;
public static MetalMaterial mithril;
public static MetalMaterial adamantine;
public static MetalMaterial starsteel;
public static MetalMaterial zinc;
public static MetalMaterial aquarium;
public static MetalMaterial cupronickel;
public static MetalMaterial platinum;

// vanilla imports
public static MetalMaterial vanilla_wood;
public static MetalMaterial vanilla_stone;
public static MetalMaterial vanilla_iron;
public static MetalMaterial vanilla_gold;
public static MetalMaterial vanilla_diamond;

private static boolean initDone = false;
public static void init(){
	if(initDone)return;

	// vanilla metals
	vanilla_wood = addMaterial("wood",2,2,6);
	vanilla_stone = addMaterial("stone",5,4,2);
	vanilla_iron = addMaterial("iron",8,8,4.5);
	vanilla_gold = addMaterial("gold",1,1,10);
	vanilla_diamond = addMaterial("diamond",10,15,4);

	// mod metals
	copper = addMaterial("copper",4,4,5);
	silver = addMaterial("silver", 5, 4, 6);
	tin = addMaterial("tin", 3, 1, 2);
	lead = new LeadMaterial("lead", 1, 1, 1);
	registerMaterial(lead.getName(), lead);
	nickel = addMaterial("nickel", 4, 4, 7);
	zinc = addMaterial("zinc", 1, 1, 1);
	bronze = addMaterial("bronze", 8, 4, 4.5);
	brass = addMaterial("brass", 3.5, 3, 9);
	steel = addMaterial("steel", 8, 15, 2);
	invar = addMaterial("invar", 9, 10, 3);
	electrum = addMaterial("electrum", 5, 4, 10);
	coldiron = addMaterial("coldiron", 7, 7, 7);
	mithril = addMaterial("mithril", 9, 9, 9);
	adamantine = new AdamantineMaterial("adamantine", 12, 100, 0);
	registerMaterial(adamantine.getName(), adamantine);
	starsteel = new StarSteelMaterial("starsteel", 10, 25, 12);
	registerMaterial(starsteel.getName(), starsteel);
	aquarium = addMaterial("aquarium", 4, 10, 15);

	cupronickel = addMaterial("cupronickel", 6, 6, 6);
	platinum = addRareMaterial("platinum", 3, 5, 15);

	initDone = true;
}

private static MetalMaterial addMaterial(String name, double hardness, double strength, double magic){
	MetalMaterial m = new MetalMaterial(name,(float)hardness,(float)strength,(float)magic);
	registerMaterial(name, m);
	return m;
}

private static MetalMaterial addRareMaterial(String name, double hardness, double strength, double magic){
	MetalMaterial m = new MetalMaterial(name,(float)hardness,(float)strength,(float)magic,true);
	registerMaterial(name, m);
	return m;
}

protected static void registerMaterial(String name, MetalMaterial m){

	allMaterials.put(name, m);

	String enumName = m.getEnumName();
	String texName = m.getName();
	int[] protection = m.getDamageReductionArray();
	int durability = m.getArmorMaxDamageFactor();
	ArmorMaterial am = EnumHelper.addArmorMaterial(enumName, texName, durability, protection, m.getEnchantability(), SoundEvents.ITEM_ARMOR_EQUIP_IRON, (m.hardness > 10 ? (int)(m.hardness / 5) : 0));
	if(am == null){
		// uh-oh
		FMLLog.severe("Failed to create armor material enum for "+m);
	}
	armorMaterialMap.put(m, am);
	FMLLog.info("Created armor material enum "+am);

	ToolMaterial tm = EnumHelper.addToolMaterial(enumName, m.getToolHarvestLevel(), m.getToolDurability(), m.getToolEfficiency(), m.getBaseAttackDamage(), m.getEnchantability());
	if(tm == null){
		// uh-oh
		FMLLog.severe("Failed to create tool material enum for "+m);
	}
	toolMaterialMap.put(m, tm);
	FMLLog.info("Created tool material enum "+tm);
}
/**
 * Gets the armor material for a given metal 
 * @param m The metal of interest
 * @return The armor material for this metal, or null if there isn't one
 */
public static ArmorMaterial getArmorMaterialFor(MetalMaterial m){
	return armorMaterialMap.get(m);
}


/**
 * Gets the tool material for a given metal 
 * @param m The metal of interest
 * @return The tool material for this metal, or null if there isn't one
 */
public static ToolMaterial getToolMaterialFor(MetalMaterial m){
	return toolMaterialMap.get(m);
}

/**
 * Returns a list of all metal materials in Base Metals. All of the metals 
 * in this list are also available as static public members of this class. 
 * @return A Collection of MetalMaterial instances.
 */
public static Collection<MetalMaterial> getAllMetals() {
	return allMaterials.values();
}
/**
 * Gets a metal material by its name (e.g. "copper").
 * @param metalName The name of a metal
 * @return The material representing the named metal, or null if no metals 
 * have been registered under that name.
 */
public static MetalMaterial getMetalByName(String metalName){
	return allMaterials.get(metalName);
}
}

so I grabbed the bronze from there with

public static MetalMaterial bronze = Materials.bronze;

as Draco said

Link to comment
Share on other sites

public static void init(){
	if(initDone)return;

	// vanilla metals
	vanilla_wood = addMaterial("wood",2,2,6);
	vanilla_stone = addMaterial("stone",5,4,2);
	vanilla_iron = addMaterial("iron",8,8,4.5);
	vanilla_gold = addMaterial("gold",1,1,10);
	vanilla_diamond = addMaterial("diamond",10,15,4);

	// mod metals
	copper = addMaterial("copper",4,4,5);
	silver = addMaterial("silver", 5, 4, 6);
	tin = addMaterial("tin", 3, 1, 2);
	lead = new LeadMaterial("lead", 1, 1, 1);
	registerMaterial(lead.getName(), lead);
	nickel = addMaterial("nickel", 4, 4, 7);
	zinc = addMaterial("zinc", 1, 1, 1);
	bronze = addMaterial("bronze", 8, 4, 4.5);
	brass = addMaterial("brass", 3.5, 3, 9);
	steel = addMaterial("steel", 8, 15, 2);
	invar = addMaterial("invar", 9, 10, 3);
	electrum = addMaterial("electrum", 5, 4, 10);
	coldiron = addMaterial("coldiron", 7, 7, 7);
	mithril = addMaterial("mithril", 9, 9, 9);
	adamantine = new AdamantineMaterial("adamantine", 12, 100, 0);
	registerMaterial(adamantine.getName(), adamantine);
	starsteel = new StarSteelMaterial("starsteel", 10, 25, 12);
	registerMaterial(starsteel.getName(), starsteel);
	aquarium = addMaterial("aquarium", 4, 10, 15);

	cupronickel = addMaterial("cupronickel", 6, 6, 6);
	platinum = addRareMaterial("platinum", 3, 5, 15);

	initDone = true;
}

Link to comment
Share on other sites

At BaseMetals.java during preInitialization

@Mod(
	modid = BaseMetals.MODID,
	name=BaseMetals.NAME,
	version = BaseMetals.VERSION,
	acceptedMinecraftVersions = "[1.9.4,)") // see VersionRange.createFromVersionSpec(String) for explanation of this convoluted feature
//		updateJSON = "https://raw.githubusercontent.com/cyanobacterium/BaseMetals/master/update.json")

public class BaseMetals
{

public static BaseMetals INSTANCE = null;
/** ID of this mod */
public static final String MODID = "basemetals";
/** display name of this mod */
public static final String NAME ="Base Metals";
/** Version number, in Major.Minor.Build format. The minor number is increased whenever a change 
 * is made that has the potential to break compatibility with other mods that depend on this one. */
public static final String VERSION = "2.3.0";



//	/** If true, some metals can be used to brew potions */
//	public static boolean enablePotionRecipes = true;

/** If true, hammers cannot crush ores that they cannot mine */
public static boolean enforceHardness = true;
/** If true, then crack hammers can mine on all the same blocks that their pick-axe equivalent 
 * can mine. If false, then the hammer is 1 step weaker than the pick-axe */
public static boolean strongHammers = true;
/** For when the user adds specific recipies via the config file */
public static List<String> userCrusherRecipes = new ArrayList<>();
/** location of ore-spawn files */
public static Path oreSpawnFolder = null;
/** if true, then this mod will scan the Ore Dictionary for obvious hammer recipes from other mods */
public static boolean autoDetectRecipes = true;
/** if true, then this mod will require the orespawn mod */
public static boolean requireOreSpawn = true;

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	INSTANCE = this;
	// load config
	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
	config.load();

//		enablePotionRecipes = config.getBoolean("enable_potions", "options", enablePotionRecipes, 
//				"If true, then some metals can be used to brew potions.");



	enforceHardness = config.getBoolean("enforce_hardness", "options", enforceHardness, 
			"If true, then the crack hammer cannot crush ingots into powders if that \n"
		+	"crackhammer is not hard enough to crush the ingot's ore.");

	strongHammers = config.getBoolean("strong_hammers", "options", strongHammers, 
			"If true, then the crack hammer can crush ingots/ores that a pickaxe of the same \n"
		+	"material can harvest. If false, then your crack hammer must be made of a harder \n"
		+	"material than the ore you are crushing.");


	autoDetectRecipes = config.getBoolean("automatic_recipes", "options", autoDetectRecipes,
			"If true, then Base Metals will scan the Ore Dictionary to automatically add a \n"
					+	"Crack Hammer recipe for every material that has an ore, dust, and ingot.");

	requireOreSpawn = config.getBoolean("using_orespawn", "options", requireOreSpawn,
			"If false, then Base Metals will not require DrCyano's Ore Spawn mod. \n" +
					"Set to false if using another mod to manually handle ore generation.");


	ConfigCategory userRecipeCat = config.getCategory("hammer recipes");
	userRecipeCat.setComment(
		  "This section allows you to add your own recipes for the Crack Hammer (and other rock \n"
		+ "crushers). Recipes are specified in semicolon ( delimited lists of formulas in the \n"
		+ "format modid:name#y->x*modid:name#y, where x is the number of items in a stack and y \n"
		+ "is the metadata value. Note that both x and y are optional, so you can use the \n"
		+ "formula modid:name->modid:name for most items/blocks. \n\n"
		+ "All properties in this section will be parsed for formulas, regardless their name. \n"
		+ "This lets you organize your recipe lists for easier reading.");
	if(userRecipeCat.keySet().size()==0){
		Property prop = new Property("custom","",Property.Type.STRING);
		prop.setComment("Example: minecraft:stained_glass#11->minecraft:dye#4; minecraft:wool->4*minecraft:string");
		userRecipeCat.put("custom", prop);
	}
	for(Property p : userRecipeCat.values()){
		String[] recipes = p.getString().split(";");
		for(String r : recipes){
			String recipe = r.trim();
			if(recipe.isEmpty()) continue;
			if(recipe.contains("->") == false){
				throw new IllegalArgumentException ("Malformed hammer recipe expression '"+recipe+"'. Should be in format 'modid:itemname->modid:itemname'");
			}
			userCrusherRecipes.add(recipe);
		}
	}

	if(requireOreSpawn) {
		if(!net.minecraftforge.fml.common.Loader.isModLoaded("orespawn")){
			HashSet<ArtifactVersion> orespawnMod = new HashSet<>();
			orespawnMod.add(new DefaultArtifactVersion("1.0.0"));
			throw new MissingModsException(orespawnMod, "orespawn", "DrCyano's Ore Spawn Mod");
		}
		oreSpawnFolder = Paths.get(event.getSuggestedConfigurationFile().toPath().getParent().toString(), "orespawn");
		Path oreSpawnFile = Paths.get(oreSpawnFolder.toString(), MODID + ".json");
		if (Files.exists(oreSpawnFile) == false) {
			try {
				Files.createDirectories(oreSpawnFile.getParent());
				Files.write(oreSpawnFile, Arrays.asList(DataConstants.defaultOreSpawnJSON.split("\n")), Charset.forName("UTF-8"));
			} catch (IOException e) {
				FMLLog.severe(MODID + ": Error: Failed to write file " + oreSpawnFile);
			}
		}
	}

	config.save();

	cyano.basemetals.init.Fluids.init();
	cyano.basemetals.init.Materials.init();
	cyano.basemetals.init.ItemGroups.init();
	cyano.basemetals.init.Blocks.init();
	cyano.basemetals.init.Items.init();
	cyano.basemetals.init.VillagerTrades.init();




	Path ALTPath = Paths.get(event.getSuggestedConfigurationFile().getParent(),"additional-loot-tables");
	Path myLootFolder = ALTPath.resolve(MODID);
	if(Files.notExists(myLootFolder)){
		try{
			Files.createDirectories(myLootFolder.resolve("chests"));
			Files.write(myLootFolder.resolve("chests").resolve("abandoned_mineshaft.json"),
					Arrays.asList(         AdditionalLootTables.abandoned_mineshaft));
			Files.write(myLootFolder.resolve("chests").resolve("desert_pyramid.json"),
					Arrays.asList(         AdditionalLootTables.desert_pyramid));
			Files.write(myLootFolder.resolve("chests").resolve("end_city_treasure.json"),
					Arrays.asList(         AdditionalLootTables.end_city_treasure));
			Files.write(myLootFolder.resolve("chests").resolve("jungle_temple.json"),
					Arrays.asList(         AdditionalLootTables.jungle_temple));
			Files.write(myLootFolder.resolve("chests").resolve("nether_bridge.json"),
					Arrays.asList(         AdditionalLootTables.nether_bridge));
			Files.write(myLootFolder.resolve("chests").resolve("simple_dungeon.json"),
					Arrays.asList(         AdditionalLootTables.simple_dungeon));
			Files.write(myLootFolder.resolve("chests").resolve("spawn_bonus_chest.json"),
					Arrays.asList(         AdditionalLootTables.spawn_bonus_chest));
			Files.write(myLootFolder.resolve("chests").resolve("stronghold_corridor.json"),
					Arrays.asList(         AdditionalLootTables.stronghold_corridor));
			Files.write(myLootFolder.resolve("chests").resolve("stronghold_crossing.json"),
					Arrays.asList(         AdditionalLootTables.stronghold_crossing));
			Files.write(myLootFolder.resolve("chests").resolve("village_blacksmith.json"),
					Arrays.asList(         AdditionalLootTables.village_blacksmith));
		} catch(IOException ex){
			FMLLog.log(Level.ERROR,ex,"%s: Failed to extract additional loot tables",MODID);
		}
	}

	if(event.getSide() == Side.CLIENT){
		clientPreInit(event);
	}
	if(event.getSide() == Side.SERVER){
		serverPreInit(event);
	}
}

@SideOnly(Side.CLIENT)
private void clientPreInit(FMLPreInitializationEvent event){
	// client-only code
	cyano.basemetals.init.Fluids.bakeModels(MODID);

}
@SideOnly(Side.SERVER)
private void serverPreInit(FMLPreInitializationEvent event){
	// server-only code
}

@EventHandler
public void init(FMLInitializationEvent event)
{

	cyano.basemetals.init.Recipes.init();
	cyano.basemetals.init.DungeonLoot.init();
	cyano.basemetals.init.Entities.init();

	cyano.basemetals.init.Achievements.init();


	if(event.getSide() == Side.CLIENT){
		clientInit(event);
	}
	if(event.getSide() == Side.SERVER){
		serverInit(event);
	}
}


@SideOnly(Side.CLIENT)
private void clientInit(FMLInitializationEvent event){
	// client-only code
	cyano.basemetals.init.Items.registerItemRenders(event);
	cyano.basemetals.init.Blocks.registerItemRenders(event);
}
@SideOnly(Side.SERVER)
private void serverInit(FMLInitializationEvent event){
	// server-only code
}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
	cyano.basemetals.init.WorldGen.init();


	// parse user crusher recipes
	for(String recipe : userCrusherRecipes){
		FMLLog.info(MODID+": adding custom crusher recipe '"+recipe+"'");
		int i = recipe.indexOf("->");
		String inputStr = recipe.substring(0,i);
		String outputStr = recipe.substring(i+2,recipe.length());
		ItemStack input = parseStringAsItemStack(inputStr,true);
		ItemStack output = parseStringAsItemStack(outputStr,false);
		if(input == null || output == null){
			FMLLog.severe("Failed to add recipe formula '"+recipe+"' because the blocks/items could not be found");
		} else {
			CrusherRecipeRegistry.addNewCrusherRecipe(input, output);
		}
	}


	if(autoDetectRecipes){
		// add recipe for every X where the Ore Dictionary has dustX, oreX, and ingotX
		Set<String> dictionary = new HashSet<>();
		dictionary.addAll(Arrays.asList(OreDictionary.getOreNames()));
		for(String entry : dictionary){
			if(entry.contains("Mercury")) continue;
			if(entry.startsWith("dust")){
				String X = entry.substring("dust".length());
				String dustX = entry;
				String ingotX = "ingot".concat(X);
				String oreX = "ore".concat(X);
				if(dictionary.contains(oreX) && dictionary.contains(ingotX) && !OreDictionary.getOres(dustX).isEmpty()){
					ItemStack dustX1 = OreDictionary.getOres(dustX).get(0).copy();
					dustX1.stackSize = 1; 
					ItemStack dustX2 = dustX1.copy();
					dustX2.stackSize = 2; 
					// recipe found
					// but is it already registered
					List<ItemStack> oreBlocks = OreDictionary.getOres(oreX);
					boolean alreadyHasOreRecipe = true;
					for(ItemStack i : oreBlocks){
						alreadyHasOreRecipe = alreadyHasOreRecipe 
								&& (CrusherRecipeRegistry.getInstance().getRecipeForInputItem(i) != null);
					}
					List<ItemStack> ingotStacks = OreDictionary.getOres(ingotX);
					boolean alreadyHasIngotRecipe = true;
					for(ItemStack i : ingotStacks){
						alreadyHasIngotRecipe = alreadyHasIngotRecipe 
								&& (CrusherRecipeRegistry.getInstance().getRecipeForInputItem(i) != null);
					}
					if(!alreadyHasOreRecipe){
						FMLLog.info(MODID+": automatically adding custom crusher recipe \"%s\" -> %s",oreX,dustX2);
						CrusherRecipeRegistry.addNewCrusherRecipe(oreX, dustX2);
					}
					if(!alreadyHasIngotRecipe){
						FMLLog.info(MODID+": automatically adding custom crusher recipe \"%s\" -> %s",ingotX,dustX1);
						CrusherRecipeRegistry.addNewCrusherRecipe(ingotX, dustX1);
					}
				}
			}
		}
	}

	if(event.getSide() == Side.CLIENT){
		clientPostInit(event);
	}
	if(event.getSide() == Side.SERVER){
		serverPostInit(event);
	}

	CrusherRecipeRegistry.getInstance().clearCache();
}


@SideOnly(Side.CLIENT)
private void clientPostInit(FMLPostInitializationEvent event){
	// client-only code
}
@SideOnly(Side.SERVER)
private void serverPostInit(FMLPostInitializationEvent event){
	// server-only code
}


/**
 * Parses a String in the format (stack-size)*(modid):(item/block name)#(metadata value). The 
 * stacksize and metadata value parameters are optional.
 * @param str A String describing an itemstack (e.g. "4*minecraft:dye#15" or "minecraft:bow")
 * @param allowWildcard If true, then item strings that do not specify a metadata value will use 
 * the OreDictionary wildcard value. If false, then the default meta value is 0 instead.
 * @return An ItemStack representing the item, or null if the item is not found
 */
public static ItemStack parseStringAsItemStack(String str, boolean allowWildcard){
	str = str.trim();
	int count = 1;
	int meta;
	if(allowWildcard){
		meta = OreDictionary.WILDCARD_VALUE;
	} else {
		meta = 0;
	}
	int nameStart = 0;
	int nameEnd = str.length();
	if(str.contains("*")){
		count = Integer.parseInt(str.substring(0,str.indexOf("*")).trim());
		nameStart = str.indexOf("*")+1;
	}
	if(str.contains("#")){
		meta = Integer.parseInt(str.substring(str.indexOf("#")+1,str.length()).trim());
		nameEnd = str.indexOf("#");
	}
	String id = str.substring(nameStart,nameEnd).trim();
	if(Block.getBlockFromName(id) != null){
		// is a block
		return new ItemStack(Block.getBlockFromName(id),count,meta);
	} else if(Item.getByNameOrId(id) != null){
		// is an item
		return new ItemStack(Item.getByNameOrId(id),count,meta);
	} else {
		// item not found
		FMLLog.severe("Failed to find item or block for ID '"+id+"'");
		return null;
	}
}




}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Bottle Cap Torque Tester: Ensuring Precision in Packaging Integrity In the packaging industry, ensuring that containers are securely sealed is paramount for maintaining product quality and safety. One of the most critical components in this process is the bottle cap, which must be tightened to a precise torque to prevent leaks, contamination, or damage. The Bottle Cap Torque Tester by Pacorr is a high-precision instrument designed to test the opening and closing torque of bottle caps, ensuring the integrity of packaging. Importance of Torque Testing for Bottle Caps Torque is the rotational force applied to tighten or loosen a cap on a bottle. Too much torque can cause the cap or the neck of the bottle to break, while too little torque can result in leaks or tampered products. This is especially important for industries like pharmaceuticals, beverages, cosmetics, and chemicals, where any packaging failure can lead to significant financial loss and harm to consumers. The Bottle Cap Torque Tester Price ensures that every cap is perfectly tightened to the desired specification, preventing such issues and guaranteeing the safety and quality of the product inside. Key Features of Pacorr's Bottle Cap Torque Tester High Precision Measurement: The tester is designed to provide highly accurate torque readings for both capping and uncapping, giving manufacturers confidence in their packaging processes. Versatility: It can accommodate a wide range of bottle sizes and cap types, making it suitable for various industries, including beverages, pharmaceuticals, cosmetics, and more. Easy Operation: With an intuitive design, this machine allows for quick and easy testing, reducing the time needed for quality control checks. Digital Display: The digital readout provides clear, precise torque values, ensuring consistency in testing and improving the accuracy of results. Data Logging: Many models come equipped with data logging capabilities, allowing manufacturers to store and analyze torque measurements for future reference and quality assurance. Benefits of Using the Bottle Cap Torque Tester Improved Product Quality: By ensuring that caps are tightened to the correct torque, manufacturers can prevent leaks and maintain product freshness and safety. Compliance with Industry Standards: The tester helps manufacturers meet industry-specific regulations and standards, ensuring that their products are safe for consumers. Cost Savings: Preventing packaging failures reduces waste and avoids costly recalls, ultimately saving the company money. Enhanced Brand Reputation: Consistent quality control enhances consumer trust in the product, fostering a stronger brand reputation in the market. Applications in Various Industries Pharmaceuticals: In the pharmaceutical industry, packaging must be tamper-proof to ensure product safety. The Bottle Cap Torque Tester ensures that child-resistant caps are securely fastened, complying with safety regulations. Beverages: For carbonated drinks, the correct torque ensures the pressure inside the bottle is maintained without leaking. This helps maintain the product's taste and quality until it reaches the consumer. Cosmetics: Packaging for beauty products often requires precise torque control to ensure that liquids or creams do not leak, preventing product waste and enhancing the user experience. Food & Dairy: Food products need to be tightly sealed to maintain freshness. Incorrect torque can lead to spoilage and contamination, impacting the safety and quality of the food. Conclusion The Bottle Cap Torque Tester from Pacorr is an essential tool for industries where packaging integrity is critical. It helps manufacturers maintain high product quality, comply with regulations, and protect their brand reputation by ensuring that every bottle cap is perfectly sealed. Whether you're in the pharmaceutical, beverage, cosmetic, or food industry, the Bottle Cap Torque Tester is a must-have for efficient and accurate torque testing.
    • The mod is not exported,I'm writing the gradlew build command and it doesn't work. I'm doing the mod on macOS.
    • Asegúrate que tu mod sea de la misma versión que tu servidor si este mod no te funciona prueba otro https://www.curseforge.com/minecraft/search?class=mc-mods&page=1&pageSize=20&search=npc&sortBy=relevancy
    • https://modrinth.com/datapack/animated-doors https://www.spigotmc.org/resources/big-doors.58669/
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.