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

GamingTom

Members
  • Content Count

    21
  • Joined

  • Last visited

Posts posted by GamingTom

  1. Hi, I am looking for some help with adding an overlay to the game, something like the health bar. I have tried looking through "GuiIngame.class" but it looks complicated and I don't understand it to well. At the moment, I have:

    4xz5C

    And that works, but I was looking for something that resembles:

    4xzfb.jpg

    And when one of your stats changes, one or more of the little bars change. I would create the textures myself, but I just need to know how to render them and for the changes to take place.

    If anyone would kindly walk me through what I am asking for, of send me to a useful tutorial, I would greatly appreciate it. Many thanks, Tom.

  2. Could you perhaps explain in a little more detail please? I am still learning, so any help will be great. If you know of any useful tutorials that may help in this area, that would also be good. Many thanks, Tom.

  3. How would I use the EntityItem class? I've been looking into it a little, but I don't know how I would use it. Would I need to take some code and add it to, lets say, BlockPedestal.class? I am still learning how to mod, so if you could try and explain what and how to do things, that would be great.

  4. I don't know how you would detect if an item is in the inventory, but I have been detecting when an item is picked up for my mod. For example, when an item is picked up, a specified action takes place.

     

    public class PickupHandler implements IPickupNotifier {
    @Override
    public void notifyPickup(EntityItem item, EntityPlayer player) {
    
                    if (item.getEntityItem().itemID == Items.yourItem.itemID){
                          <perform an action>
                    }
            }
    }

     

    Hope this helps!

  5. I am currently developing a mod based on the popular game, 'The Binding of Isaac'. I am having a little bit of trouble adding the item pedestal. What I need is a block or tile entity which renders a randomly selected item from a range of item id's which is added to an inventory slot in the pedestal. It would also be good if I can swap out the item in the inventory and for it to render the current item. I hope this makes sense and any help would greatly be appreciated. Many thanks, Tom.

  6. Then we set the item in use on right click.

    @Override
    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entityPlayer)
    {
            entityPlayer.setItemInUse(stack, this.getMaxItemUseDuration(stack));
            return stack;
    }
    

    Then

    @Override
    public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer entityPlayer, int amountUsed)
    {
    //do things...
    if (!world.isRemote)
        {
            world.spawnEntityInWorld(new EntityTear(world, entityPlayer));
        }
    }
    

     

    That doesn't seem to do what I want it to do :/ What I want is for when the player hold right click, it constantly fires the projectile but with a certain delay in-between each fire. With the code you suggested, when holding right click, it doesn't fire a projectile. I might have added the code wrong, so again, any help would be appreciated.

  7. Secondly, I'm looking for a way to increase or decrease the player walking speed and maybe possibly stop the player from being able to run. If I can't stop the player running, maybe also limit the running speed. If anyone has any ideas about any of these issues, I would greatly appreciate some help. Many thanks, Tom.

     

    I don't have any useful input about the projectile rate yet (hopefully that changes when I get to the "Skeleton Machinegun" part of my "Ultrasoftcore" mod project), but after reading your second question, I took a look at the code for the soul sand block. It's not much, but it might give you a starting point.

     

    public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)

        {

            par5Entity.motionX *= 0.4D;

            par5Entity.motionZ *= 0.4D;

        }

    }

     

    Thanks! I have successfully got the speed variables working!

     

    Override:

    /**
         * How long it takes to use or consume an item
         */
        public int getMaxItemUseDuration(ItemStack par1ItemStack)
        {
            return 0;//change that
        }
    

     

    Can you maybe explain what I have to change that to? If so, I think it may work!

    I added that code to my ItemTear.class and changed 'return 0;' to 'return 32' but it doesn't seem to change anything, any idea what's wrong?

  8. First things first, I have two classes (EntityTear.class and EntityThrowable.class) which I coppied straight from the Minecraft src, EntityTear was EntitySnowball. I've been looking through the 2 classes and can't figure out a way to limit how fast the item is used. What I want is maybe a second delay inbetween each item use so the entity is fired slower. My code:

     

    EntityTear.class:

    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
    {
    
        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)
            {
                float Damage = Stats.DAMAGE;
    
                
    
                par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)Damage);
            }
    
            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();
            }
        }
    }

     

    EntityThrowable.class

    package tbos.entity.projectile;
    
    import java.util.List;
    
    import net.minecraft.block.Block;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.IProjectile;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.util.EnumMovingObjectType;
    import net.minecraft.util.MathHelper;
    import net.minecraft.util.MovingObjectPosition;
    import net.minecraft.util.Vec3;
    import net.minecraft.world.World;
    import tbos.player.Stats;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    
    
    
    public abstract class EntityThrowable extends Entity implements IProjectile
    {
    
    private int xTile = -1;
        private int yTile = -1;
        private int zTile = -1;
        private int inTile;
        protected boolean inGround;
        public int throwableShake;
    
        /**
         * Is the entity that throws this 'thing' (snowball, ender pearl, eye of ender or potion)
         */
        private EntityLivingBase thrower;
        private String throwerName;
        private int ticksInGround;
        private int ticksInAir;
    
        public EntityThrowable(World par1World)
        {
            super(par1World);
            this.setSize(0.25F, 0.25F);
        }
    
        protected void entityInit() {}
    
        @SideOnly(Side.CLIENT)
    
        /**
         * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
         * length * 64 * renderDistanceWeight Args: distance
         */
        public boolean isInRangeToRenderDist(double par1)
        {
            double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D;
            d1 *= 64.0D;
            return par1 < d1 * d1;
        }
    
        public EntityThrowable(World par1World, EntityLivingBase par2EntityLivingBase)
        {
            super(par1World);
            this.thrower = par2EntityLivingBase;
            this.setSize(0.25F, 0.25F);
            this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch);
            this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
            this.posY -= 0.10000000149011612D;
            this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
            this.setPosition(this.posX, this.posY, this.posZ);
            this.yOffset = 0.0F;
            float f = 0.4F;
            this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
            this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
            this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.func_70183_g()) / 180.0F * (float)Math.PI) * f);
            this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.func_70182_d(), 1.0F);
        }
    
        public EntityThrowable(World par1World, double par2, double par4, double par6)
        {
            super(par1World);
            this.ticksInGround = 0;
            this.setSize(0.25F, 0.25F);
            this.setPosition(par2, par4, par6);
            this.yOffset = 0.0F;
        }
    
        protected float func_70182_d()
        {
            return 1.5F;
        }
    
        protected float func_70183_g()
        {
            return 0.0F;
        }
    
        /**
         * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
         */
        public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8)
        {
            float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
            par1 /= (double)f2;
            par3 /= (double)f2;
            par5 /= (double)f2;
            par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
            par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
            par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
            par1 *= (double)par7;
            par3 *= (double)par7;
            par5 *= (double)par7;
            this.motionX = par1;
            this.motionY = par3;
            this.motionZ = par5;
            float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
            this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
            this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI);
            this.ticksInGround = 0;
        }
    
        @SideOnly(Side.CLIENT)
    
        /**
         * Sets the velocity to the args. Args: x, y, z
         */
        public void setVelocity(double par1, double par3, double par5)
        {
        	
            this.motionX = par1;
            this.motionY = par3;
            this.motionZ = par5;
    
            if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
            {
                float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
                this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
                this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI);
            }
        }
    
        /**
         * Called to update the entity's position/logic.
         */
        public void onUpdate()
        {
            this.lastTickPosX = this.posX;
            this.lastTickPosY = this.posY;
            this.lastTickPosZ = this.posZ;
            super.onUpdate();
    
            if (this.throwableShake > 0)
            {
                --this.throwableShake;
            }
    
            if (this.inGround)
            {
                int i = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
    
                if (i == this.inTile)
                {
                    ++this.ticksInGround;
    
                    if (this.ticksInGround == 1200)
                    {
                        this.setDead();
                    }
    
                    return;
                }
    
                this.inGround = false;
                this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
                this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
                this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
                this.ticksInGround = 0;
                this.ticksInAir = 0;
            }
            else
            {
                ++this.ticksInAir;
            }
    
            Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
            Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
            MovingObjectPosition movingobjectposition = this.worldObj.clip(vec3, vec31);
            vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
            vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
    
            if (movingobjectposition != null)
            {
                vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
            }
    
            if (!this.worldObj.isRemote)
            {
                Entity entity = null;
                List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
                double d0 = 0.0D;
                EntityLivingBase entitylivingbase = this.getThrower();
    
                for (int j = 0; j < list.size(); ++j)
                {
                    Entity entity1 = (Entity)list.get(j);
    
                    if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || this.ticksInAir >= 5))
                    {
                        float f = 0.3F;
                        AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f);
                        MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);
    
                        if (movingobjectposition1 != null)
                        {
                            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
    
                            if (d1 < d0 || d0 == 0.0D)
                            {
                                entity = entity1;
                                d0 = d1;
                            }
                        }
                    }
                }
    
                if (entity != null)
                {
                    movingobjectposition = new MovingObjectPosition(entity);
                }
            }
    
            if (movingobjectposition != null)
            {
                if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE && this.worldObj.getBlockId(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Block.portal.blockID)
                {
                    this.setInPortal();
                }
                else
                {
                    this.onImpact(movingobjectposition);
                }
            }
    
            this.posX += this.motionX;
            this.posY += this.motionY;
            this.posZ += this.motionZ;
            float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
            this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
    
            for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
            {
                ;
            }
    
            while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
            {
                this.prevRotationPitch += 360.0F;
            }
    
            while (this.rotationYaw - this.prevRotationYaw < -180.0F)
            {
                this.prevRotationYaw -= 360.0F;
            }
    
            while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
            {
                this.prevRotationYaw += 360.0F;
            }
    
            this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
            this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
            float f2 = 0.99F;
            float f3 = this.getGravityVelocity();
    
            if (this.isInWater())
            {
                for (int k = 0; k < 4; ++k)
                {
                    float f4 = 0.25F;
                    this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
                }
    
                f2 = 0.8F;
            }
    
            this.motionX *= (double)f2;
            this.motionY *= (double)f2;
            this.motionZ *= (double)f2;
            this.motionY -= (double)f3;
            this.setPosition(this.posX, this.posY, this.posZ);
        }
    
        /**
         * Gets the amount of gravity to apply to the thrown entity with each tick.
         */
        protected float getGravityVelocity()
        {
            return Stats.RANGE;
        }
    
        /**
         * Called when this EntityThrowable hits a block or entity.
         */
        protected abstract void onImpact(MovingObjectPosition movingobjectposition);
    
        /**
         * (abstract) Protected helper method to write subclass entity data to NBT.
         */
        public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
        {
            par1NBTTagCompound.setShort("xTile", (short)this.xTile);
            par1NBTTagCompound.setShort("yTile", (short)this.yTile);
            par1NBTTagCompound.setShort("zTile", (short)this.zTile);
            par1NBTTagCompound.setByte("inTile", (byte)this.inTile);
            par1NBTTagCompound.setByte("shake", (byte)this.throwableShake);
            par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
    
            if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer)
            {
                this.throwerName = this.thrower.getEntityName();
            }
    
            par1NBTTagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
        }
    
        /**
         * (abstract) Protected helper method to read subclass entity data from NBT.
         */
        public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
        {
            this.xTile = par1NBTTagCompound.getShort("xTile");
            this.yTile = par1NBTTagCompound.getShort("yTile");
            this.zTile = par1NBTTagCompound.getShort("zTile");
            this.inTile = par1NBTTagCompound.getByte("inTile") & 255;
            this.throwableShake = par1NBTTagCompound.getByte("shake") & 255;
            this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
            this.throwerName = par1NBTTagCompound.getString("ownerName");
    
            if (this.throwerName != null && this.throwerName.length() == 0)
            {
                this.throwerName = null;
            }
        }
    
        @SideOnly(Side.CLIENT)
        public float getShadowSize()
        {
            return 0.0F;
        }
    
        public EntityLivingBase getThrower()
        {
            if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0)
            {
                this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);
            }
    
            return this.thrower;
        }
    }

     

    Also my ItemTear.class:

    package tbos.items;
    
    import java.util.List;
    
    import net.minecraft.client.renderer.texture.IconRegister;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.world.World;
    import tbos.TheBindingOfSteve;
    import tbos.entity.projectile.EntityTear;
    import tbos.player.Stats;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    
    public class ItemTear extends Item {
    
    public ItemTear(int id) {
    	super(id);
    	setCreativeTab(TheBindingOfSteve.CustomCreativeTab);
    	setMaxStackSize(1);
    	setUnlocalizedName(ItemInfo.TEAR_UNLOCALIZED_NAME);
    
    }
    
    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
    {
    par3List.add("Damage = " + Stats.DAMAGECOUNTER);
    par3List.add("Range = " + Stats.RANGECOUNTER);
    }
    
    @Override
    public boolean func_111207_a(ItemStack itemstack, EntityPlayer player, EntityLivingBase target) {
    
    
    	return false;
    }
    
    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IconRegister register) {
    	itemIcon = register.registerIcon(ItemInfo.TEXTURE_LOCATION + ":" + ItemInfo.TEAR_ICON);
    }
    
    
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (!par3EntityPlayer.capabilities.isCreativeMode)
        {
            //--par1ItemStack.stackSize;
        }
    
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    
        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntityTear(par2World, par3EntityPlayer));
        }
    
        return par1ItemStack;
    }
    }

     

    Secondly, I'm looking for a way to increase or decrease the player walking speed and maybe possibly stop the player from being able to run. If I can't stop the player running, maybe also limit the running speed. If anyone has any ideas about any of these issues, I would greatly appreciate some help. Many thanks, Tom.

     

     

     

  9. 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.

     

  10. Yeah, I realized that I only needed it once after posting, and swiftly changed it, however, I tried it with it only once, in both PreInit and Load, however that didn't work. Which one does it need to be in? PreInit or Load?

  11. This is handled by Ipickupnotifier. One has to implement its only method which is called when an item gets into inventory. When done, register new instance of the class - GameRegistry.registerPickupHandler(new Blabla()).

     

    Use

    EntityItemPickupEvent

    or an

    IPickupNotifier

    .

     

    Hi, thanks for the replies. I decides to do a bit of research on 'IPickupNotifier' and found some tutorials. However, they don't seem to be working... I decided to test it with picking up an item and receiving an achievement. I believe I have done it right, but I'm not sure, here is my code:

     

     

    Main class:

    package tbos;
    
    import net.minecraft.creativetab.CreativeTabs;
    import tbos.blocks.Blocks;
    import tbos.config.ConfigHandler;
    import tbos.items.Items;
    import tbos.network.PacketHandler;
    import tbos.network.PickupHandler;
    import tbos.proxies.CommonProxy;
    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.Mod.PreInit;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import cpw.mods.fml.common.network.NetworkMod;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.common.registry.LanguageRegistry;
    
    @Mod(modid = ModInformation.ID, name = ModInformation.NAME, version = ModInformation.VERSION)
    @NetworkMod(channels = {ModInformation.CHANNEL}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
    public class TheBindingOfSteve {
    
    @Instance(ModInformation.ID)
    public static TheBindingOfSteve instance;
    
    @SidedProxy(clientSide = "tbos.proxies.ClientProxy", serverSide = "tbos.proxies.CommonProxy")
    public static CommonProxy proxy;
    
    public static CreativeTabs CustomCreativeTab = new CustomCreativeTab(CreativeTabs.getNextID(), ModInformation.NAME);
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	ConfigHandler.init(event.getSuggestedConfigurationFile());
    	Items.init();
    	Blocks.init();
    	proxy.initSounds();
    	proxy.initRenderers();
    }
    
    @EventHandler
    public void load(FMLInitializationEvent event) {
    	Items.addNames();
    	Blocks.addNames();
    	LanguageRegistry.instance().addStringLocalization("itemGroup." + ModInformation.NAME, "en_US", ModInformation.NAME);
    	GameRegistry.registerPickupHandler(new PickupHandler());
    
    
    }
    
    @EventHandler
    public void modsLoader(FMLPostInitializationEvent event) {
    
    }
    
    
    }

     

    PickupHandler.class:

    package tbos.network;
    
    import tbos.items.ItemInfo;
    import tbos.items.Items;
    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.buildWorkBench);
    
    }
    }

     

    And ItemInfo.class:

    package tbos.items;
    
    public class ItemInfo {
    
    public static final String TEXTURE_LOCATION = "tbos";
    
    public static int TEAR_ID;
    public static final String TEAR_KEY = "Tear";
    public static final int TEAR_DEFAULT = 24201;
    
    public static final String TEAR_UNLOCALIZED_NAME = "Basic-Tear";
    public static final String TEAR_NAME = "Tear";
    
    public static final String TEAR_ICON = "tear";
    }

     

     

    Any help with this would be greatly appreciated!

     

     

  12. I need some help figuring out if there is a way to perform a certain action when an item is picked up or when it's detected in the players inventory. At the moment I have quite a few items that I'm wanting to change a variable of another item when the item is picked up. However, I don't know if this is possible or if it is, how I'm meant to do it.

    Is there an 'onItemPickup' function or something? And is there somewhere to find all the functions and what they do?

    I hope this makes sense, if not, please tell me and I'll try and make myself clear.

    Many thanks, Tom.

  13. After I reinstalled my Java's, I re-added the paths of them. And after typing "java -version" in a command prompt, I get:

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    
    C:\Users\Thomas>java -version
    java version "1.7.0_25"
    Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
    Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
    
    C:\Users\Thomas>

     

    So it might just be something screwing up with my computer... I'll try running install.cmd on another computer and try copying the files over. I'll report back soon with what happens.

  14. Okay, I assume you meant run the install.cmd after making the changes, and these are the results of the command prompt:

    C:\Users\Thomas\Downloads\forge\fml>echo off
    Traceback (most recent call last):
      File "install.py", line 56, in <module>
        decompile=options.decompile, gen_conf=False)
      File "install.py", line 8, in fml_main
        from fml import download_mcp, setup_mcp, decompile_minecraft, apply_fml_patc
    hes, finish_setup_fml
      File "C:\Users\Thomas\Downloads\forge\fml\fml.py", line 663
        pprint(results)
        ^
    IndentationError: unexpected indent
    Press any key to continue . . .

  15. After trying to install multiple versions of the Forge source from http://files.minecraftforge.net/, I always get a fatal error. I've tried about 5 different versions of the Forge src but nothing seems to work.

     

    Log from "\forge\mcp\logs\mcp.log": http://pastebin.com/wRWAkKEn

     

    I also tried to open the files in eclipse from "C:\forge\mcp\eclipse" but it fails to launch the game with the error:

    Aug 29, 2013 4:21:35 PM net.minecraft.launchwrapper.LogWrapper log
    INFO: Using tweak class name cpw.mods.fml.common.launcher.FMLTweaker
    Aug 29, 2013 4:21:35 PM net.minecraft.launchwrapper.LogWrapper log
    SEVERE: Unable to launch
    java.lang.ClassNotFoundException: cpw.mods.fml.common.launcher.FMLTweaker
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:99)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:49)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

    I have also got the latest JDK installed. I hope I've made myself clear, if not please tell me and I'll try and explain further. Any help would be greatly appreciated!

×
×
  • Create New...

Important Information

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