• 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    I *think* I have it:

    in onBlockClicked(...), change this:
    if(world.isRemote){

    to this:
    if(!world.isRemote){
    Posted in: Modification Development
  • 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    Could you post all the code you're using?
    Posted in: Modification Development
  • 0

    posted a message on Potion Icons "not visible"
    Ok, surprise surprise, vanilla's approach works. In your Potion class, create two methods -
    public void performEffect(EntityLivingBase entity, int amplifier) //For potion effects
    public void affectEntity(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase, int par3, double par4) //For instants

    (Note: All I do is just call performEffect from affectEntity like this: performEffect(par2EntityLivingBase, par3);

    Anyway, in these methods, check for if your potion is active:

    if(this.id == DungeonsAndCreepers.combustion.id)
    {
    par1EntityLivingBase.setFire(10 * par2);
    }

    As for why Minecraft wants you to use one of it's potions, try an effect id like 28
    Posted in: Modification Development
  • 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    Ok, a few things:

    1) Try creating a new world. When you change TileEntities around, worlds can get weird.
    2) When are you reading the data?
    Posted in: Modification Development
  • 0

    posted a message on Potion Icons "not visible"
    Quote from YummyTomatoesYay

    public ResourceLocation resourceLocation = new ResourceLocation(DefaultProps.coreKey,"gui/guielements.png");

    The problem I have right now is that I don't quite understand where the icons come from and what it is. Is it the icon for the effects you get when you drink like an invisibility potion? Also, if I create my own icon, how big does it have to be? I know it's not 16x16, so is it 32x32? :o


    I *believe* you can just call that. Change the "gui/guielements.png" to wherever you have the icons. I don't know past that, so use Trial And Error

    Quote from YummyTomatoesYay

    It has no errors, but I have no clue how to test this!


    First off, why is the id 19?? Minecraft uses id's 1-23! Unless you're intentionally overriding poison, that is.

    Either way, to test the effects just do /effect @a <id> 2000, or you can give yourself a splash potion of whatever by doing:
    /give @a minecraft:potion 64 16384 {CustomPotionEffects:[{Id:<id>, Duration:4000}]}

    in the chat
    Posted in: Modification Development
  • 0

    posted a message on Potion Icons "not visible"
    Quote from YummyTomatoesYay

    Thanks! I'm still a bit confused, although I know about the overwriting methods portion but this "this" in java has always made me go nuts because I've never understood it fully. (I'll take a look into it again like right now)


    Just to address this: 'this' refers to the instance of the class that it is used in. Java devs generally use it to differentiate from a variable that's part of a function, and a variable in the class.

    Quote from YummyTomatoesYay

    For now though, I just want to create an effect that can be triggered by pressing a key. I was thinking about delving into the potion effects so that if I press the key the potion effect will activate. To do this, do I still need to know everything about potions or just the effects? Because, the mod I'm trying to make does not touch potions.


    The potion class you saw is not for the Item Potions, it's for the PotionEffects (Which gets confusing when you see that there's a class called Potion Effects =/)

    However, what you are talking about would require a key binding and some instance of the player (Which would be slightly more difficult on servers)
    But, once you have that, add a potion effect to the player via a method (I believe the method is addPotionEffect)

    Just remember - If you're not adding potion effects, you don't really need to touch the Potions class
    Posted in: Modification Development
  • 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    Quote from iTooly

    One min.. It doesnt work when I am compling the mod.. :steve_tearful:


    What error do you get? How are you compiling?
    Posted in: Modification Development
  • 1

    posted a message on Infinite Furnace Fuel
    Quote from Axe2760

    Just an idea for you to try if other things fail, I can't see why it won't work..but I'm not sure; try using -1 as your burn time, it will keep incrementing backwards but never meet the == 0 requirement


    Actually, if they're using ints, it will *eventually* reach the requirement (underflow), but it'll take a long time(Assuming we're talking ticks here, and 20 ticks to a second, you're looking at around 17 years)
    Posted in: Modification Development
  • 0

    posted a message on [Solved][Forge][1.7.2] Saving data about player when clicking block
    Ok, simple enough.

    So, in your BlockX class, you should override the method
    'public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) {}'

    Now, since Java doesn't look at function names for overriding, we can substitute normal things in:
    'public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {}'

    So, onto the problem. The sort of data you are saving is too complex to store within metadata, so we're going to need a 'TileEntity'. Simple enough, create a new class, let it extend TileEntity, and that's the TE!

    Now, by default, this won't really do much. It'll work, but you want to do some more stuff here...
    So add a new variable to TileEntityX, and it's gonna be a String. Call it 'playerName', as that's what we're gonna store right now.

    Got it? Good, now, you need to add two functions to your TileEntityX: 'public void readFromNBT(NBTTagCompound nbt)' and 'public void writeToNBT(NBTTagCompound nbt)'

    Both of these need to call their super methods (so do super.readFromNBT(nbt) for the reading, and super.writeToNBT(nbt) for the writing). These basically store the data, and allow the TE to recover it.

    After that, we need to add some content to the methods. In 'readFromNBT', add this:
    'this.playerName = nbt.getString("PlayerName");'

    For 'writeToNBT', put this:
    'nbt.setString("PlayerName", playerName);' <-- Thanks to iTooly for pointing this out xD

    Congratulations! Your TileEntity will now store data!

    But, we never really set that data, nor does our block use it...

    Quick important sidestep: You need to put this in either your preinit, init or postinit methods (or whatever they're called):
    'TileEntity.addMapping(TileEntityX.class, "modname:TileEntityX");'

    This gives the TileEntity a way to actually store it's data with the level (I believe)


    Anyway, back to the block.

    First important thing, you need to tell the game you're using a tile entity. So, to do that, let your block implement 'ITileEntityProvider'. This should require you to implement a method: 'TileEntity createNewTileEntity(World var1, int var2);'. This is pretty simple, just put this:

    'public void TileEntity createNewTileEntity(World var1, int var2)
    {
    return new TileEntityX();
    }'

    This just creates a new instance of TileEntityX when you place the block down.

    Now, remember our method at the start? Let's start populating it!

    First step is to check if we're on the client or the server. If we're on the client, we can't do anything to the TileEntity, but if we're on the server, then we can do stuff.

    So simply put: if(world.isRemote) return true;

    Then, we can get onto the fun stuff!
    So, put this after your if check:

    TileEntity te = world.getTileEntity(x, y, z); //Get the TileEntity at this location
    if(!(te instanceof TileEntityX)) return false;//If it's not a TileEntityX, then return
    TileEntityX tex = (TileEntityX) te; // Cast te to the right type
    tex.playerName = player.getCommandSenderName(); //Get's the name
    world.setTileEntity(x, y, z, tex); //Sets the tile entity at that location


    That's the fancy stuff that sets the actual string in the tile entity. Then, you can read it using very similar code:
    TileEntity te = world.getTileEntity(x, y, z); //Get the TileEntity at this location
    if(!(te instanceof TileEntityX)) return false;//If it's not a TileEntityX, then return
    TileEntityX tex = (TileEntityX) te; // Cast te to the right type
    System.out.println("See? This is their name: " + tex.playerName);


    Anyway, hope that helped.

    (Welp. lots of textz)
    Posted in: Modification Development
  • 0

    posted a message on Potion Icons "not visible"
    The issue is that Minecraft has made the 'setIconIndex' class to be 'protected'. A protected method can't be accessed from outside the package that it's in. Since you're *hopefully* not putting the class in net.minecraft.potion, you can't use the method.

    The solution to this is to override the method, or write a different one. For example, what you can do is make another method with the same name in BlockyPotion that uses a different variable, and then override the method 'public int getStatusIconIndex()' and return that variable
    Posted in: Modification Development
  • 0

    posted a message on Need Help With Programming
    Quote from SeaWry

    Java = Just a branch of C++ with a better library (bit of sarcasm).



    C-Sharp and C/C++(C11, 14, 99) are vastly different.


    Ah. Was not aware of this. Thanks for enlightening me as to this
    Posted in: Computer Science and Technology
  • 0

    posted a message on Need Help With Programming
    Quote from fm87

    There are no "branches of C". What are you even talking about?

    If you are saying something like a "branch of C" most languages are a "branch of C".

    Sorry, by "branch of C', I meant, rather, variants, like C++, C#, etc
    Posted in: Computer Science and Technology
  • 0

    posted a message on Need Help With Programming
    tbh- My view of what's easier is gonna be biased, considering I started with Java.....

    In terms of languages, what are you planning to develop for? Java's a nice one to get started with for the Computer, whereas the various branches of C are nice too (I've heard). However, if you are looking into app development, Objective C is the language for iOS app development (Including costs of a Mac, the 99/year dev program, etc)

    As for languages such as Python, Lua, Ruby, etc, I haven't had much experience with them, but I know that, often, they can get a job done much quicker then, say, a C or Java equivalent.

    As SeaWry posted though, it is better to start off fluent in one language than to be "OK" in several. So, if you start with Java, stick with Java for a while, and then, if you still want to, move on to another one, all the while continuing to practice Java. It's just like anything - You need to hone your skills otherwise you'll get rusty.
    Posted in: Computer Science and Technology
  • 0

    posted a message on [1.5.2]Would YOU be interested in a 200+ Modpack
    My computer hardly runs FTB at a decent speed atm.... a 200+ modpack wouldn't even load
    Posted in: Mods Discussion
  • 0

    posted a message on NBT saving problem
    Have you checked the actual value of the boolean? Are you sure it's a matter of it not getting loaded, or is it getting changed?
    Posted in: Modification Development
  • To post a comment, please .