Jump to content

Lucius Q. User

Members
  • Posts

    25
  • Joined

  • Last visited

Posts posted by Lucius Q. User

  1. I am trying to use a particle to draw a beam from the player to the target. Instead the particle a good distance from both the player and the target:

    The code:

    	@Override
    	public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX,
    			float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
    		Vec3d lookVec = Helpers.getEntityLook(Minecraft.getMinecraft().player, 1).eyePosition;
    		drawBeam(buffer, origin, target, lookVec, 2);
    
    	}
    	public static void drawBeam(BufferBuilder buffer, Vec3d S, Vec3d E, Vec3d P, float width) {
    		Vec3d PS = S.subtract(P);
    		Vec3d SE = E.subtract(S);
    
    		Vec3d normal = PS.crossProduct(SE).normalize();
    
    		Vec3d half = normal.scale(width);
    		Vec3d p1 = S.add(half);
    		Vec3d p2 = S.subtract(half);
    		Vec3d p3 = E.add(half);
    		Vec3d p4 = E.subtract(half);
    		int brightness = 240;
    		int b1 = brightness >> 16 & 65535;
    		int b2 = brightness & 65535;
    		buffer.pos(p1.x, p1.y, p1.z).tex(0.0D, 0.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();
    		buffer.pos(p2.x, p2.y, p2.z).tex(1.0D, 0.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();
    		buffer.pos(p3.x, p3.y, p3.z).tex(1.0D, 1.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();
    		buffer.pos(p4.x, p4.y, p4.z).tex(0.0D, 1.0D).lightmap(b1, b2).color(255, 255, 255, 128).endVertex();
    
    	}

     

  2. 39 minutes ago, Animefan8888 said:

    Ok. So the thing is that even when you are playing in singleplayer there is still a server. In Minecraft we have both physical and logical sides. Meaning that singleplayer both has a server and a client, and Multiplayer is separated physically between server and client. So I suggest just telling the player that the block(s) that s/he selected are wrong and which ones they selected are wrong.

    Sigh.

    1. I know about sides, thanks.

    2. The question is: If a certain kind of packet is recieved on a server, then either the mod has a bug, or the client is hacking. What should i do in such situation. 

     

    I edited the OP to make it more concise. 

  3. If a certain kind of packet is recieved on a server, then either the mod has a bug, or the client is hacking. What should the server do in such situation? Kick the player from server? Tell the player in chat that a error occured? Something entirely different?

  4. I did enable it. The problem is not that it is not cutting anything, but rather that it cuts too much.

     

    EDIT:

    The problem is as follows:

    drawRect(...)// <- gets drawn

    setUpStencil(...)

    drawRect(...) // <- gets cut entirely (should get cut only partially)

    disableStencil()

    drawRect(...) // <- gets drawn

  5. EDIT: I switched to using scissor test.

    I am trying to set up stencil buffer to cut everything that gets drawn outside of a specific rectangle in the gui. Instead, everything that is drawn after the stencil buffer is set up gets cut;

    Here is the stencil set up code:

    public static void setUpStencil(int left, int top, int right, int bottom) {
    	if (left < right) {
    		int i = left;
    		left = right;
    		right = i;
    	}
    
    	if (top < bottom) {
    		int j = top;
    		top = bottom;
    		bottom = j;
    	}
    	Tessellator tessellator = Tessellator.getInstance();
    	VertexBuffer vertexbuffer = tessellator.getBuffer();
    	GL11.glEnable(GL11.GL_STENCIL_TEST);
    	GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF);
    	GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_REPLACE);
    	GL11.glStencilMask(0xFF);
    	GL11.glDepthMask(false);
    	GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
    	vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
    	vertexbuffer.pos(left, bottom, 0.0D).endVertex();
    	vertexbuffer.pos(right, bottom, 0.0D).endVertex();
    	vertexbuffer.pos(right, top, 0.0D).endVertex();
    	vertexbuffer.pos(left, top, 0.0D).endVertex();
    	tessellator.draw();
    	GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); 
    	GL11.glStencilMask(0x00);
    	GL11.glDepthMask(true);
    }

    Here is the actual drawing code:

    drawDefaultBackground();
    setUpStencil(20, 20, width - 20, height - 20);
    drawRect(0, 0, 50, 65); //Some drawRect calls here

     

  6. Hi, everyone!

    I am currently writing a mod that has a "Laser gun", that when right clicked shoots a (potentially very long) beam. I have two questions about how to draw said beam.

    1. Where should i put the beam drawing code? Create an EntityFX for it, somehow do it in the Item renderer itself (if so, than how?) or do arcane magicks with TESRs?

    2. I want the beam to originate in a specific place of the gun's model. How do i convert the the "muzzle's" coordinates from model's coordinate system to world coordinates?

×
×
  • Create New...

Important Information

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