Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

grand_mind1

Members
  • Posts

    122
  • Joined

  • Last visited

Posts posted by grand_mind1

  1. If I understand you correctly, you're only letting the item be set if it has already been set before (Because an item's nbt tag, by default, is null). You probably want that the other way around.

     

    Sorry, it occured to me that you probably aren't talking about setting the tag in itemInteractionForEntity(). Can I see your code for adding the information?

  2. You can override the method itemInteractionForEntity() in your Item class to handle the right clicking of a player. You can use the method getDisplayName() in the EntityPlayer class to get a player's name, and you can save the name to nbt using the nbt methods in ItemStack.

    Sample (Not tested):

    @Override
    public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase livingBase) {
        if (livingBase instanceof EntityPlayer) {
            NBTTagCompound tagCompound = new NBTTagCompound();
            tagCompound.setString("playerName", ((EntityPlayer) livingBase).getDisplayName());
            stack.setTagCompound(tagCompound);
            return true;
        }
        return false;
    }
    

  3. The reason it moves with your mouse is because you're drawing the texture to the position of your mouse in drawScreen(). You're passing the x and y coordinates given to you by drawScreen() to drawTexturedModalRect(), but these coordinates are the coordinates of the mouse. You need to pass it the position you want the texture to be drawn to.

    I'm guessing the texture can't be found because I think you need to set your mod id to lowercase when you create a ResourceLocation, but I'm not positive on that one.

  4. I assume you mean a bukkit plugin, in which case, I doubt it. As far as I know, the plugin would have to be made specifically to interact with the mod using some intermediary like chat (or, as pointed out by Ernio, an api), for instance. I doubt this is what you want, though.

  5. Yeah, sorry, I meant to say that. 80k should be a full item. I got the items from the creative menu. This is the code I used to add the full item to the menu, if it is relevant:

        @Override
        public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
        {
                list.add(new ItemStack(this, 1));
                ItemStack fullEnergy = new ItemStack(this, 1);
                this.setEnergyStored(fullEnergy, 80000);
                list.add(fullEnergy);
        }
    

    setEnergyStored() just manipulates the NBT value used to store the amount of energy.

  6. Hi, I'm trying to make an item that can store "energy". I'd like the item to have a durability bar that displays how much energy it currently stores. I've tried to use showDurabilityBar() and getDurabilityForDisplay(), however it seems that the durability bar displays the opposite of what it should. (i.e. the bar is completely green when the item is empty and empty when the item is full)

    Here is an example of what I mean:

    http://i.imgur.com/U2byBbA.png

    The item on the left is empty and the item on the right is full.

    This is the code I have for the durability bar:

        @Override
        public boolean showDurabilityBar(ItemStack itemStack)
        {
            return true;
        }
    
        @Override
        public double getDurabilityForDisplay(ItemStack itemStack)
        {
            if (itemStack.getTagCompound() == null || !itemStack.getTagCompound().hasKey("Energy"))
            {
                itemStack.stackTagCompound = new NBTTagCompound();
                itemStack.getTagCompound().setInteger("Energy", 0);
            }
    
            return itemStack.getTagCompound().getInteger("Energy") / 80000;
        }
    

    According to the documentation for getDurabilityForDisplay(), you are to pass 1 for 100% durability and 0 for 0%. I thought that this is what this would accomplish, but I must have done something wrong.

    Thanks! :D

  7. Ah, I was trying to make it a soft dependancy, but only just learned about the @Optional annotation. If you don't mind, I have another question about the annotation. I've upated the class here:

    https://github.com/grandmind/Pandas-Things/blob/6b62cadb90ed9e4424b62d51d62db5e8105b1189/src/main/java/com/darichey/PandasThings/tileEntity/TileEntityPoweredAnvil.java

    The game now crashes because of my use of EnergyStorage. I understand now why this happens, but I'm not sure how to fix it. Is there any similar thing to the optional annotation that I can use for the field?

  8. Hi, as the title says, I'm having trouble with my mod once it has been built and is no longer being run through my development environmet. The mod works fine in the dev environment. The game crashes on launch with the follwing crash report:

    http://pastebin.com/JTcY3vVJ

    Because I think it's easier to read code on github, here's a link to the referenced class:

    https://github.com/grandmind/Pandas-Things/blob/master/src/main/java/com/darichey/PandasThings/tileEntity/TileEntityPoweredAnvil.java

    I'm sure I've just done something stupid with tile entities, as usual.

    Any help is appreciated.

    Thanks! :D

  9. Sorry, I worded it kind of strangely. Let me try to correct myself and clarify. I'm talking about the fireball that is fired by the ghast. As far as I can tell, the game separates the blaze/fire charge and ghast fireball into EntitySmallFireball and EntityLargeFireball, respectively. I'm trying to detect the explosion made by the large fireball in the ExplosionEvent. However, this it is not possible to distinguish, in the ExplosionEvent, if the explosion was caused by an EntityLargeFireball. This is because when the fireball creates the explosion, it sets the cause of the newly created explosion to null.

  10. Hey guys, quick question. EntityLargeFireball creates an explosion on impact like normal with worldObj.newExplosion(), however it sets the entity for the cause of the explosion to null, rather than EntityLargeFireball for some reason. I was just wondering if there is any way around this, because I would like to be able to get the cause of explosions.

    Thanks!

  11. Hey, title says most of it. I'm trying to create an explosion that will not damage the environment (only damage the player, play sound, create particles). I'm trying to do this under certain conditions for creepers. According to the documentation of the Explosion class, doExplosionB() should do what I want. This is what I have right now:

    @SubscribeEvent
    public void onWorldExplosion(ExplosionEvent.Start event)
    {
        Entity cause = event.explosion.exploder;
    
        if (cause instanceof EntityCreeper)
        {
            event.setCanceled(true);
            Explosion explosion = new Explosion(event.world, cause, event.explosion.explosionX, event.explosion.explosionY, event.explosion.explosionZ, ((EntityCreeper) cause).getPowered() ? 6 : 3);
            explosion.doExplosionB(true);
        }
    }
    

    However, I must not understand the consequences of using doExplosionB() without doExplosion(), because this does not work. The creeper disappears and no explosion is created.

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.