• 0

    posted a message on [Solved] Teleport Player through Gui Button
    Quote from CosmicDan

    Block activation can happen all on the server.

    Problem here is that the OP wants it to happen in a GUI, so you need to use a packet to sync the client with server. Impossible any other way, GUI's are only client side and need to sync any world changes with server - simple as that.

    There are heaps of guides out there on how to work with packets, coolAlias's ones are probably the best - so see that and learn how to use packets. It will be simple then, just have the player GUI send a packet to server and do NO teleporting on the client side - make the server do it for you. I don't see any problem with that.

    Ah that makes perfect sense. Thanks for the info ^.^
    Posted in: Modification Development
  • 0

    posted a message on [Solved] Teleport Player through Gui Button
    Is this the same problem then? I was able to teleport dimensions from block activation but not a button press in a gui
    Posted in: Modification Development
  • 0

    posted a message on Inventory not saving in custom container
    I'm by no means an expert on this but I would think it's in the nbt.

    If it is, then here's an example from a working inventory (some things may be different)



    public void writeToNBT(NBTTagCompound compound) {
    NBTTagList items = new NBTTagList();
    for (int i = 0; i < getSizeInventory(); ++i) {
    if (getStackInSlot(i) != null) {
    NBTTagCompound item = new NBTTagCompound();
    item.setByte("Slot", (byte) i);
    getStackInSlot(i).writeToNBT(item);
    items.appendTag(item);
    }
    }

    compound.setTag(tagName, items);
    }

    public void readFromNBT(NBTTagCompound compound) {
    NBTTagList items = compound.getTagList(tagName, compound.getId());
    for (int i = 0; i < items.tagCount(); ++i) {
    NBTTagCompound item = items.getCompoundTagAt(i);
    byte slot = item.getByte("Slot");
    if (slot >= 0 && slot < getSizeInventory()) {
    setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item));
    }
    }
    }

    Posted in: Modification Development
  • 0

    posted a message on [Forge][1.6.4 - 1.8] Custom Inventories in Items and Players
    Quote from coolAlias

    Quote from Erag0n1


    So I did some research and fixed the problem. I can't find the custom slots in it though.


    I've changed the slot number a bunch of times yet I'm not getting any successes to know if I even have the right slot

    I got it to work when the player is hurt and when another entity is hurt

    Awesome, that's progress xD Can you post the code with which you are having trouble?

    @SubscribeEvent
    public void onLivingHurtEnemy(LivingHurtEvent event)
    {
    if (!(event.entity instanceof EntityPlayer)) {
    {
    System.out.println("got thus far");
    EntityPlayer player = (EntityPlayer) event.entityLiving;
    if (ExtendedPlayer.get(player).inventory.getSizeInventory() != 0)
    {
    System.out.println("your pain is noticed");

    }
    else
    {

    }
    }
    }
    }

    @SubscribeEvent
    public void onLivingHurtPlayer(LivingHurtEvent event)
    {
    if (event.entity instanceof EntityPlayer) {
    {
    EntityPlayer player = (EntityPlayer) event.entityLiving;
    if (ExtendedPlayer.get(player).inventory.getSizeInventory() != 0)
    {
    System.out.println("your pain is shared");

    }
    else
    {

    }
    }
    }
    }





    I would think that it would be a better idea to add the stats here (you mentioned using attributes, but would it be able to stack?). And pretty much just adding events that hurt mobs or take more of your damage if the slot is wearing the right item. And specific dmg/def for different items in the same slot

    In the entity living getting hurt it obviously doesn't work since it's not a player entity, but I threw it in there. I'm not sure how calculating attack bonuses would even be added. (resistance (defense) for that sake as well.)
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on Custom armor types and/or custom armor materials
    Quote from coolAlias

    Quote from Erag0n1

    Pretty much just basic resistance. Individual for the item though. And probably some attack damage as well. I haven't gotten around to testing it yet so I might know what I'm doing but im not too sure

    See, that's something totally different than what I was explaining how to do. In these cases, you could add these attributes in Item#getItemAttributeModifiers, or use custom fields, and then make sure to take them into account during LivingHurtEvent. Basically, you need to check if the entity that was hurt is an EntityPlayer, then check if that player has any items in the custom slots and apply the bonus (if you mean resistance to damage); for attack damage, check if the source of damage is an EntityPlayer, and again check if any items in the custom slots etc.

    Alternatively, you could implement the resistance as a potion effect applied while the player is wearing the item, in which case you will need to do what I was talking about earlier: call Item#onUpdate for all of your custom item slots. The downside (or perhaps balancing factor) is that then the effect will not stack with Potions of Resistance.

    So now I'm thinking I would just need to find the slots and declare if it's a certain item then give the player some sort of attribute based on the item. Not sure how to test it yet though since I've still yet to find the slots correctly.


    @SubscribeEvent
    public void onLivingHurtEnemy(LivingHurtEvent event)
    {
    if (event.entity instanceof EntityLiving && !(event.entity instanceof EntityPlayer)) {
    {
    System.out.println("your pain is noticed");
    }
    }
    }

    @SubscribeEvent
    public void onLivingHurtPlayer(LivingHurtEvent event)
    {
    if (event.entity instanceof EntityPlayer) {
    {
    System.out.println("your pain is shared");
    }
    }
    }

    I am able to find when the player or another entity is hurt :)
    Posted in: Modification Development
  • 0

    posted a message on [Forge][1.6.4 - 1.8] Custom Inventories in Items and Players
    Quote from coolAlias

    Please heed my earlier advice and spend some time learning basic Java. Google "Java can't resolve to a variable" or something like that, and you will probably find some useful information. Or you can start here: http://docs.oracle.com/javase/tutorial/java/index.html


    So I did some research and fixed the problem. I can't find the custom slots in it though.


    I've changed the slot number a bunch of times yet I'm not getting any successes to know if I even have the right slot

    I got it to work when the player is hurt and when another entity is hurt
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] Custom Inventories in Items and Players
    Quote from coolAlias
    If you followed my tutorial, then your custom slots would be located in your Extended Properties class, e.g. ExtendedPlayer, and you would retrieve them by first getting the extended properties for the player, and then accessing the inventory field in your properties, just like any other class member:
     public class SomeClass {
    public Type someField; // where Type is 'int', 'String', 'IInventory', or whatever
    
    }
    
    // elsewhere:
    SomeClass object = new SomeClass();
    object.someField = some_value;

    This is basic Java syntax, not anything specific to Minecraft modding. If you look in the tutorial, you'll see where I access the ExtendedProperties for a player several times like "ExtendedPlayer.get(player).someField", so if you named your inventory slots 'inventory', you would have "ExtendedPlayer.get(player).inventory". And there you go, you've just accessed your custom inventory and can iterate through the slots (if you stored them as an array) or access them one-by-one (if for some reason you stored each one as a separate field). If you don't understand any of the terms I've used, please please please Google them or search the JavaDocs on Oracle's website - you will be doing yourself a HUGE favor by learning the fundamentals of Java.

    Player won't resolve to a variable. and I realized after I got to the .inventory that I don't know what the actual update tick for armor requires me to do. Does it just want me to have it direct it to the slot. I was playing around having special stuff happen to normal inventory but I'm just here to update so it will read the special equip's defense/attack bonuses. I'm trying to understand this but... right now I've got it as
    @SubscribeEvent
    public void onArmorTick(PlayerTickEvent event)
    {
    if (ExtendedPlayer.get(player).inventory
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on Custom armor types and/or custom armor materials
    Quote from coolAlias

    Quote from Erag0n1

    It would work having the stats in the itemarmor file just in each item's file with changes to match?

    What stats? What exactly are you trying to do?

    Pretty much just basic resistance. Individual for the item though. And probably some attack damage as well. I haven't gotten around to testing it yet so I might know what I'm doing but im not too sure
    Posted in: Modification Development
  • 0

    posted a message on [Forge][1.6.4 - 1.8] Custom Inventories in Items and Players
    Quote from coolAlias

    Please note that most of the stuff I did in there is ENTIRELY UNNECESSARY, and I only did it out of personal preference :D The other, simpler solution I linked to above works just fine, too. I just wanted the player object to be available to me directly when handling the message, and then got a little carried away with it. It's still pretty straightforward, but choose whichever style suits you best.

    Hm. I already had a bunch of registered events set up from a while back if I ever needed them. I have a PlayerTickEvent set up and registered in commonproxy's initialize(). So that all should be fine and working. I'll continue testing but how do I check for a specific Armor slot. Like the actual lines of coding. I'm doing something majorly wrong. I was able to get slots to be checked for but I can't find the route to the custom slots
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on Custom armor types and/or custom armor materials
    Quote from coolAlias

    Quote from Erag0n1

    The effects when worn. Would it just be extending Item then and not ItemArmor

    Either should work, but there is not much point in extending ItemArmor if you are not making an Item that fits in one of the vanilla Armor slots.

    I'm pretty sure you are stuck because custom slots do not receive update ticks by default - you have to implement that yourself, which I discussed briefly here. Basically, you just need to check all of your custom slots each tick and call Item#onUpdate and Item#onArmorTick (if appropriate) on each one that has an item.

    It would work having the stats in the itemarmor file just in each item's file with changes to match?
    Posted in: Modification Development
  • 0

    posted a message on Custom armor types and/or custom armor materials
    Quote from coolAlias
    Ah, I should have realized that from your comments in my custom inventory thread :P
    So, what exactly are you having trouble with, then? Getting the custom item slots? Limiting the custom slots to only accept your specific item types (e.g. Ring only slots)? Getting your Items to have effects when worn?

    The effects when worn. Would it just be extending Item then and not ItemArmor
    Posted in: Modification Development
  • 0

    posted a message on Custom armor types and/or custom armor materials
    Quote from coolAlias
    You could take a look at a Github-exclusive tutorial I wrote about this subject. In it, I show how you can create dozens of different complete armor sets using only a single new class, and I also touch on adding new armor models.

    A new armor material is added like this, often in the main mod class outside of any methods:
     public static final EnumArmorMaterial CUSTOM_MATERIAL = EnumHelper.addArmorMaterial("MaterialName", 5, new int[]{1, 3, 2, 1}, 15);
    After the material name, the parameters are: durability, armor value for {helm, chest, legs, boots}, enchantment value. Durability is a value that gets multiplied by other things to determine the armor piece's final max damage value, but you can also just setMaxDamage(value) to whatever you want individually on each piece if you don't want to do any math.

    Sorry I should have specified more in the first post. I mean something as in pendant, ring, face, etc. So a whole different type of armor
    Posted in: Modification Development
  • 0

    posted a message on Custom armor types and/or custom armor materials
    I'm trying to create some custom armor types (such as pendant, ring, face, earring, etc) and rather than have individual items I'm trying to change my custom materials to have more options.

    Also, creating custom armor types hasn't worked out so far for me. Is there a good guide out there or does someone know what is needed? (I have searched for a while to no avail)

    Thanks ^.^
    Posted in: Modification Development
  • 0

    posted a message on [ADV] Pokemon Johto in Minecraft! ~ 1.7.2 ~ IN-GAME POKEMON NOTEBLOCK MUSIC! 375,000 DLs+ (ONLY WORKS IN MINECRAFT 1.7)
    Quote from blitzscrank

    the guy in the video added in the mod items. they werent actually there. :\

    I haven't been on this page in a long time. How's the map doing? Still getting updates? :D

    btw what happened to the sound dilemma
    Posted in: Maps
  • 0

    posted a message on [solved] onBlockActivated needs to be activated twice
    Quote from master801

    Quote from Erag0n1

    Quote from master801

    Well, you could always check if one of the player inventory slots is null (meaning it's empty), and not an armor slot either.

    So it'd have to be for every slot possible? or would I need to test if entityplayer.inventory.getFirstEmptyStack() is null or false. if that is close to right, then it's not working with all the ways I'm trying it


    Yeah, I think the second one would probably work. Notice how I said, probably. Again, I haven't done this yet, so I wouldn't know, but I'm trying to give you advice I would give myself, if I had to do this.

    I realize that :P An outside input is better than me alone though
    Posted in: Modification Development
  • To post a comment, please .