• 0

    posted a message on [1.4.6/1.4.7/1.5.2] The Hat Fortress 2 Mod: Crates, Keys, and HATS.
    Mod is slow because I'm slow. I've been trying to remove the edits to base Minecraft code, which is surprisingly difficult. I've also been working on something else (a surprise!). Release should (should, not gonna give any guarantees ._.) be this week.
    Posted in: Minecraft Mods
  • 0

    posted a message on [Forge 1.6.2] Moving an entity
    UPDATE: Fixed, I changed the event to just EntityEvent rather than CanUpdate and it's working now.

    Hi,

    I'm currently developing a mod where I need to be able to move an entity towards a specific x, y, and z co-ordinate. I'm using EntityEvent.CanUpdate to hook into the update tick for the entity, and from there I need to move it towards my co-ordinates. Here's my current code.

    @ForgeSubscribe
    public void onEntityTick(EntityEvent.CanUpdate event)
    {
    Entity e = event.entity;
    if(e instanceof EntityLiving)
    {
    	 // x, y, and z are defined elsewhere in my code and contain the correct values.
    	 ((EntityLiving)e).getMoveHelper().setMoveTo(x, y, z, ((EntityLiving)e).getMoveHelper().getSpeed());
    }
    }


    The code definitely runs once per tick for each entity, but the entity fails to move. I've also tried e.moveEntity, with the same result.

    Does anyone know how to make this work?
    Posted in: Modification Development
  • 0

    posted a message on [1.4.6/1.4.7/1.5.2] The Hat Fortress 2 Mod: Crates, Keys, and HATS.
    A new demo is out. I'm not releasing another beta since I'll be updating to 1.6.2 as soon as is possible, and releasing the mod properly once that's done.

    [media][media][/media[/media]]


    Full changelog from the last demo:

    CHANGELOG: HF 3.0 BETA 4
    - Added the following hats:
    - The Anger
    - The Advanced Cool-down System
    - The Coupe D'isaster
    - The Conjurer's Cowl
    - Le Party Phantom
    - Soldier's Stash
    - The Team Captain
    - The Wraith Wrap
    - Added the following weapons:
    - The Bat Outta Hell, Wither Skull on 2 Blaze Rods for crafting
    - The Unarmed Combat, Eye of Ender on 2 Bones for crafting
    - The Holy Mackerel, 3 paper in a row on the bottom and a column of 2 raw fish for crafting
    - Sharpened Volcano Fragment, 1 Blaze Powder on 2 Blaze Rods for crafting
    - Wrench, same recipe as iron pickaxe but replace sticks with iron ingots for crafting
    - Golden Wrench, a Wrench surrounded with golden ingots for crafting
    - Jarate, a glass bottle surrounded with Ghast Tears for crafting
    - Added the following effects:
    - Searing Plasma
    - Vivid Plasma
    - Community Sparkle
    - Anti-freeze
    - Roboactive
    - Bouncing Balloons
    - Bright Idea
    - Purple Confetti
    - Green Confetti
    - Updated the following effects:
    - Cauldron Bubbles and Bubbles (returned to MC-based particle effect)
    - Heart and Note (now circle the player properly)
    - Portal (returned to MC-based particle effect)
    - Added the Unusual Saddle, a beta animal-based unusual (they work like unusual couriers in DOTA 2, with effects on the feet).
    - Only available in Scorching form in the wild, unboxing is implemented but it cannot be unbosed yet,
    I've added a temporary crafting recipe for this version only (surround a Saddle with Magma Cream)
    - Added the Unusual Majestic Saddle, another animal unusual beta. Custom textures are the best.
    - Implemented dying without inventory loss. Play without fear of losing keys or unusuals.

    Posted in: Minecraft Mods
  • 0

    posted a message on 20 questions regarding modding with forge.
    3.1 is actually quite easy.

    If you look in minecraft.jar, under textures/blocks, there's a file called fire_0.png, and a file called fire_0.txt. Using these fire animations as an example, you can see that the fire_0 PNG has the animation on a big spritesheet (it's layed out as 16x16 squares going downwards). Make sure each frame of your animated texture is in the same format.

    Next, see fire_0.txt. It contains integers from 0 to the last frame in fire_0.png; this defines what order the animation goes through the frames in.

    Once you've made your files (let's call them liquid_0.png and liquid_0.txt), you need to add some code to your Block file for the liquid.

    Here's an example of my own:

    package com.ziddia.hf3;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IconRegister;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.util.Icon;
    import net.minecraft.world.World;
    /**
    * Placeholder class for hearts effect.
    * @author Josh
    *
    */
    public class BlockHearts extends Block {
    
    private Icon[] iconArray;
    public BlockHearts(int par1, Material par2Material) {
    super(par1, par2Material);
    }
    
    public Icon getIcon(int i)
    {
    return iconArray[i];
    }
    
    public void registerIcons(IconRegister par1IconRegister)
    {
    	 this.iconArray = new Icon[] {par1IconRegister.registerIcon("heart_0")};
    }
    
    public boolean renderAsNormalBlock()
    {
    return false;
    }
    
    public int getRenderType()
    {
    return 3;
    }
    
    public boolean isOpaqueCube()
    {
    return false;
    }
    
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
    	 return null;
    }
    
    public Icon getBlockTextureFromSideAndMetadata(int par1, int par2)
    {
    	 return this.iconArray[0];
    }
    }


    That should be fairly easy to figure out; it's just rendering it as a non-cube-shaped block that you can walk through. Change the heart_0 to liquid_0 and you're set.
    Posted in: Modification Development
  • 0

    posted a message on GameRegistry.registerItem Not Working
    Quote from Toffie_of_Truth

    public static Item itemBroadsword;
    public static Item itemKnife;
    public static Item itemSaber;
    public static Item itemSpear;


    You need to instantiate the items before you register them.


    This is the solution to your error. You're getting a NullPointerException, which means that one of the variables you're trying to reference is returning null.

    In your code, because the variables in the quote above aren't instantiated, they're null. Therefore, your registerItem calls are going to fail. Change the lines above like so:

    public static Item itemBroadsword = new Item(222).setUnlocalizedName("itemBroadsword");
    public static Item itemKnife = new Item(223).setUnlocalizedName("itemKnife");
    public static Item itemSaber = new Item(224).setUnlocalizedName("itemSaber");
    public static Item itemSpear = new Item(225).setUnlocalizedName("itemSpear");


    Just change the IDs/instantiated classes/unlocalized names as necessary.
    Posted in: Modification Development
  • 0

    posted a message on Forge Item error
    Quote from Anglican

    The main problem is actually he's calling a constructer from a method..... super(...) can't be used in a method afaik


    That may be the actual error, but the simplest way to fix it would be just to fix up his items' constructor, and so that's what I told him to do.
    Posted in: Modification Development
  • 0

    posted a message on Forge Item error
    You don't need to make a second constructor for your second item. If both are using the GemItems class, then the single constructor is fine.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]Forge Achievements: Item collection trigger?
    Quote from dev909

    Ahh right, I forgot I removed that. It works now! Kudos to you good gentleman :D .

    As an extra bonus though, do you know why the achievement page for mods is so glitchy? First achievement has a full white background, while if you scroll to the y borders, the entire gui goes white.

    I honestly have no idea. I don't work with achievements much, so I've never really noticed.

    Anyways, glad I could help! :)
    Posted in: Modification Development
  • 1

    posted a message on [SOLVED]Forge Achievements: Item collection trigger?
    You're using par1ItemStack.getItem().itemID, but it should be par1ItemStack.getItem().itemID - 256. Constructor for Items adds 256 to the item ID automatically, when comparing to your hardcoded IDs you need to subtract 256 again.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]Forge Achievements: Item collection trigger?
    Quote from dev909

    Alrighty just tried that, and didn't work.

    public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    	 {
    		 --par1ItemStack.stackSize;
    		 par3EntityPlayer.getFoodStats().addStats(this);
    		 if (berryAchCheck(par1ItemStack)) {
    		 par3EntityPlayer.addStat(modDSAch.berryAch, 1);
    		 }
    		 par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F);
    		 this.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer);
    		 return par1ItemStack;
    	 }
    
    protected boolean berryAchCheck(ItemStack par1ItemStack)
    {
    int i = par1ItemStack.getItem().itemID;
    if (i == baseModDS.blueBerryID){
    blue = true;
    }
    else if(i == baseModDS.strawBerryID){
    		 straw = true;
    }
    else if(i == baseModDS.blackBerryID){
    		 black = true;
    }
    else if(i == baseModDS.raspBerryID){
    rasp = true;
    }
    else if(i == baseModDS.cranBerryID){
    cran = true;
    }
    
    if (blue && straw && black && rasp && cran){
    return true;
    }
    
    return false;
    }


    *Edit: I added the booleans within the class, not my basemod class.


    I'd put them in the basemod class and make them static if I were you; if they're not static already, then each berry will have their own version of the variables, and only the corresponding boolean would be made true (for example, the Blueberry would change its blue boolean to true when eaten, but would never change the rasp boolean to true, because the ID of the item eaten would never equal the raspberry ID. It's the same for each of the other berries; they would change their own booleans to true, but would never change the others to true).
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]Forge Achievements: Item collection trigger?
    My approach would be something like this:

    You currently have this code for onEaten.

    public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    		 {
    				 --par1ItemStack.stackSize;
    				 par3EntityPlayer.getFoodStats().addStats(this);
    				 par3EntityPlayer.addStat(modDSAch.berryAch, 1);
    				 par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F);
    				 this.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer);
    				 return par1ItemStack;
    		 }


    The first parameter is an ItemStack. You can use this to get the item ID of the item that's being eaten:

    int i = par1ItemStack.getItem().itemID - 256;


    Note that we need to subtract 256 to get the ID you coded in for each berry, as the constructor for Item automatically adds 256 to the item ID you provide.

    Then, you can use an if-then-else to check what item ID has been eaten:

    if(i == baseModDS.blueBerryID)
    {
    	 // Blueberry code here...
    } else if(i == baseModDS.strawBerryID)
    {
    	 // Strawberry code here...
    } else if(i == baseModDS.blackBerryID)
    {
    	 // Blackberry code here...
    } else if(i == baseModDS.raspBerryID)
    {
    	 // Raspberry code here...
    } else if(i == baseModDS.cranBerryID)
    {
    	 // Cranberry code here...
    }


    Now, I'm not sure what's happening at this point. Are you assigning the achievement after every berry has been eaten at least once, or a different achievement for each berry type? If it's a different achievement for each berry type, just throw in the addStat in each if. However, if it's an achievement that requires you to eat at least one of each berry type, my advice would be to create a boolean for each berry type in your mod class:

    // this is in your main mod class
    public static boolean eatenBlueberry = false;
    public static boolean eatenStrawberry = false;
    public static boolean eatenBlackberry = false;
    public static boolean eatenRaspberry = false;
    public static boolean eatenCranberry = false;


    And then, in each of the else-if statements from before, set the corresponding boolean to true:

    // i assume baseModDS is your main mod class?
    if(i == baseModDS.blueBerryID)
    {
    	 baseModDS.eatenBlueberry = true;
    } else if(i == baseModDS.strawBerryID)
    {
    	 baseModDS.eatenStrawberry = true;
    } else if(i == baseModDS.blackBerryID)
    {
    	 baseModDS.eatenBlackberry = true;
    } else if(i == baseModDS.raspBerryID)
    {
    	 baseModDS.eatenRaspberry = true;
    } else if(i == baseModDS.cranBerryID)
    {
    	 baseModDS.eatenCranberry = true;
    }


    And finally, add a check at the end of onEaten to determine that all the berries have been eaten, and add the stat if all the booleans are true.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]Forge Achievements: Item collection trigger?
    Let's use the example achievement they made in the link you provided.

    In the Apple's onEaten method, you would use player.addStat(TimeAchieve, 1). It's as simple as adding the stat in the onEaten or onItemRightClick method.

    Like this:

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    par3EntityPlayer.addStat(MyModClass.myAchievement, 1);
    }


    Note that the achievement in MyModClass would need to be static so that you can access it outside of your mod class properly.

    edit: if this doesn't make sense would you mind posting what code you have now? It's difficult to explain without something to explain about.
    Posted in: Modification Development
  • 0

    posted a message on Serious... what is this error?
    It looks to me like you're missing the paulscode classes in minecraft.jar. Try taking a clean minecraft.jar from your appdata folder and copying the paulscode folder into the minecraft.jar in your Forge folder.
    Posted in: Modification Development
  • 0

    posted a message on Static Entities and Lag
    No way to know whether it would or not without testing it. I don't think it would, since they're (presumably) not doing anything in their onUpdate or whatever the name of the once per tick method is, but I can't be certain without it being tested.
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]Forge Achievements: Item collection trigger?
    I'm not entirely sure what you mean by a 'collect one of each item type' trigger, but as for upon use, Item.java has a method called onItemRightClick:

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {}


    However, there's no Forge or ML hook for this afaik; for each item you want to check for, you would need to implement this method in their item class. If you wanted to implement it for all items, it would involve editing base classes.
    Posted in: Modification Development
  • To post a comment, please or register a new account.