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

Variables...


Recommended Posts

Hi, I'm currently developing a mod based on 'The Binding of Isaac' and I have an item which will be modified depending on which items are picked up. However, I don't know how to change a variable in another class when a function in another is called. I tried using a 'public static' variable but I recently read that they are only ever updated at the start of an application, and I need them to always be updated.

 

Here is my Pickup Handler class:

package tbos.network;

import tbos.items.ItemInfo;
import tbos.items.Items;
import tbos.player.Stats;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.stats.AchievementList;
import cpw.mods.fml.common.IPickupNotifier;

public class PickupHandler implements IPickupNotifier {
@Override
public void notifyPickup(EntityItem item, EntityPlayer player) {

	if (item.getEntityItem().itemID == ItemInfo.TEAR_DEFAULT)
			//player.triggerAchievement(AchievementList.mineWood);

}
}

 

My EnityTear class which has the damage in:

package tbos.entity.projectile;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import tbos.player.Stats;

public class EntityTear extends EntityThrowable
{

private byte DAMAGE = 5;

    public EntityTear(World par1World)
    {
        super(par1World);
    }

    public EntityTear(World par1World, EntityLivingBase par2EntityLivingBase)
    {
        super(par1World, par2EntityLivingBase);
    }

    public EntityTear(World par1World, double par2, double par4, double par6)
    {
        super(par1World, par2, par4, par6);
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
     */
    protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
    {
        if (par1MovingObjectPosition.entityHit != null)
        {
            byte b0 = DAMAGE;

            

            par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
        }

        for (int i = 0; i < 8; ++i)
        {
            this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
        }

        if (!this.worldObj.isRemote)
        {
            this.setDead();
        }
    }
}

 

And here is my stats class which I was using:

package tbos.player;

public class Stats {

public static float RANGE = 0.1f;
public static byte DAMAGE = 5;

}

 

So to summarize, when an Item is picked up, I would like it to increase, or decrease the variables from the stats class, but by different ammounts for different items, and for the item effects to stack. For example if and Item which was '+5 damage' is picked up, then an item with '-2 damage', it would only add 3 to the base damage. If any of this is possible. I hope I've made myself clear, if not please tell me and I'll try again. Many thanks, Tom.

 

Link to post
Share on other sites

your deffinition of static is wrong ... maybe you should look into the basics...

 

also, once the player picks up one of the item that is supposed to change the stat item, check if that player has the said stat item, get a reference to the itemstack containing it and increase a stat variable in the nbt of that itemstack

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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