
Rui
Members-
Posts
49 -
Joined
-
Last visited
Everything posted by Rui
-
I've done this before, but it's been awhile and I can't seem to figure out how I got it to work the first time. I'm trying to look through the Biomes o Plenty source files. I made a new project with it and imported the necessary files. However, it's acting a bit strangely. http://i61.tinypic.com/6o339j.png The folders do not cascade but are all bunched together like this, and of course, it can't find the minecraft and forge files because they are not in there. I believe there was some way to simply import a file like this and look at all its contents and be able to hop around with F3 like a normal project without actually having to go through the process of making an entirely new forgegradle project. Having this mod in my testing environment is not important. All I want to do is be able to look at the files with all the convenience of Eclispe. Please do not come in and point out obvious things like "of course it won't work if you don't have forge/eclipse on there". I do have it, but it's in a separate project. If I need to set up an entirely new folder for it like I were making one for my own mod, then that's fine; I can do that. I was just wondering if there was a simpler way of doing this, because I swear I was able to do this before without having to go through all that, but I can't remember how or even what tutorial taught me that. I've searched and come up with nothing myself.
-
How do I set it to accessible if I can't access it in the first place? Edit: Nevermind, figured it out. I got the method to fire but unfortunately it didn't do anything. Thanks anyway, though.
-
Still doesn't work. if (rider != null && rider.ridingEntity != null) { if (rider.getHeldItem() != null && rider.getHeldItem().isItemEqual(new ItemStack(Items.carrot_on_a_stick))) { System.out.println("Rider is holding carrot on a stick."); Class clazz = EntityPig.class; Method method = null; try { method = clazz.getMethod("updateAITasks"); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (method != null) { try { method.invoke(pig); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Success!"); } } System.out.println("CheckRiderThread: ridingEntity set."); } } @diesieben: If you join the game on a mounted pig and are holding a carrot on a stick, you have to wait a significant amount of time before it registers and the pig starts walking. I'm attempting to eliminate the wait time.
-
Trying reflection for the first time, and something which seemed very simple eludes me. if (rider != null && rider.ridingEntity != null) { if (rider.getHeldItem() != null && rider.getHeldItem().isItemEqual(new ItemStack(Items.carrot_on_a_stick))) { System.out.println("Rider is holding carrot on a stick."); Class clazz = EntityPig.class; Method method = null; try { method = clazz.getMethod("updateAITasks", (Class) null); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (method != null) { try { method.invoke(pig, (Class) null); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Success!"); } } System.out.println("CheckRiderThread: ridingEntity set."); } } Here is the corresponding method I am trying to access from EntityPig: protected void updateAITasks() { super.updateAITasks(); } So, why is it throwing a NoSuchMethodException when I try to access the method?
-
[1.7.10] [SOLVED] ridingEntity and riddenByEntity return null
Rui replied to Rui's topic in Modder Support
code is a mysterious thing that works in mysterious ways see OP for solution -
Makes sense. How do I cancel it?
-
Can you elaborate, please?
-
Did, but nothing changed.
-
I am trying to make it so that when the player shift+right clicks the pig, the pig is unsaddled and the player gets the saddle back. This is my current code: @SubscribeEvent public void removeSaddle(EntityInteractEvent event) { if (event.target instanceof EntityPig && event.entity instanceof EntityPlayer) { EntityPig pig = (EntityPig) event.target; EntityPlayer player = (EntityPlayer) event.entity; if (pig.getSaddled() && player.getHeldItem() == null && player.isSneaking()) { player.inventory.setInventorySlotContents((player.inventory.currentItem), new ItemStack(Items.saddle)); pig.setSaddled(false); } } } Right now, the pig doesn't get unsaddled, and the player only gets the saddle if they're in creative mode. If I comment out the part adding the saddle to the player's inventory, the pig does get unsaddled.
-
[1.7.10] [SOLVED] ridingEntity and riddenByEntity return null
Rui replied to Rui's topic in Modder Support
Alright, I'm an idiot. Of course you don't put a check for the server, because then the client has no idea that you've moved. A hurr durr. New problem: For some reason if you enter the world already mounted on a pig, the pig refuses to move. It can turn, but not move. Otherwise, when you mount a pig the pig's body jerks awkwardly as it moves. I tried doing setLocationAndAngles() for the pig, but then the render wouldn't update to reflect the pig's movement and yaw/pitch. Relevant class: http://pastebin.com/q3aNZ5wq -
[1.7.10] [SOLVED] ridingEntity and riddenByEntity return null
Rui replied to Rui's topic in Modder Support
Excellent, thank you! Well, with some more testing I found that the position of the player DOES change... but the render doesn't. I don't... <i>why doesn't the render update to reflect the position</i>. Guess that means I'll have to do it myself. Um... any ideas? -
On Techne: New Model -> Base Class: Pick whichever entity you'd like to mess with.
-
[1.7.10] [SOLVED] ridingEntity and riddenByEntity return null
Rui replied to Rui's topic in Modder Support
While I'm at it, could someone tell me how to add mods to eclipse? I tried just shoving the mods into the "mods" folder, but it crashed because it couldn't find the appropriate classes. -
[1.7.10] [SOLVED] ridingEntity and riddenByEntity return null
Rui replied to Rui's topic in Modder Support
Ah, thank you for that first answer, I'll definitely change that. I can't override updateRiderPosition though. I'm kind of hacking the original pig entity with events and such, so unfortunately method overriding is unavailable for me. -
[1.7.10] [SOLVED] ridingEntity and riddenByEntity return null
Rui replied to Rui's topic in Modder Support
Made the change to check for EntityPlayerMP instead of EntityPlayer. It cuts it down to one call, but is it an acceptable way of dealing with that problem? Meanwhile, I'm having trouble actually updating the rider's position. Using setLocation and setLocationAndAngles don't seem to have any effect (other than making my computer's fans whirr). Not particularly happy about the position being coded in on the Player's side... who's wise idea was that? Anyway, if anyone can give me an idea for how to change the player's position, that would be great. -
[1.7.10] [SOLVED] ridingEntity and riddenByEntity return null
Rui replied to Rui's topic in Modder Support
Okay, so I tested out a theory and it was right. I'm not sure why, but it takes the game a moment to set the ridingEntity and riddenByEntity variables. So I made a thread specifically to wait for this change. With EntityPlayer as the parameter in EntityJoinWorldEvent it still gets called twice. Does anyone know why? -
Alright.. so... maybe this was a "duh" sort of thing, but originally I just had it so the player was passed into the method and not the pig (which was stored in a global). Upon passing the pig into the method, I was able to use setLocationAndAngles to correct the jittering. Hurrah! The player still occasionally bobs, but I'm not sure if I can do much about that. Right now I have the position update alternating with a single sleep tick so the comp doesn't go nuts while updating. ------------ SOLVED ------------- I need to update the rider's position on my new model for the pig since it is no longer in the correct area, however... Whenever I call ridingEntity or riddenByEntity, they both return null-- even while riding the entity. I have tried this with the EntityJoinWorldEvent for both the player and pig, as well as EntityInteractEvent for the player. For the EntityJoinWorldEvent I have tried it by mounting a pig, then restarting the game (so i would be mounted when I joined), and for EntityInteractEvent I of course mounted the pig once it was saddled. For some reason when the player is the object of the event, the method gets called twice, but in any circumstance the values return null when they should be returning an entity. I don't have any code yet, just a print statement to show me the result of ridingEntity/riddenByEntity in an EntityJoinWorldEvent. So, what's going on, and how am I actually supposed to detect if a pig is being ridden or if a player is riding a pig?
-
...welp, found the answer. Was not expecting it to be that simple. I have LARenderPig, which is essentially a copy of RenderPig. All I had to do was change the shouldRenderPass() method to always return -1 (instead of returning 1 when the pig is saddled).
-
http://pastebin.com/WPR8U9yT Um... yeah. I don't think there's anything more I need to say? The conditional for the pig being saddled is in the render function. Ah yes. Note that I am making a 3-D model of the saddle and not simply rendering a different skin.
-
Actually, not quite solved yet. Didn't realize this until I did some testing, but for some reason my serverside code isn't running. Main: http://pastebin.com/r5Ek7JwZ Server Proxy: http://pastebin.com/yMEHq32n Edit: Nevermind, forgot to put the super.init in the client proxy orz
-
How's that? I overrode the original model in the hashmap for entities, so I'm not sure what more I could do. Edit: Well, that is extremely bizarre. I decided to update my mod to .1240, and once I transferred the files over I could see that the back legs didn't actually have a texture. Which is WEIRD because I DID texture them, and they showed up absolutely fine on eclipse. It's only when I moved folders that that showed up. In any case, problems solved!
-
Good news: Got the proxy thing figured out! I'm surprised I was able to do it without any problem. Bad news: ... my pigs are still bipedal. Any ideas for why this is happening?
-
There isn't much to show; it's just your standard entity renderer. http://pastebin.com/WykSkZd2 Could you explain a little more what you mean when you say proxy? And where would I need to put this code? In the constructor of the class? Edit: And my model class for the heck of it: http://pastebin.com/13Ajkf50
-
Used the tutorial provided by MrCaracal and some snooping around in other mods to figure out proxies. In short: entities went in the common proxy, renderer went in the client proxy. Shocker! -------- SOLVED --------- Yup, can't get my mod to work on a server. I assume it probably has something to do with rendering being client-side only, but I'm not sure how to account for that. I tried using the @ClientSide Only tag as a quick, temporary fix, but that didn't do it either. ... inexplicably, it does work on Single player but the back legs don't seem to render. I figured the problems were probably one in the same though.
-
Hey, I only just really got started in modding, so honestly I'm not really familiar with the Minecraft code environment at all. If you have any suggestions feel free to throw them at me! And thank you for the tip on isDead!