Jump to content

Robertof

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Robertof

  1. Sorry for the double post - but I fixed that: /** * A function which generates an EntityItem * from an ItemStack, given World and x, y, z coordinates. * @param wObj The world object where the entity will be spawned. * @param result The ItemStack to drop. It will be automatically copied. * @param x X coordinate * @param y Y coordinate * @param z Z coordinate * @author Robertof */ protected void genBlockDrop (World wObj, ItemStack result, int x, int y, int z) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { float var6 = 0.7F; double var7 = (double)(wObj.rand.nextFloat() * var6) + (double)(1.0F - var6) * 0.5D; double var9 = (double)(wObj.rand.nextFloat() * var6) + (double)(1.0F - var6) * 0.5D; double var11 = (double)(wObj.rand.nextFloat() * var6) + (double)(1.0F - var6) * 0.5D; EntityItem ei = new EntityItem(wObj, (double)x + var7, (double)y + var9, (double)z + var11, new ItemStack (result.itemID, result.stackSize, result.getItemDamage())); if (result.hasTagCompound()) ei.item.setTagCompound((NBTTagCompound) result.getTagCompound().copy()); ei.delayBeforeCanPickup = 10; wObj.spawnEntityInWorld(ei); } } add that to onBlockStartBreak along with something to add damage to the tool used (if you want), then return true and you are good to go.
  2. Yep but as I said - I don't have the access to the original block (and I don't wanna edit the original classes). I just have the access to the tool. By the way I guess I should use a temporary block which drops what is in the metadata. Thanks anyways.
  3. Hello, I'm pretty new to Forge programming (but not to programming in general), and I need to ask a thing. I already tried to ask that in IRC but I got no response. Anyways, I have a class 'ItemMyPickaxe' which should replace some blocks when they break. However I didn't find anything to do this. I tried 2 different solutions: Using onBlockStartBreak() and then running playerEntity.worldObj.setBlock (blockX, blockY, blockZ, newblock) That would've work perfectly, but then I realized that I need to drop even items, not just blocks. So, nope. Then I tried again with onBlockStartBreak(), this time dropping the block manually using the code in Block.dropBlockAsItem_do(). But using that leads to 1) the drop entity not being placed correctly, for a reason unknown to me 2) the need to add the code in ItemInWorldManager.tryHarvestBlock(x,y,z). But that's too much, and also dangerous for future updates. Can anyone help me on this? (to make an example - a thing like Azanor's TC2 Pickaxe of the core is what I would need: it cooked the items on the fly and dropped them, but I still didn't understand how to do that) Thank you very much, Robertof
×
×
  • Create New...

Important Information

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