Jump to content

yariplus

Members
  • Posts

    44
  • Joined

  • Last visited

Posts posted by yariplus

  1. 	@Override
    public void generate(Random random, int chunkX, int chunkZ, World world,
    		IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
    	int x = random.nextInt(16);
    	int z = random.nextInt(16);
    
    	this.generate(world, random, x, world.getHeightValue(x, z), z);
    }

     

    Umm, this is placing every single tree at chunk 0,0

     

    It should be

     

    int x = chunkX*16 + random.nextInt(16);
    int z = chunkZ*16 + random.nextInt(16);

  2. This is the Itemstack writeToNBT method:

     

        /**
         * Write the stack fields to a NBT object. Return the new NBT object.
         */
        public NBTTagCompound writeToNBT(NBTTagCompound p_77955_1_)
        {
            p_77955_1_.setShort("id", (short)Item.getIdFromItem(this.field_151002_e));
            p_77955_1_.setByte("Count", (byte)this.stackSize);
            p_77955_1_.setShort("Damage", (short)this.itemDamage);
    
            if (this.stackTagCompound != null)
            {
                p_77955_1_.setTag("tag", this.stackTagCompound);
            }
    
            return p_77955_1_;
        }

     

    It checks and stores the stackTagCompound, which you store a second time in your writeToNBT:

     

    			nbt.setTag("ItemStack"+i,NBT); // Stores the NBT.stackTagCompound Tag
    		nbt.setTag("ItemStackData"+i, inv[i].stackTagCompound); // Duplicate Tag

     

     

     

    markDirty() is a method on TileEntity. It ensures that the TileEntity is saved. Even if Minecraft would normally not save it, for example, when no blocks have changed.

  3. This is the code from EntityBlaze I put into my own mob. It works perfectly, as I will explain below. (Hopefully accurately.)

     

        @Override
        public void attackEntityWithRangedAttack(EntityLivingBase entity, float distance) {
    
            double d0 = entity.posX - this.posX;
            double d1 = entity.boundingBox.minY + (double)(entity.height / 2.0F) - (this.posY + (double)(this.height / 2.0F));
            double d2 = entity.posZ - this.posZ;

     

    This calculates the x,y,z DISTANCE between the projectile and the target. getLook() only gives the DIRECTION.

     

            float f1 = MathHelper.sqrt_float(distance) * 0.5F;

     

    This is calculating the accuracy (randomness) of the projectile. (The square root of the total distance divided by half. So, larger distances are more accurately fired.)

     

            this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)this.posX, (int)this.posY, (int)this.posZ, 0);
            for (int i = 0; i < 1; ++i)
            {

     

    This part has a for loop because the Blaze can fire three fireballs at a time, but it's not needed in this case.

     

                EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.worldObj, this, d0 + this.rand.nextGaussian() * (double)f1, d1, d2 + this.rand.nextGaussian() * (double)f1);
    

     

    This is the important part. This sets the x,y,z vector of the projectile, it uses the distance numbers calculated above, times a random number. (Because the Blaze fires randomly), you can take out "this.rand.nextGaussian() * (double)f1" and the projectile will always hit you dead on.

     

                entitysmallfireball.posY = this.posY + (double)(this.height / 2.0F) + 0.5D;

     

    This is where the projectile starts, the 0.5 is added to half the height to place it near the mobs mouth area.

     

                this.worldObj.spawnEntityInWorld(entitysmallfireball);
            }
        }

     

    Done. My class extends EntitySkeleton and nothing but this method is in it. I spawned it in, and now I have a skelington that shoots (Inaccurate) fireballs instead of arrows.

     

  4. Well, then you have to make Baubles a dependency. This is how I do it. Delete the API folder from your mod, instead, add the built jar of the mod to your build.gradle dependencies block. This will add it to your classpath when building. If you run gradle --refresh-dependencies (I think that's the command.) it should add the jar as an external library in your dev environment (if not add it manually). Make sure your ide has the jar set to "do not compile" or "provided". Then link the library to the source or dev jar (so you can see the code inside your ide.), lastly, add the dev jar to your run/mods folder. If there is no dev jar, you can put the built jar and CCC in run/mods instead.

  5. This works for me, put it in your item class.

     

        @Override
        public void onUpdate(ItemStack itemStack, World world, Entity entity, int slot, boolean inHand)
        {
            if (!world.isRemote && entity instanceof EntityPlayer)
            {
                int damage = itemStack.getItemDamage() + 1;
                if (damage >= 600)
                {
                    EntityPlayer player = ((EntityPlayer) entity);
                    player.inventory.setInventorySlotContents(slot, new ItemStack(Blocks.diamond_block));
                }else{
                    itemStack.setItemDamage(damage);
                }
            }
        }

×
×
  • Create New...

Important Information

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