Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GemBlocksForGregMod.java
- package de.ultrapeeks.gemblocksforgreg;
- import net.minecraft.block.Block;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.init.Blocks;
- import net.minecraft.init.Items;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraftforge.common.MinecraftForge;
- import net.minecraftforge.oredict.OreDictionary;
- import net.minecraftforge.oredict.ShapedOreRecipe;
- import cpw.mods.fml.common.Mod;
- import cpw.mods.fml.common.Mod.EventHandler;
- import cpw.mods.fml.common.Mod.Instance;
- import cpw.mods.fml.common.event.FMLInitializationEvent;
- import cpw.mods.fml.common.registry.GameRegistry;
- import cpw.mods.fml.common.registry.LanguageRegistry;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import de.ultrapeeks.gemblocksforgreg.BasicGemBlock.GemType;
- @Mod(modid = GemBlocksForGregMod.MODID, name = GemBlocksForGregMod.NAME, version = GemBlocksForGregMod.VERSION)
- public class GemBlocksForGregMod {
- public static final String MODID = "GemBlocksForGreg";
- public static final String NAME = "GemBlocksForGreg";
- public static final String VERSION = "1.2";
- @Instance(value = MODID)
- public static GemBlocksForGregMod instance;
- public static CreativeTabs tabCustom = new CreativeTabs(MODID) {
- @Override
- @SideOnly(Side.CLIENT)
- public Item getTabIconItem() {
- return Item.getItemFromBlock(GameRegistry.findBlock(MODID, "rubyBlock"));
- }
- };
- @EventHandler
- public void preInit(FMLInitializationEvent event) {
- for (GemType type: GemType.values()) {
- Block block = new BasicGemBlock(type);
- GameRegistry.registerBlock(block, type.getName());
- for(String oreName: type.getOreNames()) {
- OreDictionary.registerOre(oreName, block);
- }
- GameRegistry.addRecipe(new ShapedOreRecipe(
- new ItemStack(block), "xxx", "xxx", "xxx", Character.valueOf('x'), type.getGemOreName()));
- }
- Block block = null;
- for (int i = 0; i < MetalType.values().length; i++) {
- MetalType type = MetalType.values()[i];
- if (i % 16 == 0) {
- block = new BasicMetalBlock(i / 16);
- GameRegistry.registerBlock(block, MetalBlockItem.class, block.getUnlocalizedName(), block);
- }
- ItemStack stack = new ItemStack(block, 1, i % 16);
- for(String oreName: type.getOreNames()) {
- OreDictionary.registerOre(oreName, stack.copy());
- }
- GameRegistry.addRecipe(new ShapedOreRecipe(
- stack.copy(), "xxx", "xxx", "xxx", Character.valueOf('x'), type.getIngotOreName()));
- }
- }
- @EventHandler
- public void postInit(FMLInitializationEvent event) {
- for(ItemStack item: OreDictionary.getOres("ironwood")) {
- OreDictionary.registerOre("ingotIronWood", item);
- }
- }
- }
- //----------------------------------------------------------------------------------------
- // BasicGemBlock.java
- package de.ultrapeeks.gemblocksforgreg;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.util.IIcon;
- public class BasicGemBlock extends Block {
- public enum GemType {
- RUBY("rubyBlock", "gemRuby", "blockRuby", "blockGemRuby"),
- SAPPHIRE("sapphireBlock", "gemSapphire", "blockSapphire", "blockGemSapphire"),
- GREEN_SAPPHIRE("greenSapphireBlock", "gemGreenSapphire", "blockGreenSapphire", "blockGemGreenSapphire"),
- OLIVINE("olivineBlock", "gemOlivine", "blockOlivine", "blockGemOlivine"),
- TOPAZ("topazBlock", "gemTopaz", "blockTopaz", "blockGemTopaz"),
- TANZANITE("tanzaniteBlock", "gemTanzanite", "blockTanzanite", "blockGemTanzanite"),
- AMETHYST("amethystBlock", "gemAmethyst", "blockAmethyst", "blockGemAmethyst"),
- OPAL("opalBlock", "gemOpal", "blockOpal", "blockGemOpal"),
- JASPER("jasperBlock", "gemJasper", "blockJasper", "blockGemJasper"),
- BLUE_TOPAZ("blueTopazBlock", "gemBlueTopaz", "blockBlueTopaz", "blockGemBlueTopaz"),
- FOOLS_RUBY("foolsRubyBlock", "gemFoolsRuby", "blockFoolsRuby", "blockGemFoolsRuby"),
- AMBER("amberBlock", "gemAmber", "blockAmber", "blockGemAmber"),
- DILITHIUM("dilithiumBlock", "gemDilithium", "blockDilithium", "blockGemDilithium"),
- FORCICIUM("forciciumBlock", "gemForcicium", "blockForcicium", "blockGemForcicium"),
- FORCILLIUM("forcilliumBlock", "gemForcillium", "blockForcillium", "blockGemForcillium"),
- FORCE("forceBlock", "gemForce", "blockForce", "blockGemForce"),
- RED_GARNET("redGarnetBlock", "gemGarnetRed", "blockGarnetRed", "blockGemGarnetRed"),
- YELLOW_GARNET("yellowGarnetBlock", "gemGarnetYellow", "blockGarnetYellow", "blockGemGarnetYellow"),
- VINTEUM("vinteumBlock", "gemVinteum", "blockVinteum", "blockGemVinteum"),
- ENDERPEARL("enderPearlBlock", "gemEnderPearl", "blockEnderPearl", "blockGemEnderPearl"),
- ENDEREYE("enderEyeBlock", "gemEnderEye", "blockEnderEye", "blockGemEnderEye"),
- AER("aerCrystalBlock", "gemInfusedAir", "blockInfusedAir", "blockGemInfusedAir"),
- IGNIS("ignisCrystalBlock", "gemInfusedFire", "blockInfusedFire", "blockGemInfusedFire"),
- TERRA("terraCrystalBlock", "gemInfusedEarth", "blockInfusedEarth", "blockGemInfusedEarth"),
- AQUA("aquaCrystalBlock", "gemInfusedWater", "blockInfusedWater", "blockGemInfusedWater"),
- PERDITIO("perditioCrystalBlock", "gemInfusedEntropy", "blockInfusedEntropy", "blockGemInfusedEntropy"),
- ORDO("ordoCrystalBlock", "gemInfusedOrder", "blockInfusedOrder", "blockGemInfusedOrder");
- private String name;
- private String gemOreName;
- private String[] oreNames;
- private GemType(String name, String gemOreName, String... oreNames) {
- this.name = name;
- this.gemOreName = gemOreName;
- this.oreNames = oreNames;
- }
- public String getName() {
- return name;
- }
- public String[] getOreNames() {
- return oreNames;
- }
- public String getGemOreName() {
- return gemOreName;
- }
- }
- private static final String TEXTURE_PREFIX = "gemblocksforgreg:gems/";
- private GemType type;
- protected BasicGemBlock(GemType type) {
- super(Material.iron);
- this.type = type;
- setBlockName(type.getName());
- setHardness(3.0f);
- setStepSound(Block.soundTypeMetal);
- setCreativeTab(GemBlocksForGregMod.tabCustom);
- setHarvestLevel("pickaxe", 2);
- setBlockTextureName(TEXTURE_PREFIX + type.getName());
- }
- }
- //----------------------------------------------------------------------------------------------
- // BasicMetalBlock.java
- package de.ultrapeeks.gemblocksforgreg;
- import java.util.List;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.client.renderer.texture.TextureMap;
- import net.minecraft.client.settings.GameSettings;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.IIcon;
- public class BasicMetalBlock extends Block{
- private static final String TEXTURE_PREFIX = "gemblocksforgreg:metals/";
- private final int offset;
- private IIcon[] iconBuffer;
- @Override
- public int damageDropped(int damage) {
- return damage;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void getSubBlocks(Item item, CreativeTabs tab, List list) {
- int enumLength = MetalType.values().length;
- for (int i = 0; i < 16 && i + this.offset * 16 < enumLength; i++) {
- list.add(new ItemStack(item, 1, i));
- }
- }
- @Override
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister icons) {
- int enumLength = MetalType.values().length;
- int offset = this.offset * 16;
- this.iconBuffer = new IIcon[Math.min(enumLength - offset, 16)];
- IIcon defaultIcon = icons.registerIcon(TEXTURE_PREFIX + "defaultBlock");
- for(int i = 0; i < this.iconBuffer.length; i++) {
- this.iconBuffer[i] = icons.registerIcon(TEXTURE_PREFIX + MetalType.values()[i + offset].getName());
- }
- }
- @Override
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int side, int meta) {
- if (meta >= this.iconBuffer.length) {
- System.out.println("Warning: unknown meta data " + meta + " for block " + getUnlocalizedName() + ". Prevented Overflow.");
- return this.iconBuffer[0];
- }
- return this.iconBuffer[meta];
- }
- public int getOffset() {
- return offset;
- }
- protected BasicMetalBlock(int offset) {
- super(Material.iron);
- this.offset = offset;
- setBlockName("metalBlock" + offset);
- setHardness(3.0f);
- setStepSound(Block.soundTypeMetal);
- setCreativeTab(GemBlocksForGregMod.tabCustom);
- setHarvestLevel("pickaxe", 2);
- }
- }
- // -----------------------------------------------------------------------------------------
- // MetalBlockItem.java
- package de.ultrapeeks.gemblocksforgreg;
- import net.minecraft.block.Block;
- import net.minecraft.item.ItemBlock;
- import net.minecraft.item.ItemStack;
- public class MetalBlockItem extends ItemBlock{
- private BasicMetalBlock block;
- public MetalBlockItem(Block block, BasicMetalBlock metalBlock) {
- super(block);
- this.block = metalBlock;
- setHasSubtypes(true);
- }
- @Override
- public int getMetadata(int damage) {
- return damage;
- }
- @Override
- public String getUnlocalizedName(ItemStack itemStack) {
- MetalType type = MetalType.values()[block.getOffset() * 16 + itemStack.getItemDamage()];
- return "tile." + type.getName();
- }
- }
- // --------------------------------------------------------------------------------------------------------------------
- // MetalType.java
- package de.ultrapeeks.gemblocksforgreg;
- public enum MetalType {
- BERYLLIUM("Beryllium"),
- MAGNESIUM("Magnesium"),
- ALUMINIUM("Aluminium"),
- SILICON("Silicon"),
- SCANDIUM("Scandium"),
- TITANIUM("Titanium"),
- VANADIUM("Vanadium"),
- CHROME("Chrome"),
- MANGANESE("Manganese"),
- COBALT("Cobalt"),
- NICKEL("Nickel"),
- COPPER("Copper"),
- ZINC("Zinc"),
- GALLIUM("Gallium"),
- ARSENIC("Arsenic"),
- RUBIDIUM("Rubidium"),
- YTTRIUM("Yttrium"),
- NIOBIUM("Niobium"),
- MOLYBDENUM("Molybdenum"),
- PALLADIUM("Palladium"),
- SILVER("Silver"),
- INDIUM("Indium"),
- TIN("Tin"),
- ANTIMONY("Antimony"),
- TELLURIUM("Tellurium"),
- CAESIUM("Caesium"),
- LANTHANUM("Lanthanum"),
- CERIUM("Cerium"),
- PRASEODYMIUM("Praseodymium"),
- NEODYMIUM("Neodymium"),
- SAMARIUM("Samarium"),
- EUROPIUM("Europium"),
- GADOLINIUM("Gadolinium"),
- TERBIUM("Terbium"),
- DYSPROSIUM("Dysprosium"),
- HOLMIUM("Holmium"),
- ERBIUM("Erbium"),
- THULIUM("Thulium"),
- YTTERBIUM("Ytterbium"),
- LUTETIUM("Lutetium"),
- TANTALUM("Tantalum"),
- TUNGSTEN("Tungsten"),
- OSMIUM("Osmium"),
- IRIDIUM("Iridium"),
- PLATINUM("Platinum"),
- LEAD("Lead"),
- BISMUTH("Bismuth"),
- THORIUM("Thorium"),
- URANIUM235("Uranium235"),
- URANIUM("Uranium"),
- PLUTONIUM("Plutonium"),
- PLUTONIUM241("Plutonium241"),
- AMERICIUM("Americium"),
- NEUTRONIUM("Neutronium"),
- BRONZE("Bronze"),
- BRASS("Brass"),
- INVAR("Invar"),
- ELECTRUM("Electrum"),
- WROUGHT_IRON("WroughtIron"),
- STEEL("Steel"),
- STAINLESS_STEEL("StainlessSteel"),
- PIG_IRON("PigIron"),
- RED_ALLOY("RedAlloy"),
- BLUE_ALLOY("BlueAlloy"),
- CUPRONICKEL("Cupronickel"),
- NICHROME("Nichrome"),
- KANTHAL("Kanthal"),
- MAGNALIUM("Magnalium"),
- SOLDERING_ALLOY("SolderingAlloy"),
- BATTERY_ALLOY("BatteryAlloy"),
- TUNGSTEN_STEEL("TungstenSteel"),
- OSMIRIDIUM("Osmiridium"),
- SUNNARIUM("Sunnarium"),
- ADAMANTIUM("Adamantium"),
- FLUXED_ELECTRUM("ElectrumFlux"),
- ENDERIUM("Enderium"),
- HSLA_STEEL("HSLA"),
- INFUSED_GOLD("InfusedGold"),
- NAQUADAH("Naquadah"),
- NAQUADAH_ALLOY("NaquadahAlloy"),
- ENRICHED_NAQUADAH("NaquadahEnriched"),
- NAQUADRIA("Naquadria"),
- DURANIUM("Duranium"),
- TRITANIUM("Tritanium"),
- THAUMIUM("Thaumium"),
- MITHRIL("Mithril"),
- MIDASIUM("Midasium"),
- ASTRAL_SILVER("AstralSilver"),
- BLACK_STEEL("BlackSteel"),
- DAMASCUS_STEEL("DamascusSteel"),
- SHADOW_IRON("ShadowIron"),
- SHADOW_STEEL("ShadowSteel"),
- IRON_WOOD("IronWood"),
- METEORIC_IRON("MeteoricIron"),
- METEORIC_STEEL("MeteoricSteel"),
- DARK_IRON("DarkIron"),
- COBALT_BRASS("CobaltBrass"),
- ULTIMET("Ultimet"),
- ANNEALED_COPPER("AnnealedCopper"),
- FIERY_STEEL("FierySteel"),
- RED_STEEL("RedSteel"),
- BLUE_STEEL("BlueSteel"),
- STERLING_SILVER("SterlingSilver"),
- ROSE_GOLD("RoseGold"),
- BLACK_BRONZE("BlackBronze"),
- BISMUTH_BRONZE("BismuthBronze"),
- MAGNETIC_IRON("IronMagnetic"),
- MAGNETIC_STEEL("SteelMagnetic"),
- MAGNETIC_NEODYMIUM("NeodymiumMagnetic"),
- VANADIUM_GALLIUM("VanadiumGallium"),
- YTTRIUM_BARIUM_CUPRATE("YttriumBariumCuprate"),
- NIOBIUM_NITRIDE("NiobiumNitride"),
- NIOBIUM_TITANIUM("NiobiumTitanium"),
- CHROMIUM_DIOXIDE("ChromiumDioxide"),
- KNIGHTMETAL("Knightmetal"),
- TIN_ALLOY("TinAlloy"),
- DEEP_IRON("DeepIron"),
- DESH("Desh");
- private String name;
- private String ingotOreName;
- private String[] oreNames;
- private MetalType(String material) {
- this.name = material.substring(0, 1).toLowerCase() + material.substring(1) + "Block";
- this.ingotOreName = "ingot" + material;
- this.oreNames = new String[]{"block" + material, "blockMetal" + material};
- }
- public String getName() {
- return name;
- }
- public String[] getOreNames() {
- return oreNames;
- }
- public String getIngotOreName() {
- return ingotOreName;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement