Jump to content

CAS_ual_TY

Members
  • Posts

    72
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by CAS_ual_TY

  1. Yes blame the "lack of documentation". Totally not your java "knowledge". You also totally did not try to implement code that has such an obvious syntax error that someone with actual java knowledge would immediately see and be able to fix.

     

    Everything you need to do has been explained in this thread (and also the thread you linked where you stole the code from). Making this mod probably takes about 5 minutes.

    • Haha 2
  2. The main mistakes here are lack of java knowledge.

    - In your topic you create a new instance of something, but nothing is being done with it, nothing gets called because of instantiation.

    - In your last example your syntax does not work at all (as pointed out already).

     

    These are things that have nothing to do with forge documentation.

    Surely there are things you have to know beforehand, but these are all listed here (itemstacks are point 12):

     

     

    Again, if you show me how you implemented my previous suggestion(s) I can help you with it.

  3. The annotation basically tells forge "ey there is an event here". Then forge checks which parameter that method has and sends the corresponding event. Just as a simple explanation. 

     

    So you subscribe to the tick event and in there you create a new instance of invChk every single tick. And in there you dont even call the method. The annotation doesnt work in invChk since there are no method params. 

     

    Solution: add the client tick event parameter to the method in invChk instead (remove the entire thing in your mod class) and then pass an instance of said class to

    MinecraftForge.EVENT_BUS.register

  4.  These are your options listed in there. 

     

    I have given my own implementation which in the current state you can find here: https://github.com/CAS-ual-TY/Visibilis/blob/c03f6972e3dc2845dbbdcc271ba1eee5b64a2bfc/src/main/java/de/cas_ual_ty/visibilis/util/RenderUtility.java#L410 (scissor methods, feel free to use these yourself) 

     

    The only thing is that you have to account for mouse position. There is no hacky way around that, you have to do old fashion calculations. 

  5. 52 minutes ago, Animefan8888 said:

    This should be used if it has a contnainer. No reason to use it if it doesn't.

    Pretty sure I read somewhere that you should do it regardless.. But doesnt matter.

     

    OP, remember to register this event handler only on client side.

     

    Also, dont use GL11.glColor

    Use the GlStateManager instead.

  6. Here is how I would do it:

     

    - I would open the model (eg https://blockbench.net/) and add the middle card onto it. Just as a blanc quad or thin cube. Now I would move it to the other 2 slots and write down how I had to move it for that.

    - Next, I would remove everything except for the card itself, and export it. Now move the card to another slot (as written down), export. Now move it to the final slot, export.

    - Now I would take the initial card-only model again, and create copies of it with the actual textures on it. To clarify: You now have your main item model, 3 blanc card models, which all fit into a slot of your main item model, and then X models of the first card but textured.

    - Now whenever you render your item model, you also render one of the textured cards, with the transform of the correct blanc card applied for the slot.

     

    This would still require you to create 1 model per card, but no combinations needed.

     

    Or you quickly write a Programm which does all the combinations for you from a small premade template.

  7. Take a look at this thread: 

     

    I made a Gun Mod with attachments. Instead of creating all combinations each, I created the single layers and then just dynamically combined them for rendering. I am basically sharing all code here. It might help you, feel free to copy parts it.

     

    EDIT: What you could do is have 1 model for each card, and 3 models for the transforms where they can be, then combine them

    1. Make a card model of the middle card

    2. Copy the model, move it up/down and export again for the top/bottom card

    - Now you have 3 json models, all have the same data, except that their transforms are different

    3. Copy the first model again for each card and apply texture

    - Now you also have a model for each card

    4. In the rendering code, always load the model with the card texture (of step 3), but load the transform of one of the initial 3 models to get it into the right position. Do that for all 3 cards.

     

    Now only does that solve your problem, but it also lets you change everything via resource pack only.

  8. 13 hours ago, Animefan8888 said:

    First off dont post code that isnt yours here or anywhere without permission from the writers.

     

    Second when you render your image you specify where on your image you want to start at (x, y) then you specify where on the screen (x, y) then you give the width and height to the method. So if you want the image to have a scrolling appearance change where on the image you want to start.

    I removed the code you are right. I was thinking I would be posting a general concept instead of someone's code which is obviously not true.

     

    I should have emphasized it a bit more that I was looking for something the glScissor solution. I mentioned it slightly below the spoiler but I should have been more clear.

     

    10 hours ago, gendeathrow said:

    Animefan8888 is right about creating a scrolling image by changing the start,height. I wrote most of my guis like that, But if you were wanting to have a bunch of images and text and dont want to write all the logic for that. Than I have used GL Scissor to do what your asking. I've used it to draw scroll-able guis inside other guis. Anything outside the borders will get cut off. 

     

      Reveal hidden contents

    GL_SCISSOR_TEST:

     

    
    
    public drawScreen(int mouseX, int mouseY, float partialTicks){
    	GL11.glEnable(GL11.GL_SCISSOR_TEST);
    		GlStateManager.disableLighting();
        	guiScissor(mc, x, y, width, height);
        	CallYourDrawCode(mouseX, mouseY, partialTicks); 
    	GlStateManager.enableLighting();
    	GL11.glDisable(GL11.GL_SCISSOR_TEST);
    }
    
    
    // This gets the scaledResolution to get proper placement. 
    public static void guiScissor(Minecraft mc, int x, int y, int w, int h){
    	ScaledResolution r = new ScaledResolution(mc);
    	int f = r.getScaleFactor();
    	GL11.glScissor(x * f, (r.getScaledHeight() - y - h)*f, w * f, h * f);
    }

     

     

    It really depends on what you trying to do. As this can be a bit much for a simple scrolling window. You will still have to handle all the key inputs & mouse inputs. This only handles the rendering.  Also This was written for mc1.12.2.

    Thank you, this is exactly what I was looking for. The following is how I did it:

     

    /**
    	 * Cut everything off outside the given rectangle. Call this, then the all the draw code, then {@link #innerEnd()} for cleanup.
    	 * @param x Pos X of the rectangle.
    	 * @param y Pos Y of the rectangle.
    	 * @param w Width of the rectangle.
    	 * @param h Height of the rectangle.
    	 */
    	protected void innerStart(int x, int y, int w, int h)
    	{
    		GL11.glEnable(GL11.GL_SCISSOR_TEST);
    		//* scaleFactor due to the automatic resizing depending on window size (or the GUI size settings)
    		//All the derparoundery with the Y position because Minecraft 0,0 is at the top left, but lwjgl 0,0 is at the bottom left
    		GL11.glScissor(x * this.sr.getScaleFactor(), (this.sr.getScaledHeight() - y - h) * this.sr.getScaleFactor(), w * this.sr.getScaleFactor(), h * this.sr.getScaleFactor());
    		this.applyZoomAndShift();
    		GL11.glPushMatrix();
    	}
    	
    	/**
    	 * Scissor cleanup. Call {@link #innerStart(int, int, int, int)}, then all the draw code, then this.
    	 */
    	protected void innerEnd()
    	{
    		GL11.glPopMatrix();
    		GL11.glDisable(GL11.GL_SCISSOR_TEST);
    	}

    From: https://github.com/CAS-ual-TY/Visibilis/blob/bee136b8243cbd7796be3b334cf5c681d38a5347/src/main/java/de/cas_ual_ty/visibilis/GuiPrint.java#L394

    (Experimental, untested code, the entire GUI. Something could be terribly wrong, everything in this repo is only theory. I was too lazy yet to write a ReadMe pls no shame)

     

    Thanks for the help.

×
×
  • Create New...

Important Information

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