The Meaning of Life, the Universe, and Everything.
Location:
Kitchener
Join Date:
9/22/2011
Posts:
59
Minecraft:
BenWolvenhour
Member Details
So, as the title says, I would like to (specifically) Either..
1. Disable the vanilla iron ore block completely, and replace it with an identical block, that drop MY item rather than itself.
2. over ride Minecraft and tell the original block to drop my item instead.
or
3. have my block replace irom ore in generation so that it will still be available in creative mode.
I don't have much experience in modding (at all) and I am using MCreator to mod, but I want to slowly learn JAVA so I'm editing the files after making the base block/item.
I typically use a different method to register my method as a mod, instead of having it extend basemod and whatnot. I don't want to mess up your whole setup, and don't know exactly where you'd put it, other than simply sticking it in different places in your base class.
I typically use a different method to register my method as a mod, instead of having it extend basemod and whatnot. I don't want to mess up your whole setup, and don't know exactly where you'd put it, other than simply sticking it in different places in your base class.
Well this is my base class.. Where would I put it? And I only a few blocks/items so far, so I'm not 'too' concern about "Messing my setup"
// Mod & Net Mod
@Mod(modid = Main.modid, name = "BenWolvenhour_wolvenhourterraria", version ="1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Main {
//Enum
// Define Modid
public static final String modid = "BenWolvenhour_wolvenhourterraria";
//Block Defining
public static Block OreCopperBlock;
//Item Defining
public static Item CopperOreDrop;
public static Item CopperIngot;
public static Item CopperSword;
public static Item CopperPickAxe;
public static Item CopperShovel;
public static Item CopperHoe;
public static Item CopperAxe;
//Events
EventManager oreManager = new EventManager();
//Define Block IDs/Materials
@EventHandler
public void load(FMLInitializationEvent event){
// Initialize Blocks
OreCopperBlock = new BlockOreCopperBlock(1200, Material.rock).setUnlocalizedName("wolvenhour_copperoreblock").setTextureName("wolvenhour_copperoreblock").setCreativeTab(CreativeTabs.tabBlock);
// Initialize Items
CopperOreDrop = new ItemCopperOreDrop(1201).setUnlocalizedName("wolvenhour_copperoredrop").setTextureName("wolvenhour_copperoredrop").setCreativeTab(CreativeTabs.tabMisc);
CopperIngot = new ItemCopperIngot(1202).setUnlocalizedName("wolvenhour_copperingot").setTextureName("wolvenhour_copperingot").setCreativeTab(CreativeTabs.tabMaterials);
CopperSword = new ItemCopperSword(1203, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_coppersword").setTextureName("wolvenhour_coppersword").setCreativeTab(CreativeTabs.tabCombat);
CopperPickAxe = new ItemCopperPickAxe(1204, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_copperpickaxe").setTextureName("wolvenhour_copperpickaxe").setCreativeTab(CreativeTabs.tabTools);
CopperShovel = new ItemCopperShovel(1205, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_coppershovel").setTextureName("wolvenhour_coppershovel").setCreativeTab(CreativeTabs.tabTools);
CopperHoe = new ItemCopperHoe(1206, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_copperhoe").setTextureName("wolvenhour_copperhoe").setCreativeTab(CreativeTabs.tabTools);
CopperAxe = new ItemCopperAxe(1207, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_copperaxe").setTextureName("wolvenhour_copperaxe").setCreativeTab(CreativeTabs.tabTools);
Not to be a necromancer, but this topic exactly matches what I want to do and only seems to have a pre-1.7.2 answer.
So, I've got a custom replacement block all set up. Looks exactly like iron, behaves exactly like iron, but it drops the item I want (custom gem style ore rather than the iron ore block). How can I get minecraft to use my custom iron ore block instead of the base?
1.) Replace it in the GameRegistry when the mod is loaded?
2.) Make a custom chunk generator that uses my iron instead of the vanilla iron?
Not to be a necromancer, but this topic exactly matches what I want to do and only seems to have a pre-1.7.2 answer.
So, I've got a custom replacement block all set up. Looks exactly like iron, behaves exactly like iron, but it drops the item I want (custom gem style ore rather than the iron ore block). How can I get minecraft to use my custom iron ore block instead of the base?
1.) Replace it in the GameRegistry when the mod is loaded?
2.) Make a custom chunk generator that uses my iron instead of the vanilla iron?
Thanks!
Don't use that method. Just use an event handler with the HarvestDropsEvent. Then clear the drops array list and ad your mod dropped item.
Rollback Post to RevisionRollBack
I'm working on an open-source mod called Craft++. Check it out!
Don't use that method. Just use an event handler with the HarvestDropsEvent. Then clear the drops array list and ad your mod dropped item.
Exactly this. However, also make sure to reroute all recipes using the to-be-replaced block with the replacement block, or you'll wind up not being able to craft anything at all with the replacement block.
So far from what I have seen, this is the most elegant and simplest solution to this problem. It might not be as effective as the pre-1.7.2 ID-hijacking, but it sure is safer.
So, I've tried the HarvestDropsEvent and the BreakEvent but these don't seem to be doing the trick. Are these events correct for catching the Iron Ore block getting broken/harvested?
I added it to my "init" method, and I (correctly?) assumed that the "new EventHandler()" was an instance of whatever class I have my subscribing event handlers in.
Alright, so I've got some working code for a the block break event, but I was wondering if anyone knew of a better way to do this? I just poked around the classes and found stuff that I thought might work. Please let me know if this is horribly inefficient or way less of a pain than I made it.
What this does is it detect wen a player is breaking an iron ore block, and as long as they're using a pickaxe without silktouch it will add xp to the drop. The main thing I'm wondering about is the NBTTagList. This seems like a hacky way of finding out if the tool has silktouch on it.
Check out the EnchantmentHelper (EnchantHelper?) class. I believe it has a method or two that identifies the enchantments on an ItemStack or returns the enchantment belonging to a certain effectId. Using one of those methods will make your code seem cleaner, I suppose, but it's unnecessary as your code seems to be doing the job just fine.
1. Disable the vanilla iron ore block completely, and replace it with an identical block, that drop MY item rather than itself.
2. over ride Minecraft and tell the original block to drop my item instead.
or
3. have my block replace irom ore in generation so that it will still be available in creative mode.
I don't have much experience in modding (at all) and I am using MCreator to mod, but I want to slowly learn JAVA so I'm editing the files after making the base block/item.
Any help would be greatly appreciated!
It removed the vanilla block from the block list, and replaces it with your own.
Would this be in the BaseMod, or the block itself? (The block itself doesn't seem to have a 'void' + Public)
my code:
import cpw.*;
import cpw.mods.*;
import cpw.mods.fml.*;
import cpw.mods.fml.client.*;
import cpw.mods.fml.client.modloader.*;
import cpw.mods.fml.client.registry.*;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.asm.*;
import cpw.mods.fml.common.asm.transformers.*;
import cpw.mods.fml.common.discovery.*;
import cpw.mods.fml.common.discovery.asm.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.functions.*;
import cpw.mods.fml.common.modloader.*;
import cpw.mods.fml.common.network.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.toposort.*;
import cpw.mods.fml.common.versioning.*;
import cpw.mods.fml.relauncher.*;
import cpw.mods.fml.server.*;
import ibxm.*;
import net.*;
import net.minecraft.*;
import net.minecraft.block.*;
import net.minecraft.block.material.*;
import net.minecraft.client.*;
import net.minecraft.client.audio.*;
import net.minecraft.client.entity.*;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.achievement.*;
import net.minecraft.client.gui.inventory.*;
import net.minecraft.client.model.*;
import net.minecraft.client.multiplayer.*;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.culling.*;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.tileentity.*;
import net.minecraft.client.settings.*;
import net.minecraft.command.*;
import net.minecraft.crash.*;
import net.minecraft.creativetab.*;
import net.minecraft.dispenser.*;
import net.minecraft.enchantment.*;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.boss.*;
import net.minecraft.entity.effect.*;
import net.minecraft.entity.item.*;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.*;
import net.minecraft.entity.projectile.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.item.crafting.*;
import net.minecraft.nbt.*;
import net.minecraft.network.*;
import net.minecraft.network.packet.*;
import net.minecraft.network.rcon.*;
import net.minecraft.pathfinding.*;
import net.minecraft.potion.*;
import net.minecraft.profiler.*;
import net.minecraft.server.*;
import net.minecraft.server.dedicated.*;
import net.minecraft.server.gui.*;
import net.minecraft.server.integrated.*;
import net.minecraft.server.management.*;
import net.minecraft.src.*;
import net.minecraft.stats.*;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.village.*;
import net.minecraft.world.*;
import net.minecraft.world.biome.*;
import net.minecraft.world.chunk.*;
import net.minecraft.world.chunk.storage.*;
import net.minecraft.world.demo.*;
import net.minecraft.world.gen.*;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.layer.*;
import net.minecraft.world.gen.structure.*;
import net.minecraft.world.storage.*;
import net.minecraftforge.*;
import net.minecraftforge.classloading.*;
import net.minecraftforge.client.*;
import net.minecraftforge.client.event.*;
import net.minecraftforge.client.event.sound.*;
import net.minecraftforge.common.*;
import net.minecraftforge.event.*;
import net.minecraftforge.event.entity.*;
import net.minecraftforge.event.entity.item.*;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.minecart.*;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.terraingen.*;
import net.minecraftforge.event.world.*;
import net.minecraftforge.oredict.*;
import net.minecraftforge.transformers.*;
import paulscode.*;
import paulscode.sound.*;
import paulscode.sound.codecs.*;
import java.util.Random;
import java.util.List;
public class mcreator_wolvenhourIronOre extends BaseMod{
public mcreator_wolvenhourIronOre(){}
public static Item block;
public void load(){}
public String getVersion(){
return "1.0";
}
static{
block = (new ItemwolvenhourIronOre(171));
}
static class ItemwolvenhourIronOre extends Item{
public ItemwolvenhourIronOre(int par1){
super(par1);
setMaxDamage(0);
maxStackSize = 64;
setUnlocalizedName("wolvenhour.ironore");
setTextureName("wolvenhour.ironore");
setCreativeTab(CreativeTabs.tabMaterials);
}
public int getItemEnchantability()
{
return 0;
}
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 0;
}
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
return 1.0F;
}
}}
Well this is my base class.. Where would I put it? And I only a few blocks/items so far, so I'm not 'too' concern about "Messing my setup"
package wolvenhourterraria;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.src.ModLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import wolvenhourterraria.blocks.BlockOreCopperBlock;
import wolvenhourterraria.blocks.OreIronBlock;
import wolvenhourterraria.items.ItemCopperIngot;
import wolvenhourterraria.items.ItemCopperOreDrop;
import wolvenhourterraria.tools.ItemCopperAxe;
import wolvenhourterraria.tools.ItemCopperHoe;
import wolvenhourterraria.tools.ItemCopperPickAxe;
import wolvenhourterraria.tools.ItemCopperShovel;
import wolvenhourterraria.tools.ItemCopperSword;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
// Mod & Net Mod
@Mod(modid = Main.modid, name = "BenWolvenhour_wolvenhourterraria", version ="1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Main {
//Enum
// Define Modid
public static final String modid = "BenWolvenhour_wolvenhourterraria";
//Block Defining
public static Block OreCopperBlock;
//Item Defining
public static Item CopperOreDrop;
public static Item CopperIngot;
public static Item CopperSword;
public static Item CopperPickAxe;
public static Item CopperShovel;
public static Item CopperHoe;
public static Item CopperAxe;
//Events
EventManager oreManager = new EventManager();
//Define Block IDs/Materials
@EventHandler
public void load(FMLInitializationEvent event){
// Initialize Blocks
OreCopperBlock = new BlockOreCopperBlock(1200, Material.rock).setUnlocalizedName("wolvenhour_copperoreblock").setTextureName("wolvenhour_copperoreblock").setCreativeTab(CreativeTabs.tabBlock);
// Initialize Items
CopperOreDrop = new ItemCopperOreDrop(1201).setUnlocalizedName("wolvenhour_copperoredrop").setTextureName("wolvenhour_copperoredrop").setCreativeTab(CreativeTabs.tabMisc);
CopperIngot = new ItemCopperIngot(1202).setUnlocalizedName("wolvenhour_copperingot").setTextureName("wolvenhour_copperingot").setCreativeTab(CreativeTabs.tabMaterials);
CopperSword = new ItemCopperSword(1203, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_coppersword").setTextureName("wolvenhour_coppersword").setCreativeTab(CreativeTabs.tabCombat);
CopperPickAxe = new ItemCopperPickAxe(1204, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_copperpickaxe").setTextureName("wolvenhour_copperpickaxe").setCreativeTab(CreativeTabs.tabTools);
CopperShovel = new ItemCopperShovel(1205, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_coppershovel").setTextureName("wolvenhour_coppershovel").setCreativeTab(CreativeTabs.tabTools);
CopperHoe = new ItemCopperHoe(1206, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_copperhoe").setTextureName("wolvenhour_copperhoe").setCreativeTab(CreativeTabs.tabTools);
CopperAxe = new ItemCopperAxe(1207, EnumToolMaterial.STONE).setUnlocalizedName("wolvenhour_copperaxe").setTextureName("wolvenhour_copperaxe").setCreativeTab(CreativeTabs.tabTools);
//Generation
GameRegistry.registerWorldGenerator(oreManager);
//Register Blocks
GameRegistry.registerBlock(OreCopperBlock, modid + OreCopperBlock.getLocalizedName().substring(5));
LanguageRegistry.addName(OreCopperBlock, "Copper Ore");
//Register Items
GameRegistry.registerItem(CopperOreDrop, modid + CopperOreDrop.getUnlocalizedName().substring(5));
LanguageRegistry.addName(CopperOreDrop, "Copper Ore");
GameRegistry.registerItem(CopperIngot, modid + CopperIngot.getUnlocalizedName().substring(5));
LanguageRegistry.addName(CopperIngot, "Copper Ingot");
GameRegistry.registerItem(CopperSword, modid + CopperSword.getUnlocalizedName().substring(5));
LanguageRegistry.addName(CopperSword, "Copper Sword");
GameRegistry.registerItem(CopperPickAxe, modid + CopperPickAxe.getUnlocalizedName().substring(5));
LanguageRegistry.addName(CopperPickAxe, "Copper Pickaxe");
GameRegistry.registerItem(CopperShovel, modid + CopperShovel.getUnlocalizedName().substring(5));
LanguageRegistry.addName(CopperShovel, "Copper Shovel");
GameRegistry.registerItem(CopperHoe, modid + CopperHoe.getUnlocalizedName().substring(5));
LanguageRegistry.addName(CopperHoe, "Copper Hoe");
GameRegistry.registerItem(CopperAxe, modid + CopperAxe.getUnlocalizedName().substring(5));
LanguageRegistry.addName(CopperAxe, "Copper Axe");
//Recipes
//Stack Defining
ItemStack CopperSword = new ItemStack(Main.CopperSword);
ItemStack CopperPickaxe = new ItemStack(Main.CopperPickAxe);
ItemStack CopperShovel = new ItemStack(Main.CopperShovel);
ItemStack CopperHoe = new ItemStack(Main.CopperHoe);
ItemStack CopperAxe = new ItemStack(Main.CopperAxe);
//Grid Arrangement
GameRegistry.addSmelting(Main.CopperOreDrop.itemID, new ItemStack(Main.CopperIngot), 0.1f);
FurnaceRecipes.smelting() .addSmelting(Main.CopperOreDrop.itemID, 0, new ItemStack(Main.CopperIngot, 1), 0.1f);
//copper sword
GameRegistry.addRecipe(CopperSword, "x", "x", "y",
'x', Main.CopperIngot, 'y', Item.stick );
//copper pickaxe
GameRegistry.addRecipe(CopperPickaxe, "xxx", " y ", " y ",
'x', Main.CopperIngot, 'y', Item.stick );
//copper shovel
GameRegistry.addRecipe(CopperShovel, "x", "y", "y",
'x', Main.CopperIngot, 'y', Item.stick );
//Copper Hoe
GameRegistry.addRecipe(CopperHoe, "xx ", " y ", " y ",
'x', Main.CopperIngot, 'y', Item.stick );
GameRegistry.addRecipe(CopperHoe, " xx", " y ", " y ",
'x', Main.CopperIngot, 'y', Item.stick );
//Copper Axe
GameRegistry.addRecipe(CopperAxe, "xx ", "xy ", " y ",
'x', Main.CopperIngot, 'y', Item.stick );
GameRegistry.addRecipe(CopperAxe, " xx", " yx", " y ",
'x', Main.CopperIngot, 'y', Item.stick );
}
}
PS: Unrelated Question.. Do you know of any Tutorials toward making armor? That aren't completely horrible?
So, I've got a custom replacement block all set up. Looks exactly like iron, behaves exactly like iron, but it drops the item I want (custom gem style ore rather than the iron ore block). How can I get minecraft to use my custom iron ore block instead of the base?
1.) Replace it in the GameRegistry when the mod is loaded?
2.) Make a custom chunk generator that uses my iron instead of the vanilla iron?
Thanks!
Don't use that method. Just use an event handler with the HarvestDropsEvent. Then clear the drops array list and ad your mod dropped item.
I'm working on an open-source mod called Craft++. Check it out!
Exactly this. However, also make sure to reroute all recipes using the to-be-replaced block with the replacement block, or you'll wind up not being able to craft anything at all with the replacement block.
So far from what I have seen, this is the most elegant and simplest solution to this problem. It might not be as effective as the pre-1.7.2 ID-hijacking, but it sure is safer.
My mods: Archmagus, BetterBoneMeal, BetterVanilla, Brewing-API, NaturalArmors, and PluckableChickens!
I added it to my "init" method, and I (correctly?) assumed that the "new EventHandler()" was an instance of whatever class I have my subscribing event handlers in.
What this does is it detect wen a player is breaking an iron ore block, and as long as they're using a pickaxe without silktouch it will add xp to the drop. The main thing I'm wondering about is the NBTTagList. This seems like a hacky way of finding out if the tool has silktouch on it.
My mods: Archmagus, BetterBoneMeal, BetterVanilla, Brewing-API, NaturalArmors, and PluckableChickens!