Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PeterRDevries

Forge Modder
  • Joined

  • Last visited

Everything posted by PeterRDevries

  1. Sorry for the late reply but if I use this event the text on a block is still drawn in italic how would i change this
  2. Fixed it if anyone is interrested: Apperantly draco was right but I needed to use damage dropped together with item dropped: public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return BlocksItems.Mineral; } public int damageDropped(int par1, Random par2Random, int par3){ return 0; }
  3. Thanks for you quick reply I tried public ItemStack getDamageDropped(int par1, Random par2Random, int par3){ return new ItemStack(BlocksItems.Mineral, 1, 1); } also damageDropped. none of them worked.
  4. Hi. I've been trying to get my block to drop metadata items but I can't seem to get it to work here are my attempts public ArrayList<ItemStack> idDropped(int par1, Random par2Random, int par3){ ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); int metaDropped = 0; switch (nextRandom(1)) { case 0: metaDropped = 0; break; case 1: metaDropped = 1; break; } ret.add(new ItemStack(BlocksItems.Mineral, 1, metaDropped)); return ret; } public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Items.redstone;//? } thanks for your help
  5. Dunno how it could not sometimes I find metadata annoying to use well thanks for your help!
  6. Ah okay thanks. 1 more question is metadata still viable? since minecraft doesn't have ids anymore. It could still be usefull for registering 5 items that are nearly the same like logs.
  7. Yeah, well it works. Do you know any other methods I should use(I'm just fiddeling around here with java)? should I use the NBTTagList?
  8. Ah well for anyone interrested heres my sourcecode: playerclass: package molecularscience.api; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; public class ExtendedPlayer implements IExtendedEntityProperties { public final static String EXT_PROP_NAME = "ExtendedPlayer"; private final EntityPlayer player; private static String researches; public ExtendedPlayer(EntityPlayer player){ this.player = player; } public static final void register(EntityPlayer player){ player.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer(player)); } public static final ExtendedPlayer get(EntityPlayer player){ return (ExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME); } @Override public void saveNBTData(NBTTagCompound compound){ NBTTagCompound properties = new NBTTagCompound(); properties.setString("researched", this.researches); compound.setTag(EXT_PROP_NAME, properties); } @Override public void loadNBTData(NBTTagCompound compound){ NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.researches = properties.getString("researched"); } @Override public void init(Entity entity, World world){} public static void Research(String item) { item = item + ","; researches = researches + item; } public static boolean IsResearched(String item){ if(researches != null){ String[] researched = researches.split(","); for(String p: researched){ if(p.equals(item)){ return true; } } } return false; } } itemclass package molecularscience.moditems; import java.util.List; import org.apache.commons.lang3.StringUtils; import molecularscience.Config; import molecularscience.MolecularScience; import molecularscience.api.ExtendedPlayer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemSample extends Item { public ItemSample() { super(); this.setHasSubtypes(true); this.setCreativeTab(MolecularScience.Molecules); } public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { String Itemname = par1ItemStack.getDisplayName(); Itemname = StringUtils.removeEnd(Itemname, " Sample"); Object Itemmolecule = null; String moleculesinitem = null; if(Config.Blockmolecules.get(Itemname) != null){ Itemmolecule = Config.Blockmolecules.get(Itemname); moleculesinitem = Itemmolecule.toString(); } if(ExtendedPlayer.IsResearched(Itemname)){ if(Config.Blockmolecules.get(Itemname) != null){ par3List.add( "This Sample consists of: " + Itemmolecule ); if(moleculesinitem.contains(",")){ String[] splitmolecule = moleculesinitem.split(","); for( int i = 0; i <= splitmolecule.length - 1; i++){ par3List.add(Config.Moleculesatoms.get(splitmolecule[i])); } }else{ par3List.add(Config.Moleculesatoms.get(Itemmolecule)); } } }else{ par3List.add("You have not yet researched this sample"); } } }
  9. I think you mean you want the item to look 3d in the inventory like a block. Well what you need to do if you already have the 3d rendering code. Just change it from item to a block that is being 3d rendered.
  10. GameRegistry.registerWorldGenerator(this, 0); chage to GameRegistry.registerWorldGenerator(this, 1); Worked for me atleast.
  11. After a bit of fiddling around with nbt I noticed that you can't store a string array? are there any equivalent methods for this? setbytearray? Or should i set everything in a large string? like: "grass,dirt,air" I think that would be kinda slow because I'll have to iterate through the string if I want to check for a block. Because if I wouldn't split the string it could return true if it'll look for grass and I only have Grass Block for example
  12. Would this be a good example? http://www.minecraftforge.net/forum/index.php?topic=6999.0
  13. Yeah I have seen something like storing the data per player using that
  14. Have you taken a look at the minecraft arrow source?
  15. Hello and thanks for reading. I'm trying to store nbtdata to see if a player has researched a item. I'm now storing the nbtdata to an itemstack but that means everytime I get a new itemstack the player would have to research it again. How would I set researched to "true" for every type of that item? Thanks for your help!
  16. Sorry for asking, but how would I use this method?
  17. Hello forge. Well just as the title says how can I add information to existing vanilla items? Like you do with this method: public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { Thanks!
  18. Wow thanks i finally got it working now!
  19. public class TileEntityRunecraftFire extends BlockContainer { public TileEntityRunecraftFire(int id) { super(id, Material.fire); this.setCreativeTab(Main.tabRuneCraft); } @Override public TileEntity createNewTileEntity(World world) { return new TileEntityRunecraftFireEntity(); } @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random random){ if (random.nextInt(24) == 0) { world.playSound((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "fire.fire", 1.0F + random.nextFloat(), random.nextFloat() * 0.7F + 0.3F, false); } float f1 = (float)x + 0.6F; float f2 = (float)y + 0.1F; float f3 = (float)z + 0.6F; float f4 = random.nextFloat() * 0.3F -0.3F; float f5 = random.nextFloat() * 0.3F -0.3F; float f6 = (float)y + 0.2F; float f7 = (float)y + 0.3F; float f8 = (float)y + 0.4F; float f9 = (float)y + 0.5F; float f10 = (float)y + 0.6F; float f11 = (float)x + 0.6F; float f12 = (float)z + 0.6F; world.spawnParticle("flame", (double)(f1+f4), (double)f2, (double)(f3+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f6, (double)(f3+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f7, (double)(f3+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f8, (double)(f3+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f9, (double)(f3+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f10, (double)(f3+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f11+f4), (double)f6, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f11+f4), (double)f7, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f11+f4), (double)f8, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f11+f4), (double)f9, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f11+f4), (double)f10, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f11+f4), (double)f2, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f6, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f7, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f8, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f9, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f10, (double)(f12+f5), 0.0D, 0.0D, 0.0D); world.spawnParticle("flame", (double)(f1+f4), (double)f2, (double)(f12+f5), 0.0D, 0.0D, 0.0D); } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { par1World.setBlock(par2, par3, par4, FireMaking.ITEM_ASHES_ID); } public void registerIcons(IconRegister icon) { this.blockIcon = icon.registerIcon("runecraft:textures/blocks/Fire"); } } Old fire code that spawned fire particles, I don't know if it still works for 1.7.2 but you can try.
  20. Hi thanks for the reply but i can't seem to find the anvil src, atleast not the anvil tile entity do you perhaps know where i can find it?
  21. Still can't seem to set localized names
  22. Just as the title explains How can I add a metadata item to my inventory using it's unlocalized name? using par2EntityPlayer.inventory.addItemStackToInventory(new ItemStack(sample,1)); thanks
  23. Well I was trying that but that would just change the item name to Arrow and not Arrow sample as that is what I'm trying to accomplish EDIT: I tried something different: the item file package ModItems; import java.util.ArrayList; import java.util.List; import molecularscience.MolecularScience; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemSample extends Item { public ItemSample() { super(); this.setHasSubtypes(true); setMaxDamage(0); this.setCreativeTab(MolecularScience.Molecules); } public static final String[] names = MolecularScience.Namen.toArray(new String[MolecularScience.Namen.size()]); @Override public String getUnlocalizedName(ItemStack par1ItemStack) { int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, MolecularScience.Namen.size()); return super.getUnlocalizedName() + "." + names[i]; } @SuppressWarnings({ "unchecked", "rawtypes" }) @SideOnly(Side.CLIENT) public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (int x = 0; x < MolecularScience.Namen.size(); x++) { par3List.add(new ItemStack(this, 1, x)); } } } the main mod file package molecularscience; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import java.util.Set; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.Item; import ModItems.ItemSample; import ModItems.ItemSampler; 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.SidedProxy; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid = MolecularScience.MODID, version = MolecularScience.VERSION) public class MolecularScience { public static List<String> Namen = new ArrayList<String>(); //versie en id public static final String MODID = "MolecularScience"; public static final String VERSION = "1.0.0"; //items public static Item Sampler; public static Item Sample; @Instance(value = "MolecularScience") public static MolecularScience instance; @SidedProxy(clientSide="molecularscience.ClientProxy", serverSide="molecularscience.CommonProxy") public static CommonProxy proxy; //creative tab public static CreativeTabs Molecules = new CreativeTabs("Molecules"){ public Item getTabIconItem(){ return Items.arrow; } }; //register spull @EventHandler public void preInit(FMLPreInitializationEvent event){ //items Sampler = new ModItems.ItemSampler().setUnlocalizedName("sampler").setCreativeTab(MolecularScience.Molecules); //gameregistry GameRegistry.registerItem(Sampler,"sampler"); //language registry namen van dinge word gedaan in de en_US.lang file proxy.registerRenderers(); Set<String> example = GameData.blockRegistry.getKeys(); for (String s : example) { String[] split = s.split(":"); Namen.add(split[1]); } Sample = new ItemSample().setUnlocalizedName("sample"); GameRegistry.registerItem(Sample, "Sample"); } @EventHandler public void init(FMLPostInitializationEvent event) { } }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.