Files
TAIGA-OV/src/main/java/com/sosnitzka/taiga/util/Utils.java
2016-07-22 10:42:33 -05:00

82 lines
3.1 KiB
Java

package com.sosnitzka.taiga.util;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class Utils {
public static String PREFIX_INGOT = "ingot";
public static String PREFIX_NUGGET = "nugget";
public static String PREFIX_ORE = "ore";
public static String PREFIX_BLOCK = "block";
/**
* Registers the block and its corresponding item (block as item in inventory)
*
* @param block the associated block
*/
public static void registerBlockWithItem(Block block) {
GameRegistry.register(block);
GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}
/**
* Registers the fluid and its bucket item
* @param fluid the fluid
*/
public static void registerFluid(Fluid fluid) {
FluidRegistry.registerFluid(fluid);
FluidRegistry.addBucketForFluid(fluid);
}
public static void registerTinkerAlloys(Fluid alloy, int out, Fluid first, int inOne, Fluid second, int inTwo) {
NBTTagList tagList = new NBTTagList();
NBTTagCompound fluid = new NBTTagCompound();
fluid.setString("FluidName", alloy.getName());
fluid.setInteger("Amount", out);
tagList.appendTag(fluid);
fluid = new NBTTagCompound();
fluid.setString("FluidName", first.getName());
fluid.setInteger("Amount", inOne);
tagList.appendTag(fluid);
fluid = new NBTTagCompound();
fluid.setString("FluidName", second.getName());
fluid.setInteger("Amount", inTwo);
tagList.appendTag(fluid);
NBTTagCompound message = new NBTTagCompound();
message.setTag("alloy", tagList);
FMLInterModComms.sendMessage("tconstruct", "alloy", message);
}
public static void registerTinkerAlloys(Fluid alloy, int out, Fluid first, int inOne, Fluid second, int inTwo, Fluid third, int inThree) {
NBTTagList tagList = new NBTTagList();
NBTTagCompound fluid = new NBTTagCompound();
fluid.setString("FluidName", alloy.getName());
fluid.setInteger("Amount", out);
tagList.appendTag(fluid);
fluid = new NBTTagCompound();
fluid.setString("FluidName", first.getName());
fluid.setInteger("Amount", inOne);
tagList.appendTag(fluid);
fluid = new NBTTagCompound();
fluid.setString("FluidName", second.getName());
fluid.setInteger("Amount", inTwo);
tagList.appendTag(fluid);
fluid = new NBTTagCompound();
fluid.setString("FluidName", third.getName());
fluid.setInteger("Amount", inThree);
tagList.appendTag(fluid);
NBTTagCompound message = new NBTTagCompound();
message.setTag("alloy", tagList);
FMLInterModComms.sendMessage("tconstruct", "alloy", message);
}
}