Jump to content

Knifesurge

Members
  • Posts

    14
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Waterloo, ON, Canada
  • Personal Text
    Just starting to learn!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Knifesurge's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I'm not a master of Java but I know my way around the language. I actually didn't think of that tbh... I feel dumb. Cuts down on code, thanks! (I like the pic ) Also, I've only been learning Java for about 4 months so cut me some slack ;P When I say I know Java, I mean that I can work through the code and stuff. I don't know everything yet but I'm still learning as I go
  2. :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D Omg it finally works! I set some debug System.out.println() to see if it it reaches where I want it to, but everything worked out fine. Then I thought, EntityItem has a way more extensive onUpdate() method/event than my SpecialEntityItem did. So I copy pasted (probably not the best thing to do but it gets the result I want) the rest of it. I noticed this little piece of code that is in the vanilla EntityItem onUpdate(): if (!this.worldObj.isRemote) { this.searchForOtherItemsNearby(); } However it is a private method that if you implement into the class, you need more methods which lead to a dead end (at least for me). So, I commented it out and Voila! it works. It drops the Blaze Rod, it acts as a vanilla Blaze Rod, and when it hits water, it "changes" into my cooledBlazeRod. It does everything I want it to do at the moment. onUpdate() in SpecialEntityItem onEvent(EntityJoinWorldEvent event) in my EntityJoinWorldEventHandler class Thank you everyone for their help. It has been a very interesting lesson ;D
  3. Changed my EntityJoinWorldEvent method in my EntityJoinWorldEventHandler to this, like d7 suggested to do (adding NBTTagCompound): if(((EntityItem)event.entity).getEntityItem().getItem() == Items.blaze_rod) { event.setCanceled(true); SpecialEntityItem entityItem = new SpecialEntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, ((EntityItem)event.entity).getEntityItem()); NBTTagCompound nbt = new NBTTagCompound(); event.entity.writeToNBTOptional(nbt); entityItem.readFromNBT(nbt); event.entity.worldObj.spawnEntityInWorld(entityItem); } The Blaze Rod now drops like a regular blaze rod, however, I cannot pick it back up, and just "bounces" in the same spot(looks like it is dropping after a 2 second delay where I dropped it). It also, in contact with water, does not do anything. Any suggestions as to why this is?
  4. What would I need to do for this to work and where would I put it?
  5. Trying it out, doesn't crash :3 also, whenever the event (EntityJoinWorldEvent) is triggered, I'm getting the same problem as perromercenary00 did, where it says "Item entity x has no item?!", where x is a number. As well, whenever I drop the blaze rod, I instantly pick it up. Not really sure what to do about that but everything else seems to work fine
  6. Was just going to add an edit to my last post but the post quickly became fairly lengthy. So... I'm having problems when my event is fired. It completely crashes the game, giving me this error (put it in Pastebin to save room on this post) http://pastebin.com/EA2vQCxS (and by crash I mean the game still runs but nothing can happen) I honestly have no idea what is going wrong. But I'll post the code on Pastebin as well so you guys can maybe find what is going on. SpecialEntityItem: http://pastebin.com/fLNXCvBs EntityJoinWorldEventHandler: http://pastebin.com/ES9A2igD (this one is just how I register the events so will just be a code block): public void registerEventListeners(){ //DEBUG System.out.println("Registering Events"); //Register Events MinecraftForge.EVENT_BUS.register(new EntityJoinWorldEventHandler()); MinecraftForge.EVENT_BUS.register(new FillBucketEventHandler()); //MinecraftForge.EVENT_BUS.register(new PlayerDropsEventHandler()); } (It is called from the following method): @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); Recipes.addRecipes(); SmeltingRecipes.addRecipes(); registerEventListeners(); } Honestly I'm not sure what's going on
  7. Can your WaterEntityItem just be my CooledBlazeRod class or does that not work? EDIT: Going to try it with it. Honestly, it probably should work. Unless I'm missing something... EDIT: Instead I made a new class called SpecialEntityItem, which actually spawns the CooledBlazeRod, and is called by the EntityJoinWorldEvent handler, which just @SubscribeEvent the event. Testing now to see if it all works
  8. I am quite aware of your post at the start of the thread. I keep asking questions because honestly this is my first time spawning items and using event listeners/handlers and I've only been modding for about a month (everything before this has been pretty basic. Create Item/Block. Model it. Apply textures. All the basic stuff). Thank you. Finally someone points out I am pretty confused on what to do for this. This is why I came here; to get unconfused. Pretty much everything here that has been suggested to do I've encountered for the first time, simply because this is my first time doing this kind of stuff. And yes, I do know Java ;P Alright I get this, let me clear some stuff up for myself so it doesn't cause problems later down the road. How would I go about doing this? My idea is: if(entity instanceof EntityItem){ if(EntityItem == Items.blaze_rod){ entity.setDead; //spawn specialEntityItem } } But for some reason that looks wrong.. Also, when you say: Will that SpecialEntityItem be my CooledBlazeRod class or a different class? Honestly, thanks for your help. I've actually learned quite a lot as to how to do stuff, but am still trying to grasp the concepts EDIT: Which class EXACTLY should I be putting the onEvent(EntityJoinWorldEvent event)? Should it be in its own class or somewhere else? eg, in CooledBlazeRod or something.
  9. I'll look over some documentation and tutorials and stuff for event handlers. Thanks! (I kinda feel like it was really obvious that events would be needed.. Oh well :3 ) (Thinking out loud here) Since I'm checking if the player throws a blaze rod into a water source, I could use onPlayerToss event. However, you (Draco18s) said that its fired when the item is actually tossed. So instead, as Ernio said, I could use a EntityJoinedEvent. Okay I think I'm getting the hang of this. Code would probably go like this correct?: public void onEvent(EntityJoinedWorldEvent event) { //check if entity is blaze rod //if it is, check if in water //capture coordinates //setDead //spawn cooled blaze rod at the captured coordinates }
  10. Coming back to this, where would I use this EntityJoinedWorld event exactly?
  11. I'm pretty new to Forge so would you be able to explain this AABB to me? I've seen it mentioned before but am unsure where to even find it in the vanilla code As to creating my own cauldron, I've made a new class for the cauldron, extending the vanilla cauldron and overriding some methods. I've added the following code to handle the creation of my cooled blaze rod //This is an excerpt from the onBlockActivated() event int i = ((Integer)state.getValue(LEVEL)).intValue(); Item item = itemstack.getItem(); //Turns Blaze Rod into Cooled Blaze Rod if(item == Items.blaze_rod){ if( i < 3){ if(!playerIn.capabilities.isCreativeMode){ playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, new ItemStack(ToolExpansionItems.cooled_blaze_rod)); } this.setWaterLevel(worldIn, pos, state, i - 1); } return true; } Am I right in doing this? This is honestly out of where I usually am and all of this is pretty new to me. Thanks for all the help given so far, it is greatly appreciated! EDIT: Just realilzed the above handles rightclicking the cauldron, and not throwing the item into it. So close.. /EDIT I think you want to extend EntityItem so the objects of your custom class will still count as EntityItem in vanilla code that might operate on them. Otherwise some things may break. So just create a class and extend it. Should there be anything specific in it that I would need for this not to break?
  12. Here's an update as to what I have so far: I've made a custom EntityItem class called ToolExpEntityItem, I just copy pasted the original EntityItem and changed some names around. I've @Override the onUpdate() method. I've been looking at perromercenary00's code and what they've been doing. I've looked in the original code but can't find onPlayerToss(ItemTossEvent event) so I'm assuming its a new method you've made. Despite all of this, I'm kind of stumped as to what to do now. I know I have to do something along the lines of: //Probably in onUpdate() but could be elsewhere ItemStack stack= this.getItemStack(); if(stack != null){ if(stack.inWater){ //grab the thrown entity (blazerod) this.setDead; //spawn my own cooled blazerod } } Any help is greatly appreciated!
  13. Thanks. That actually really helps. I'll try it out tonight when I have a chance. I'll probably look into some of the code (I believe I would be looking in the EntityItem class correct?) and if I have any clarification questions I'll ask them. I'm pretty new to MinecraftForge so this helps a lot. EDIT: To kill an entity I assume I would use this.isDead(true), correct?
  14. I've been looking for an answer to my question for a while. How exactly would I get an item to change (I know it "deletes" itself then spawns another where it was) when it is in water. I've read around and looked around at different things in the EntityItem code and noticed there is a inWater() method. Can I use that? Then how would I "change" the item. I would be taking a blaze rod and "changing" it into a cooled blaze rod which is an item in my mod.
×
×
  • Create New...

Important Information

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