use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.
the class Forestry method missingMapping.
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
for (MissingMapping mapping : event.get()) {
if (mapping.type == Type.BLOCK) {
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
if (block != null) {
mapping.remap(block);
Proxies.log.warning("Remapping block " + mapping.name + " to " + StringUtil.cleanBlockName(block));
}
} else {
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
if (block != null) {
mapping.remap(Item.getItemFromBlock(block));
Proxies.log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block));
} else {
ForestryItem mappedItem = mappedItems.get(mapping.name);
if (mappedItem != null) {
mapping.remap(mappedItem.item());
Proxies.log.warning("Remapping item " + mapping.name + " to " + mappedItem.name());
}
}
}
}
}
use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.
the class ShapedRecipeCustom method createShapedRecipe.
public static ShapedRecipeCustom createShapedRecipe(ItemStack product, Object... materials) {
String s = "";
int index = 0;
int columns = 0;
int rows = 0;
if (materials[index] instanceof String[]) {
String[] as = (String[]) materials[index++];
for (String pattern : as) {
rows++;
columns = pattern.length();
s = (new StringBuilder()).append(s).append(pattern).toString();
}
} else {
while (materials[index] instanceof String) {
String pattern = (String) materials[index++];
rows++;
columns = pattern.length();
s = (new StringBuilder()).append(s).append(pattern).toString();
}
}
HashMap<Character, Object> hashmap = new HashMap<Character, Object>();
for (; index < materials.length; index += 2) {
Character character = (Character) materials[index];
// Item
if (materials[index + 1] instanceof Item) {
hashmap.put(character, new ItemStack((Item) materials[index + 1]));
} else if (materials[index + 1] instanceof ForestryItem) {
hashmap.put(character, ((ForestryItem) materials[index + 1]).getItemStack());
} else if (materials[index + 1] instanceof ForestryBlock) {
hashmap.put(character, ((ForestryBlock) materials[index + 1]).getItemStack());
} else if (materials[index + 1] instanceof Block) {
hashmap.put(character, new ItemStack((Block) materials[index + 1], 1, Defaults.WILDCARD));
} else if (materials[index + 1] instanceof ItemStack) {
hashmap.put(character, materials[index + 1]);
} else if (materials[index + 1] instanceof String) {
hashmap.put(character, OreDictionary.getOres((String) materials[index + 1]));
} else {
throw new RuntimeException("Invalid Recipe Defined!");
}
}
Object[] ingredients = new Object[columns * rows];
for (int l = 0; l < columns * rows; l++) {
char c = s.charAt(l);
if (hashmap.containsKey(Character.valueOf(c))) {
ingredients[l] = hashmap.get(Character.valueOf(c));
} else {
ingredients[l] = null;
}
}
return new ShapedRecipeCustom(columns, rows, ingredients, product);
}
use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.
the class PluginFluids method doInit.
@Override
public void doInit() {
for (Fluids fluidType : Fluids.values()) {
if (fluidType.getFluid() == null) {
continue;
}
for (EnumContainerType type : EnumContainerType.values()) {
ForestryItem container = fluidType.getContainerForType(type);
if (container == null) {
continue;
}
LiquidHelper.injectLiquidContainer(fluidType, container.getItemStack());
}
for (ItemStack filledContainer : fluidType.getOtherContainers()) {
LiquidHelper.injectLiquidContainer(fluidType, filledContainer);
}
}
}
use of forestry.core.config.ForestryItem in project ForestryMC by ForestryMC.
the class PluginFluids method registerItems.
@Override
public void registerItems() {
for (EnumContainerType type : EnumContainerType.values()) {
Item emptyContainer = new ItemLiquidContainer(type, Blocks.air, null);
switch(type) {
case CAN:
ForestryItem.canEmpty.registerItem(emptyContainer, "canEmpty");
break;
case CAPSULE:
ForestryItem.waxCapsule.registerItem(emptyContainer, "waxCapsule");
break;
case REFRACTORY:
ForestryItem.refractoryEmpty.registerItem(emptyContainer, "refractoryEmpty");
break;
}
for (Fluids fluidType : Fluids.values()) {
ForestryItem container = fluidType.getContainerForType(type);
if (container == null) {
continue;
}
ItemLiquidContainer liquidContainer = new ItemLiquidContainer(type, fluidType.getBlock(), fluidType.getColor());
fluidType.setProperties(liquidContainer);
container.registerItem(liquidContainer, container.toString());
}
}
}
Aggregations