Jump to content

coolAlias

Members
  • Posts

    2805
  • Joined

  • Last visited

Everything posted by coolAlias

  1. How about PlayerWakeUpEvent - pretty self-explanatory, but currently I use LivingUpdateEvent to check if the player is fully asleep instead. InventorySlotClick event would be useful for intercepting inventory interactions, for example if you have a spell that creates magic armor that you don't want the player to be able to remove or that destroys itself if clicked.
  2. You could also try out my Structure Generation Tool - it has methods that allow you to easily manipulate things like TileEntity inventories, set painting art, add items to item frames, etc. Additionally, you'll be able to generate your structure easily at any rotation or offset. http://www.minecraftforum.net/topic/1963371-structure-generation-and-rotation-tool/ It's open source, so you can see for yourself how the methods work and copy it if you want.
  3. If you need help with KeyHandler, check out SoBiohazardous' tutorial: http://www.minecraftforum.net/topic/1798625-162sobiohazardouss-forge-keybinding-tutorial/
  4. Looks okay, but where do you add this custom AI to mobs? Entity AI 'tasks' and 'targetTasks' are both public fields, so you can add new AI through the use of Events such as EntityConstructingEvent or EntityJoinWorldEvent. If you don't know how to use Forge Events, check out my tutorial: http://www.minecraftforum.net/topic/1952901-eventhandler-and-iextendedentityproperties/
  5. Might I suggest opening a custom Gui with your Item Backpack rather than editing the base inventory gui? For an example of this, check out my tutorial on creating an Item that stores an Inventory: http://www.minecraftforum.net/topic/1949352-creating-an-item-that-stores-an-inventory/ If you want an extra inventory slot to store the item, like I see you are doing, you could store it in IExtendedEntityProperties and assign a special key to open your custom player inventory to allow access to your custom slot. If you need help with IExtendedEntityProperties, I also have a tutorial on that: http://www.minecraftforum.net/topic/1952901-eventhandler-and-iextendedentityproperties/#entry24051513 I've done this exact thing helping out some guys making a Naruto mod - they needed custom inventory slots for Sharingan Eyes, and I did it like I outlined above.
  6. DamageSource has a method getSourceOfDamage() that returns the Entity causing the damage. Use it like this in your LivingAttackEvent: if (event.entity instanceof EntityPlayer) { // Now you've got the player that is being attacked by something EntityPlayer player = (EntityPlayer) event.entity; if (event.source.getSourceOfDamage() != null && event.source.getSourceOfDamage() instanceof EntityZombie) { EntityZombie zombie = (EntityZombie) event.source.getSourceOfDamage(); // now you've got the zombie that's attacking the player, do what you'd like to it } }
  7. It worked! Thanks! And I didn't know you moved here from MCForums Great! Yeah, I just signed up with some problems of my own
  8. You also have to set a max use duration for your item, or it cannot be used. If you don't override this method, the default value from Item is 0. @Override public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; // however long your item can be used, in ticks }
  9. The OP is using that event. I think the problem is that those objects have not been set yet when he / she is trying to access them. It's similar to how you can't access worldObj in the constructor of a TileEntity because it does not get set until after the constructor. All of those fields should already be initialized in EntityJoinWorldEvent. I use it all the time to set IExtendedEntityProperty data specifically because these same objects are available for use, whereas, as you've pointed out, are NOT available in a constructor or using the EntityConstructingEvent. @OP: I'd suggest taking a look at my tutorial on using IExtendedEntityProperties - there you will find a better way to add gold as well as get it to persist across player death and such. http://www.minecraftforum.net/topic/1952901-eventhandler-and-iextendedentityproperties/#entry24051513
  10. Try using this in your EntityJoinWorldEvent instead: if (event.entity instanceof EntityPlayer) { event.entity.getEntityData().setInteger("gold", 1000); // test to see if it worked: System.out.println("Player's gold: " + event.entity.getEntityData().getInteger("gold")); } 'getEntityData()' returns the NBT Tag Compound associated with the entity, be it player or whatever. Then you can set the gold directly like that if you want. You don't need to create all those other variables in your code, such as 'theNBT'. Just use the ones provided by the parameters.
  11. I've recently been trying to update my Structure Generation Toolhttps://github.com/coolAlias/StructureGenerationTool to be compatible with multi-player; as such, I've changed to a KeyHandler and storing the Item variables in NBT. Each key press changes a variable in the item's NBT, but this is only client side. I know I can send packets, but I was hoping not to spam packets because the data is only needed when the item is used. I've been trying to send a packet from client to server onItemUse, which works, but it's too late to the party and the Item activates with the data from the previous time instead of the current data. I played around with synchronized variable and wait/notify, but it results in thread lock since the server side is waiting for the information but it can't get it until the onItemUse method is called client side, which obviously doesn't happen while the thread is waiting. Here's my item code with my failed attempts: And my PacketHandler with custom packet class:
×
×
  • Create New...

Important Information

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