Jump to content

Thornack

Members
  • Posts

    629
  • Joined

  • Last visited

Everything posted by Thornack

  1. I have written the following class, its a custom keybinding class that I use to zoom the players camera in. Thought Id share, to help promote figuring out cool things that may be useful to people. Not sure how good it is, please critique it if you can see anything to critique.
  2. If anyone knows of a better way to access camera fields please post below I believe my method isnt great. This method changes the zoom to whatever you want public void cameraZoom(double zoomValue){ EntityRenderer entRenderer = Minecraft.getMinecraft().entityRenderer; try { entRenderer.getClass().getField("cameraZoom").set(entRenderer, zoomValue); System.out.println(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
  3. This seems to change the zoom level of the camera. Bear in mind this is the first time im using reflection so this is just me messing around. I placed this block of code into an if statement inside a render player event EntityRenderer entRenderer = Minecraft.getMinecraft().entityRenderer; try { entRenderer.getClass().getField("cameraZoom").setAccessible(true); try { entRenderer.getClass().getField("cameraZoom").set(entRenderer, 0.;// I think the default is 1, a negative number flips the camera view a higher number zooms in } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); }; } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); }
  4. I think this is where I have to start but again I am not sure EntityRenderer entityRenderer = Minecraft.getMinecraft().entityRenderer; entityRenderer.getClass();
  5. I have just been looking into reflections as I have never used them. I am not sure how to approach this, since I dont know how the EntityRenderer works. The fields to change the camera view, angle, rotation, pitch etc etc are all private. I know that I need to use reflection on an object of the EntityRenderer class but I am not sure how to get the object of this class so that I can apply reflection to it. Any ideas?
  6. Yikes it seems everything I would need to change to do custom camera movements is private, I havent used reflections yet.
  7. I realized that it isnt a packet problem the onRenderPlayer.pre event only fires when player is not in first person
  8. Even weirder I created two keys one which sets a boolean to true and one which sets that same boolean to false (the boolean is playerIsInFirstPerson). For some reason when im in third person and I want to go to first person (i do a check for my boolean to be false) and if the boolean is false the view should change from third person to first person - this updates the view perfectly fine when I set the boolean and it updates my view no problems. However the weird problem occurs in reverse if I am already in first person and want to go to third person (i do this by clicking the key to set the boolean to true) -the boolean gets set to true on both client and server but the view doesnt update.. I have to click the F5 key to force it to update and then after that it is fine.
  9. I guess I would need a packet to update the server
  10. Ya I find that weird also, Do you know where the actual calculation for the camera position occur after F5 has been pressed. I cant seem to find it. I tried to put the following into my RenderPlayerEvent.Pre pre event to force the view to be third person only when I become my new model and the view doesn't change unless I hit F5 then it changes and remains stable. which is weird. @SubscribeEvent public void onRenderPlayerPre(RenderPlayerEvent.Pre pre) { //my code for becoming my other model is here //just for testing if (pre.entityPlayer.worldObj.isRemote) { Minecraft.getMinecraft().gameSettings.thirdPersonView = 1; } }
  11. Hmm Ya thats what I tried also but im in 1.7.10. I found this in the vanilla code /** * Runs the current tick. */ public void runTick() { //.... A lot of stuff... then this if (this.gameSettings.keyBindTogglePerspective.isPressed()) { ++this.gameSettings.thirdPersonView; if (this.gameSettings.thirdPersonView > 2) { this.gameSettings.thirdPersonView = 0; } } //...Alot more stuff....
  12. That is where it is registered yes but where is the logic that says (whenever this key is pressed change the view of the camera)
  13. Do you know what package the actual code for toggling the camera perspective is in. I found in the game settings the registration for the key this.keyBindTogglePerspective = new KeyBinding("key.togglePerspective", 63, "key.categories.misc");
  14. Ya I have seen that thread and I have read through it, I couldn't replicate their results. I have tried the third person view suggestion you made and ran into the same problem where the player seems to hover weirdly
  15. Hi Everyone I have been researching how to change the camera (things like zoom, camera height, position, yaw, roll, pitch etc etc) and have found very little information about it. Apparently it is fairly difficult. I was wondering if anyone has any experience in this. I want to do some custom camera manipulation (force third person and change the zoom level and camera positions) and also I want to force third person view. I currently have figured out how to change the players model (dont know how to change hitbox yet but im working on that) and I need a way to force the camera view to be always third person when the player has this different model and to have a different zoom than the default since my model is fairly large. Does anyone know where to look/ how to achieve this/has any input?
  16. Hi, I have been looking at doing custom things with the players view (third person, first person etc etc... Currently this is a huge pain and could be an awesome thing for all modders to use if we were to have a forge hook into this. Im not sure if this is the correct forum to post this, please let me know if I am wrong but it would be awesome to have such a tool. Where we could fairly easily control the camera x,y,z position, zoom, viewpoint, player eye height, and all that.
  17. I have a button that appears in a HUD GUI after a key is pressed. this button is clickable and works. I want to make this button open up the players inventory and disable the "E" key for opening inventory that way. I have tried the following in my GUI button class but this didnt work. Anyone know how to open the players vanilla item inventory using a GUI button. @Override protected void actionPerformed(GuiButton button){ f(button.id == BUTTON_ITEM_ID){ System.out.println("open item inventory"); // this outprints when I click my button but no inventory opens EntityPlayer player = Minecraft.getMinecraft().thePlayer; //Client side player player.inventory.openInventory(); } }
  18. I know how to add click-able buttons, but how do you change the texture of buttons in a GUI? heres a gui class that adds some buttons that have custom widths
  19. THANK YOU THANK YOU THANK YOU That did the trick the UUID now persists!!!!! [EDIT] Also, that fixed the problem where the UUID was changing when I hovered over the itemStack with the mouse. Now the same UUID is displayed to the consol every tick the mouse is over the item
  20. I did some more debugging by insterting System.out.println("Entity write UUID" + this.getUniqueID().getMostSignificantBits()); to every NBT method right after the entity is written to NBT and I also inserted System.out.println("Entity read UUID" + this.getUniqueID().getMostSignificantBits()); after every read method. I found that the entityUUID persists right up until the point where the itemstack is used as a spawn egg to "respawn" the entity at which point it changes. Furthermore for some reason when I mouse over the item in the inventory I get Entity read UUID-2590020052499871580 Entity read UUID230231760567025764 Entity read UUID5738625593234114913 ... and so on where it seems that the read Entity from NBT method is called on mouse over for some reason. @Override public void readEntityFromNBT(NBTTagCompound nbtCompound) { super.readEntityFromNBT(nbtCompound); System.out.println("Entity read UUID" + this.getUniqueID().getMostSignificantBits()); //I read stats here } @Override public void writeEntityToNBT(NBTTagCompound nbtCompound) { super.writeEntityToNBT(nbtCompound); System.out.println("Entity write UUID" + this.getUniqueID().getMostSignificantBits()); //I write stats here } This is what is out printed to the consol from the moment I use a spawn egg to spawn my custom entity into the world for the first time to the moment I release the entity into the wild after it has been hit by my impactEntity ,captured, and converted into an itemstack and the UUID persists until I use the item that was generated to release the entity into the world. I included the methods I use to spawn the entity. Once these methods are called the uuid stops persisting and I am not sure why, or what the problem is.
  21. After looking into this further, my stats are based off of a random number generator and they persist throughout the entire capture/item/spawn process I described above. As such do you think it would work if I created my own UUID as part of my stats generation class and save that as NBT and then each time I create my new instance of my custom entity would it be possible to set my ID to be the id of the newly spawned entity (replace them somehow). Is this possible?
  22. Hmm that is weird because I save my entities stats to NBT and those persist
  23. Im going to try to implement my own uuid system in a class that persists even while the entity is deadn then populate my entity with the uuid as data amd get the entity from that id at the later time. HHopefully this works.
  24. Hi everyone I want ro create my own custom event that gets triggered by a custom action in game. I know it is possible to do this by extending the Event class. But i have zero experience in doing this i was wondering what are the key things to keep in mind when trying this. Do i need to register the class some how? Any specifics i need to remember to do? Anyone know of any tutorials that would explain the concepts needed? I understand how to use the existong events and how to register them to the correct bus but what is required for creating a custom event that is fired at a custom time/custom on game action?
  25. Using my entities onUpdate method @Override public void onUpdate(){ super.onUpdate(); if (!this.worldObj.isRemote) { System.out.println("UUID is:" + this.getUniqueID().getMostSignificantBits()); } } UUID is:-2866414455432394955 - when the entity is first spawned into the world (before capture process) UUID is:-2028361691453110800 - after the capture process and after i release it from my itemstack UUID is:5188495526038618792 - after recapture and rerelease so the UUID is not being preserved like I said - I tried it both on client and on server (changed the worldObj.isRemote) to be true and to be false and I get the same result for both, the UUID changes.
×
×
  • Create New...

Important Information

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