Merge remote-tracking branch 'origin/GigDev'

Conflicts:
	src/main/java/techreborn/Core.java
This commit is contained in:
modmuss50 2015-04-11 15:17:42 +01:00
commit 92605dd50f
4 changed files with 163 additions and 4 deletions

View file

@ -1,9 +1,5 @@
package techreborn;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import techreborn.blocks.BlockQuantumChest;
import techreborn.blocks.BlockQuantumTank;
@ -12,7 +8,13 @@ import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileQuantumChest;
import techreborn.tiles.TileQuantumTank;
import net.minecraft.item.Item;
import techreborn.items.ItemDusts;
import techreborn.tiles.TileThermalGenerator;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "techreborn", name = "TechReborn", version = "@MODVERSION@")
public class Core {
@ -21,6 +23,9 @@ public class Core {
public static Block quantumTank;
public static Block quantumChest;
public static Item dusts;
@Mod.Instance
public static Core INSTANCE;
@ -38,6 +43,9 @@ public class Core {
GameRegistry.registerBlock(quantumChest, "techreborn.quantumChest");
GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest");
dusts = new ItemDusts();
GameRegistry.registerItem(dusts, "dust");
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
}

View file

@ -0,0 +1,81 @@
package techreborn.items;
import java.util.List;
import techreborn.Core;
import techreborn.client.TechRebornCreativeTab;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
public class ItemDusts extends ItemTR
{
public static final String[] types = new String[]
{
"Almandine", "Aluminium", "Andradite", "Ashes", "Basalt", "Bauxite", "Brass", "Bronze",
"Calcite","Charcoal", "Chrome", "Cinnabar", "Clay", "Coal", "Copper", "Dark Ashes", "Diamond",
"Electrum","Emerald", "Ender Eye", "Ender Pearl", "Endstone", "Flint", "Gold", "Green Sapphire", "Grossular",
"Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian",
"Olivine","Phosphor", "Platinum", "Pyrite", "Pyrope", "Red Garnet", "Redrock", "Ruby", "Saltpeter", "Sapphire",
"Silver", "Sodalite", "Spessartine", "Sphalerite", "Steel", "Sulfur", "Tin", "Titanium", "Tungsten", "Uranium",
"Uvarovite", "Yellow Garnet", "Zinc"
};
private IIcon[] textures;
public ItemDusts()
{
setUnlocalizedName("dust");
setHasSubtypes(true);
setCreativeTab(TechRebornCreativeTab.instance);
}
@Override
// Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister)
{
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i)
{
textures[i] = iconRegister.registerIcon("techreborn" + "dust");
}
}
@Override
// Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta)
{
if (meta < 0 || meta >= textures.length)
{
meta = 0;
}
return textures[meta];
}
@Override
// gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack)
{
int meta = itemStack.getItemDamage();
if (meta < 0 || meta >= types.length)
{
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta];
}
// Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
{
for (int meta = 0; meta < types.length; ++meta)
{
list.add(new ItemStack(item, 1, meta));
}
}
}

View file

@ -0,0 +1,20 @@
package techreborn.items;
import techreborn.client.TechRebornCreativeTab;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
public class ItemTR extends Item{
public ItemTR()
{
setCreativeTab(TechRebornCreativeTab.instance);
}
@Override
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("techreborn" + ":" + getUnlocalizedName().toLowerCase().substring(5));
}
}

View file

@ -0,0 +1,50 @@
package techreborn.util;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
public class RecipeRemover
{
public static void removeShapedRecipes(List<ItemStack> removelist)
{
for (ItemStack stack : removelist)
removeShapedRecipe(stack);
}
public static void removeAnyRecipe(ItemStack resultItem)
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++)
{
IRecipe tmpRecipe = recipes.get(i);
ItemStack recipeResult = tmpRecipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
{
recipes.remove(i--);
}
}
}
public static void removeShapedRecipe(ItemStack resultItem)
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++)
{
IRecipe tmpRecipe = recipes.get(i);
if (tmpRecipe instanceof ShapedRecipes)
{
ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
ItemStack recipeResult = recipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
{
recipes.remove(i++);
}
}
}
}
}