Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

_vertig0

Members
  • Posts

    45
  • Joined

  • Last visited

Everything posted by _vertig0

  1. I made a mod to remove the combat cooldown system on my Forge Server: But I always get disconnected immediately with this whenever I join:
  2. Oh my god the solution was so f*cking simple... literally this code was all that was needed to stabilise the render Entity: @SubscribeEvent public void onView(CameraSetup event) { if(event.getEntity() == view) { System.out.println("Util entity " + event.getEntity().getName() + " set as camera viewport"); event.setPitch(90.0f); event.setYaw(180.0f); } } //Stabilises the camera every frame I am happy and infuriated that the fix was so simple!! But again, thanks so much for the help, really appreciate it
  3. I tried with a simple setup, didn't work, same result Curiously however, putting this line in a method that's called every frame: if(view.rotationYaw > 360) view.rotationYaw -= 360; if(view.rotationYaw < 0) view.rotationYaw += 360; Drastically reduces the mad spinning to a much gentler although still choppy camera snapping. But that's still not enough, it has to be completely still I don't know how to use github but I could put it here. It's a very smallish mod with only 3 classes
  4. I can only try testing it tomorrow, but I have a bad feeling that it only works if you properly spawn the entity, meaning actually add it to the world, and you can't just do Entity entity = new Entity(); and get away with it like that. I really hope that's not the case
  5. I did kind of have doubts for the isMultiplayer Boolean from the start since I heard from other forge threads before I started trying to make a mod that it's highly unreliable, so I didn't use it in any part of the mod (Fortunately I didn't have to use it after all) I'd heard from another thread that while the renderer Minecraft uses can take any kind of living entity as the renderViewEntity, it would always cast the renderViewEntity to an EntityPlayer, and there was no instanceof Check at all. I thought this possibly could be the solution, but EntityOtherPlayerMP and EntityPlayer SP just crashed my game when I attempted to use it, and all the other types of EntityPlayer (I wonder why there are so many honestly) cannot be instantiated. I extended EntityPlayer eventually, but in the end got the same spazz camera result It does work but I'll take that advice, thanks! (Maybe this could be the solution, who knows?) Sure, I'll try that and get back with the result
  6. Got the video: (Had to upload as a youtube video) Here are all my classes: package com.snipermod.forgeclient; import org.lwjgl.input.Keyboard; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemBow; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @Mod(clientSideOnly = true, name = ArrowDirector.MODNAME, modid = ArrowDirector.MODID, version = ArrowDirector.VERSION, acceptedMinecraftVersions = ArrowDirector.ACCEPTED_MINECRAFT_VERSIONS) public class ArrowDirector { public static final String MODID = "forgeclient"; public static final String VERSION = "1.0"; public static final String MODNAME = "snipermod"; public static final String ACCEPTED_MINECRAFT_VERSIONS = "[1.11.2]"; boolean overhead = false; @Instance public static ArrowDirector mod; public KeyBinding key = new KeyBinding("Toggle Key", Keyboard.KEY_G, "key.categories.misc"); public static final boolean isMultiplayer = !Minecraft.getMinecraft().isSingleplayer(); @EventHandler public void init(FMLInitializationEvent event) { System.out.println("Initialising Forge Mod"); ClientRegistry.registerKeyBinding(key); MinecraftForge.EVENT_BUS.register(new MEventHandler()); Minecraft.getMinecraft().mouseHelper = new ForgeMouseWrapper(); } public static boolean hasBowEquipped() { return Minecraft.getMinecraft().player.getHeldItemMainhand().getItem() instanceof ItemBow; } public void update() { if(ArrowDirector.hasBowEquipped() == false) { Minecraft.getMinecraft().setRenderViewEntity(Minecraft.getMinecraft().player); this.overhead = false; if(Minecraft.getMinecraft().mouseHelper instanceof ForgeMouseWrapper) { ForgeMouseWrapper forgeMouse = (ForgeMouseWrapper) Minecraft.getMinecraft().mouseHelper; forgeMouse.isPlayerRotationDisabled = false; } } ForgeMouseWrapper forgeMouse; if(Minecraft.getMinecraft().mouseHelper instanceof ForgeMouseWrapper) { forgeMouse = (ForgeMouseWrapper) Minecraft.getMinecraft().mouseHelper; } /* To do in the code block in this area: * Update the Camera position on mouse move * Update target location * Restrict any movement if the bow is not pulled or is pulled * too little to launch an arrow * Do NOT allow mod to perform calculation if arrow will not launch */ } } package com.snipermod.forgeclient; import java.util.UUID; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public class ClientViewPlayer extends EntityPlayer { public ClientViewPlayer(World world) { super(world, new GameProfile(UUID.fromString("41C82C87-7AfB-4024-BA57-13D2C99CAE77"), "[Minecraft]")); } @Override public void onUpdate() { return; } @Override public void onLivingUpdate() { return; } @Override public void onEntityUpdate() { return; } @Override public boolean isCreative() { return false; } @Override public boolean isSpectator() { return false; } } package com.snipermod.forgeclient; import org.lwjgl.input.Mouse; import net.minecraft.util.MouseHelper; public class ForgeMouseWrapper extends MouseHelper { boolean isPlayerRotationDisabled = false; int secretMouseX; int secretMouseY; @Override public void mouseXYChange() { if(!isPlayerRotationDisabled) { super.mouseXYChange(); } else { this.secretMouseX = Mouse.getDX(); this.secretMouseY = Mouse.getDY(); } } } package com.snipermod.forgeclient; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; public class MEventHandler { private final ArrowDirector instance = ArrowDirector.mod; ClientViewPlayer view = null; @SubscribeEvent public void onKeypress(KeyInputEvent event) { if(instance.key.isPressed()) { if(ArrowDirector.hasBowEquipped() == false) return; if(!instance.overhead) { if(view == null) { view = new ClientViewPlayer(Minecraft.getMinecraft().player.world); } view.setLocationAndAngles(Minecraft.getMinecraft().player.posX, Minecraft.getMinecraft().player.posY + 10.0D, Minecraft.getMinecraft().player.posZ, Minecraft.getMinecraft().player.rotationYawHead, 90); view.world = Minecraft.getMinecraft().player.world; Minecraft.getMinecraft().setRenderViewEntity(view); } else if(instance.overhead) { Minecraft.getMinecraft().setRenderViewEntity(Minecraft.getMinecraft().player); } instance.overhead = !instance.overhead; if(Minecraft.getMinecraft().mouseHelper instanceof ForgeMouseWrapper) { ForgeMouseWrapper forgeMouse = (ForgeMouseWrapper) Minecraft.getMinecraft().mouseHelper; forgeMouse.isPlayerRotationDisabled = instance.overhead; } } } @SubscribeEvent public void onTick(ClientTickEvent event) { if(instance.overhead) { instance.update(); } } } For the life of me I can't figure out what's wrong. Nothing else is malfunctioning in the mod, everything works smoothly- Except for the spazzing out camera feed
  7. The strange part however is that it's verifiably not the zombie's head that's spinning all over the place. A quick coordinates check reveals that the zombies head is always facing 90 degrees downwards and is yawed at 0, and these values don't change at all. It's not that I'm changing the renderViewEntity every frame either, I instantiate the zombie once and that's it. The toggle button only fires once per press (I confirmed it by adding debug messages) I even made the mod disable my mouse to make sure it wasn't a problem with the mouse and the view was still spazzing all over the place. I'll try to get a video tomorrow when I have my PC available
  8. oh well, basically i didn't use a GUI at all because i deemed it too much of a hassle, so i just set the renderViewEntity to Client Side Zombie and had that as a camera until the player hit the "G" key and set their view back to the normal player vision (By right the mod is supposed to be toggleable between a constant video feed from a camera elsewhere and the normal player vision). But it just spazzed out when the renderViewEntity was set to a Zombie. Tried this on both on singleplayer world and on a server (I chose Mineplex out of convenience). In both cases the zombie definitely spawned as I got it's viewpoint, but then it spazzed out like mad. Interestingly when I looked at where I was supposed to be from the camera as it spazzed out (As in the physical player) I could only see my shadow, the player model itself was gone
  9. I just tried with a zombie and it friggin worked!! But then after 1 second the camera started just spazzing out. Do you happen to know what could cause this?
  10. Hmm, you just gave me an interesting idea. Is there a way to spawn entities entirely client side only? I mean, if this was single player it would be easy, but if the client the mod is installed on was connected to a server, can the mod spawn a mob that only exists on the client, but not on the server? If so, I could just set the renderViewEntity field in the Minecraft class rather than having to go through the trouble of Framebuffers in the first place
  11. What I managed to figure from this is: 1. On Client Start: Create a Framebuffer 2. Every time the update method for the GUI is called: Call bind method on my own framebuffer Call the minecraft render method with custom camera coordinates and pitch yaw values Bind back the default minecraft framebuffer before all hell breaks loose and graphics start spazzing out Collect image captured on my framebuffer Draw image on GUI and profit (Draw your quad does refer to drawing on the GUI, right?) And this way I don't have to touch any matrices at all?
  12. Nice! Thanks for helping with that. I've stopped trying to use direct LWJGL classes and GlStateManager to create the camera and I'm now looking at the Minecraft Source for how the In Game Camera works... Strangely only one class holds the x, y and z values for the Camera but numerous classes, including several mobs and the player class itself contain the pitch and yaw variables for the camera. And the Minecraft class contains a variable called renderViewEntity, which is the mob the camera is in, while another class named RenderSorter has a baseEntity field which also contains the entity the camera is in... Looks like I have some digging to do. I'll get back with the results after trying Edit: Blimey, Eclipse broke down for the third time this week. Well that sucks
  13. So the creation of the Matrices must happen every time the draw method is called? So if I got that right I just have to make an identity matrix or a blank one and then call the draw method (Framebuffer method?) and Minecraft will do the rest for me? Edit: Could you give a bit of a code demo since I'm getting a little confused here
  14. @Override public void initGui() { super.initGui(); GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); GlStateManager.matrixMode(GL11.GL_PROJECTION); FloatBuffer projection = GLAllocation.createDirectFloatBuffer(16); GlStateManager.getFloat(GL11.GL_PROJECTION_MATRIX, projection); GL11.glLoadMatrix(projection); GlStateManager.matrixMode(GL11.GL_MODELVIEW); //GL11.glLoadMatrix(View Matrix???); } Managed to use the default Minecraft projection Matrix (In FloatBuffer form since LWJGL apparently only supports that and not the actual Matrix itself) as the projection matrix for the custom Camera using a bit of a hack, but how would I create the View Matrix? The View Matrix defines the Camera position and rotation as you said, so I can't just take the default Minecraft View Matrix and slap it into the Camera as I want to set it at a specific position and control it's movement as well. (Also tried looking for the LWJGL Matrix Methods and found none :((. All I found were Matrix4f in LWJGL and Minecraft's own personal Matrix4f class)
  15. Ah, I think you misunderstood what I said. I know the matrix and viewport are 2 different things, I was asking what the 4 parameters in the viewport function stood for. I am aware the matrix is the one responsible for the transformation logic and all that. I apologize for that. But if I guess correctly, the 4 int parameters in GlStateManager.viewport() are the 2D x-y coordinates for the on screen rectangle? So following that, if I want the whole screen to be captured on the camera, I put the coords of one extreme side in the first 2 parameters, and the coords of the other point at the extreme end Also by drawing entry method do you mean the method that renders to the Framebuffer?
  16. I did try all that and unfortunately got stuck at the first part. I went and joined a world, marking my location. I saved it as coordinates in the mod (double type variables), but set the Y-Coordinate to 30 blocks higher than where I was, and saved pitch as a 90 degree face down value (The Camera is supposed to be pointing directly downwards), and then I went back to the mod... And got stuck on pretty much the first OpenGL function The GlStateManager class gives 4 parameters for the viewport function, all integers. I've no clue on what these are supposed to mean (Can't be coordinates, that's the View Matrix as you said earlier) Also if I'm not wrong that would be the point if this were a full fledged game where normally you would draw the graphics onto a display, right? Except this time it's on a Framebuffer? And if I want to move the Camera I have to constantly update the ViewProjection Matrix? Sorry for the constant annoying question. This isn't my forte
  17. I think i get what you're saying, draw a rectangle using the GL helper methods, and with the above methods collect the area which is to be rendered, then transfer it using something called a FrameBuffer to the GUI? I think I could do my own homework, but one question, what is a FrameBuffer? I haven't done any rendering at all so am completely clueless on this
  18. Been googling a while on this one but got no help whatsoever. I know you can create another viewport and render it onto a GUI that the player can see. But I have no idea how to create a new Camera or viewport or whatever you wish to call it and display what it captures as one continuous feed. The GUI part was ok, but the camera part is what I cannot figure out. Sorry if this is a noob question as this is my first time with Forge. It's 1.11.2 if that helps
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.