Jump to content

Draco18s

Members
  • Posts

    16559
  • Joined

  • Last visited

  • Days Won

    155

Everything posted by Draco18s

  1. Right, of course. And just because I did it right and forgot the null check when posting the first time doesn't mean I don't know. It just means that you shouldn't be blindingly copy-pasting.
  2. Javadoc: I happen to be using the "or 0" effect in my current mod: public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { NBTTagCompound data = par1ItemStack.getTagCompound(); int effectID = 0; //oddly this function runs on the server, but directly altering the player entity has no effect. //so instead we end up using packets if(data != null && par2World.isRemote) { effectID = data.getInteger("onItemRightClick"); if(effectID != 0) { //do stuff } } return par1ItemStack; }
  3. Ah. Yes. Of course, what's funny is when I tried it, an enchanted weapon told me the string was "Weapon damage" and my code didn't work. (Turned out the line I was missing at the time was nnbt.setString("AttributeName", att.getName()); "AttributeName" being what the end-result looks for, but I never found it being set anywhere, though I did find "Name" used in several places). Like I said, pain in the ass to figure out from just the code.
  4. Its the same as getBlockTexture, but rather than looping through the directions (up,down,left,right,forward,backward) it is passed the direction to look at. This prevents blockA -> blockB -> blockA -> infinite loop texture requests. And yes, it doesn't work well for grass. Grass is such a pain in the ass to fake, due to using three textures, only one of which (the top) needs to get colored, but the getBlockColor() method takes no parameters! getRenderColor() is slightly better, but passes only a single integer (side?), not enough to know if the block that is being rendered is a supposed to be mimicking grass or not. colorMultiplier() is better still, but doesn't distinguish by side.
  5. Couple of things: That counter is a local variable to that function. Every time the function is run that value will be 0, thus it will add a new enchantment: int counter = 0; if(counter <= 0){ Second even though you're incrementing the counter each time it adds an enchantment, you reset the counter to 1 at the end: case 6: {par1ItemStack.addEnchantment(Enchantment.smite, 2);} counter++; break; };counter = 1; In order to get what you want, you will need to store the counter in the NBT data for the itemstack: NBTTagCompound nbt = par1ItemStack.stackTagCompound; int counter = nbt.getInteger("EnchantmentCounter"); //returns 0 if tag doesn't exist, which is fine if(counter <= 0) { //add an enchantment counter++; } nbt.setInteger("EnchantmentCounter",counter);
  6. Holycow this was not easy. Here's what I ended up with: public ItemStack attached(ItemStack i, Random rand) { NBTTagCompound inbt = i.stackTagCompound; NBTTagCompound nnbt = new NBTTagCompound(); NBTTagList nnbtl = new NBTTagList(); AttributeModifier att = new AttributeModifier("generic.attackDamage", 1, 0); nnbt.setLong("UUIDMost", att.getID().getMostSignificantBits()); nnbt.setLong("UUIDLeast", att.getID().getLeastSignificantBits()); nnbt.setString("Name", att.getName()); nnbt.setDouble("Amount", att.getAmount()); nnbt.setInteger("Operation", att.getOperation()); nnbt.setString("AttributeName", att.getName()); nnbtl.appendTag(nnbt); inbt.setTag("AttributeModifiers", nnbtl); return i; } List of modifier names, as they do not appear to be listed anywhere convenient: generic.attackDamage generic.followRange generic.maxHealth generic.knockbackResistance generic.movementSpeed And a handful of others that only apply to specific mobs (parentheticals indicate what entity): zombie.spawnReinforcements (zombies) Baby speed boost (zombies) Attacking speed boost (endermen, pig zombies) Drinking speed penalty (witches)
  7. public class ConfigurationHandler extends mod_SecurityCraft{ extends mod_SecurityCraft Uh. What.
  8. Due to the nature of what I'm doing this would be exceedingly difficult. EXCEEDINGLY. Affects all instances of that item, not a valid solution. I want each instance to have its own value that is constant, not magically alter every item instance to a different number every time that number is polled. Ah ha! Brilliant. I didn't see that ItemStack had the same tidlybits.
  9. Is it reasonably possible to have a single Item class that would allow for variable weapon strength (using NBT tags) without having to go through the enchantment system (i.e. Sharpness)? As far as I can tell, item damage is handled via getItemAttributeModifiers(), which does not pass an ItemStack (so no NBT data). Resorting to the Sharpness enchantment isn't out of the question, just less than ideal, as I'd like to handle that independently.
  10. Food is correctly referred to as "shanks."
  11. I don't think this is possible, TBH. I don't think it would be able to perform adequate pathfinding, even if it was non-solid and allowed to pass through walls; it would never try. If it is though, that would be really cool.
  12. And what string is needed? "ironTool" OR "Material.iron" or"EnumToolMaterial.iron" And I guess level needs a float. But would you kindly provide an example? I have oly worked with modloader before. "tool" is the string for the tool name. Vanilla uses "shovel" "pickaxe" and "axe." Swords are handled by the web and leaf blocks respectively. However this string can also be any other custom tool, though there are additional registrations that have to be handled regarding the tool (and is not something I've messed with).
  13. Ohsitdude, you don't need custom renderers or TileEntities for this. Here's some code from a block of mine. It was called CamoPhaseStone (mod thread) Now, it would only grab textures in an orthogonal line from its position, but this was done to prevent infinite loops where one block would ask another block what it's texture was, and that block would ask the first block.
  14. You didn't set the block's hardness. Just because it's made of iron doesn't mean it will take a certain number of swings or a certain tool level. To enforce the iron pick you need to also set its harvest level. block.setHardness(5.0F); MinecraftForge.setBlockHarvestLevel(block, "tool", level);
  15. Galicraft replaces the player class with their own, avoiding the issue (and also getting thing things like low gravity).
  16. Having actually messed with this: From EntityLiving (or EntityLivingBase, if you're new enough): if (this.isEntityAlive() && this.isInsideOfMaterial(Material.water)) { if (!this.canBreatheUnderwater() && !this.isPotionActive(Potion.waterBreathing.id) && !flag) { this.setAir(this.decreaseAirSupply(this.getAir())); if (this.getAir() == -20) { this.setAir(0); for (int i = 0; i < 8; ++i) { float f = this.rand.nextFloat() - this.rand.nextFloat(); float f1 = this.rand.nextFloat() - this.rand.nextFloat(); float f2 = this.rand.nextFloat() - this.rand.nextFloat(); this.worldObj.spawnParticle("bubble", this.posX + (double)f, this.posY + (double)f1, this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ); } this.attackEntityFrom(DamageSource.drown, 2.0F); } } this.extinguish(); if (!this.worldObj.isRemote && this.isRiding() && ridingEntity!=null && ridingEntity.shouldDismountInWater(this)) { this.mountEntity((Entity)null); } } else { this.setAir(300); } If the entity is inside a block of material type water, they drown. Otherwise they get full air (that's what's resetting it). Problem is, Material.Water is also what allows for swimming.
  17. Thanks Lex. Apparently I can't read the documentation. Still annoying that it wouldn't reply when I tried to reference the class. And yes, I plan on fixing the javadoc, but I had to get MCPbot to behave (read: supply correct input) before I could update the docs. Edit: Gah. Can't rename already renamed methods. I had this problem once before, but I don't remember how to override that in order to change the description.
  18. I realize this is not a Forge thing but an MCPBot thing, but here's the issue: /** * Adds a sounds with the name from the file. Args: name, file */ public void addSound(String par1Str) { this.soundPoolSounds.addSound(par1Str); } Javadoc is clearly out of date, as the function no longer takes a file reference. MCPBot conversation: func_77372_a is the function name I pulled out of the decompiled source of someone else's mod (in an attempt to try and figure out how they did sounds) and discovered that the way they'd done it for their latest release...isn't how it's done currently (on the plus side, the new way is easier, but the javadocs are out of date). Yeah, I dunno what to do now.
  19. @ForgeSubscribe public void onSoundLoad(SoundLoadEvent event) { event.manager.addSound("MODID:SOUND1.ogg"); event.manager.addSound("MODID:SOUND2.ogg"); } world.playSoundAtEntity(entityplayer, "MODID:SOUND", 1F, 1F); Then your sounds go into a folder called "sound" inside your mod's asset directory. Voila, now you can use sounds like textures!
  20. Close enough. At least I finally stopped trying to add an L to it.
  21. By moving the resource directory to where it needs to be. If you're using the Pahmir* setup, you'll have to import it the same way you would anything else. *I forget how to spell his name and don't care to actually look it up
  22. Essentially you'd be requesting Forge to add hooks for what you need. Reflections. Google it. You won't be able to pull this off at your skill level though. No, you'd simply be replacing a variable with a new value. You wouldn't be altering the code itself.
  23. Oh my god, are you not listening! You're the one who used "override inside a method" first and also complained that doing so "threw an error" and never said what this error was. Previous mention of @Override? and Neither one of which mention putting override INSIDE a method. YOU did that. You were then informed that that was doing it wrong, provided an example of doing it right, and you started bitching again about us not understanding you. We're not telepathetic, like you appear to be, get it through your head: WE CANNOT READ YOUR MIND, NOR YOUR CODE unless you post it in a clear, concise, manner. Oh, and yes. I'm a dick. Get over it.
  24. TBH I might even be wrong. The best part is, Minecraft will print an error of the correct location when the load fails.
×
×
  • Create New...

Important Information

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