Jump to content

andGarrett

Members
  • Posts

    101
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by andGarrett

  1. 11 hours ago, diesieben07 said:

    Short-lived objects (aka "create resource location, look up in map, drop resource location") are heaven for modern Java GCs. Don't worry about it.

    so, hypothetically, something like ForgeRegistries.ITEMS.getValue(new ResourceLocation("minecraft:polished_diorite")); done a hundred times isn't a problem?

     

    14 hours ago, DaemonUmbra said:

    By "A LOT" you don't mean every tick, do you?

    actually, now that I've gone through the code again, it isn't all that much.

  2. 3 hours ago, Draco18s said:

    ForgeRegistries.ITEMS.getValue(key)

     

    I'm not sure how you couldn't find that.

     

    lol, the "key" in "ForgeRegistries.ITEMS.getValue(key)" is the ResourceLocation I mentioned here:

     

    4 hours ago, andGarrett said:

    It's possible to get an item by it's resource location

     

    unfortunately for me, I didn't write my code in such a way as to work well with converting the registry names into resource locations. I would have to create new ResourceLocations too often to be considered efficient. I may need to rethink some of my code.

  3. 22 hours ago, Draco18s said:

    Get the Item from the Registry by name.

    how? I tried "ForgeRegistries.ITEMS", but I can't find a way to get an item by it's registry name. It's possible to get an item by it's resource location, but I would much rather get it by registry name as I have a lot of code already written using the registry names.

  4. 1 minute ago, Animefan8888 said:

    Let's take a step back what exactly are you trying to do. End user perspective thing.

    I have a store block that has a screen for buying items. it will have a randomized list of items for sale. instead of using itemstacks, I am instead creating my own custom buttons that will have an image of whatever item is being sold in that slot. when clicked on, the button will spawn a popup that will allow the player to buy some of the item in question.

     

    to accomplish this, I'm creating a static list of all the resource locations for the item and block images. This can then be referenced instead of creating a new resource location each time the image is drawn like:minecraft.getTextureManager().bindTexture(new ResourceLocation("textures/item/gold_ingot.png"));.

     

    Is this what you meant by "End user perspective thing"?

  5. I need to create a static arraylist of all the resource locations of item and block images, but I don't know how. something like:

    for (String item: assets.minecraft.textures.item) {
    	recourceList.add(new ResourceLocation(item));
    }
    for (String block: assets.minecraft.textures.block) {
    	recourceList.add(new ResourceLocation(block));
    }

     

    clearly this is incorrect and wouldn't work. how might I do this correctly?

  6. here's a version of blit that makes the most sense to me and works perfectly for what I'm doing:
     

    blit(
    int xPos,		// x position relative to the screen image below it (not the entire screen).
    int yPos,		// y position relative to the screen image below it (not the entire screen).
    int blitOffset,		// z position (blitOffSet)
    float textureX,		// x position on the texture image to draw from
    float textureY,		// y position on the texture image to draw from
    int imgSizeX,		// x image size to display (like crop in PS)
    int imgSizeY,		// y image size to display (like crop in PS)
    int scaleY,		// y image size (will scale image to fit)
    int scalex)		// x image size (will scale image to fit)

     

    it's still a little confusing to use the first time. if you have something like:

    blit(10, 10, 10, 0F, 0F, 64, 64, 64, 64);

    you will end up with an image that is 64x64 that contains the entire image scaled to fit 64x64

     

    of you do something like:

    blit(10, 10, 10, 0F, 0F, 64, 64, 32, 32);

    you get an image that is 64x64 but that contains 4 copies of your image in a 2x2 grid that are all 32x32.

    • Like 1
  7. 17 minutes ago, Animefan8888 said:

    First I hope you're not doing new ResourceLocation in your actual code because you should just create it once in a static field.

    this is currently for testing purposes. once I get things working would this not be acceptable for something that would change? would I need to create a non-static field to store the changing data?

     

    23 minutes ago, Animefan8888 said:

    If I'm not mistaken there are other versions of blit that take more parameters and let you change more things. If that isn't true or satisfactory you could always use GLStateManager.scale

    you mentioned other versions of blit in another post of mine, but I have been unable to figure out how they work.

  8. is there a way to scale with blit, or do I need to use something else?

     

    here's what I'm trying to scale:

    minecraft.getTextureManager().bindTexture(new ResourceLocation("textures/item/gold_ingot.png"));
    blit(10, 10, 0, 0, 256, 256);

     

     

    [SOLUTION]

     

    Just now, andGarrett said:

    here's a version of blit that makes the most sense to me and works perfectly for what I'm doing:
     

    
    blit(
    int xPos,		// x position relative to the screen image below it (not the entire screen).
    int yPos,		// y position relative to the screen image below it (not the entire screen).
    int blitOffset,		// z position (blitOffSet)
    float textureX,		// x position on the texture image to draw from
    float textureY,		// y position on the texture image to draw from
    int imgSizeX,		// x image size to display (like crop in PS)
    int imgSizeY,		// y image size to display (like crop in PS)
    int scaleY,		// y image size (will scale image to fit)
    int scalex)		// x image size (will scale image to fit)

     

    it's still a little confusing to use the first time. if you have something like:

    blit(10, 10, 10, 0F, 0F, 64, 64, 64, 64);

    you will end up with an image that is 64x64 that contains the entire image scaled to fit 64x64

     

    of you do something like:

    blit(10, 10, 10, 0F, 0F, 64, 64, 32, 32);

    you get an image that is 64x64 but that contains 4 copies of your image in a 2x2 grid that are all 32x32.

     

  9. 21 minutes ago, SerpentDagger said:

    Sorry, looking over the code it seems that the method that opens a GUI also closes the current one, and an instance of Minecraft has a single currentScreen field, which is changed when a new screen is opened.

    However, you can still accomplish the same thing by, instead of calling the opening method of Minecraft, having an instance of your popup window stored in the main one, and calling its key methods through the main window. For example, when the button or trigger activates this popup window, call its initGui()* method, and toggle a boolean that allows its drawScreen()* method to be run during each call of your main window's drawScreen()*.

     

    *I think the names of methods may have changed between 1.12 and 1.14, but according to the 1.13/1.14 update primer, the underlying substance hasn't. Let me know if I'm sorely mistaken.

    Thanks, I decided to write an inner class that does what you described in your first reply. I figured out a few things that make it much easier than I had originally thought.

    • Like 1
  10. On 10/10/2019 at 12:34 AM, SerpentDagger said:

    It's pretty much up to you. There are a couple different approaches to take.

     

    Either you could have another gui class and offload more functions from the main window into the popup one, or you could create something yourself to handle the instructions from the main window that wouldn't be as complicated or sophisticated as a new gui (for example, something that simply drew an image when told to, held its x & y, etc).

     

    After doing either of those things, you could have the popup window be contained and controlled by the primary window, which would just involve having them as fields within that class and doing whatever needs to be done to them through that class.

    Or you could keep the handling of the popup window external, doing things to it alongside the main window. That would leak a little more gui handling into the outside world though.

     

    I created my own popup window class that extends "Screen", but it seems to replace the original screen that spawns it. is it possible to have the popup on top of the original screen? I could do what you said about just drawing the popup over the main screen, but then I would have to find a way to disable all mouse click events on the main screen, and that seems tedious.

  11. 22 minutes ago, Animefan8888 said:

    I wasn't intending to be negative.

     

    here is your first reply on this thread.

    On 10/4/2019 at 1:45 AM, Animefan8888 said:

    Any way you want?...

    you end the reply with "...". Correct me if I'm wrong, but in most contexts that would indicate annoyance or loosing ones patience. "Any way you want?", is like asking "isn't it obvious?", which does nothing to help while also being backhanded.

     

    so you intentionally asked a backhanded question ended with "..." to indicate annoyance. you typed all this out deliberately.

     

    to be fair, you are not the only one who does this kind of thing. I would not be typing all this out if it were the first time I saw something like this, and you were the only one. If you truly had no idea that you were being negative, then I'm sorry for all this. All I want is to learn, without stepping on any toes.

  12. 35 minutes ago, Animefan8888 said:

    What are you looking through those methods for?

    are you kidding? when I don't understand something, I look through the associated methods and classes. That should be the first thing a person does. Then I experiment. Then I look online for an answer/explanation. finally I post here on the forums.

     

    half the time when I post on this forum I get negativity. I assumed it was because I wasn't being diligent enough in figuring things out on my own. I spend HOURS trying to get something to work before asking here because I don't want to annoy people like yourself. Why, you ask, am I looking through those methods? to not bother you. to not get the negativity. An impossible task it seems.

  13. On 10/4/2019 at 3:43 PM, Animefan8888 said:

    Take a look at how you render your gui backgrounds.

    I did.

     

    from my container screen:

        @Override
        protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
            GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            this.minecraft.getTextureManager().bindTexture(GUI);
            int relX = (this.width - this.xSize) / 2;
            int relY = (this.height - this.ySize) / 2;
            this.blit(relX, relY, 0, 0, this.xSize, this.ySize);
        }

     

    "GlStateManager" is 1300 lines of mostly obfuscated code.

     

    "this.minecraft.getTextureManager().bindTexture(GUI)" creates an "ITextureObject" within the Texture maneger. I'm not sure what an "ITextureObject" does, and, looking at the code, would take a lot of trial-and-error to figure out how to use if I'm even capable. after creating the ITextureObject, bindTexture() has the line "this.loadTexture(resource, itextureobject)". loadTexture() is pretty hard to understand just looking at the code.

     

    the next three lines revolve around "this.blit()", which leads me to more obfuscated code.

     

    There are many rabbit holes I could spend hours upon hours looking down. I've already spent a few hours looking for the answers myself as well as experimenting with the code. I was hoping someone on the forum might be able to either point me to an explanation or give a short one themselves.

  14. 13 hours ago, Animefan8888 said:

    You render something moving by changing the x and y value while rendering nothing else there is no special method or class. You have to implement it yourself.

    how exactly do I render the image though? I don't know how to render an image at all. I know how to draw strings with "this.font.drawString()", and I've tried "this.minecraft.getTextureManager().bindTexture();", but that seems incorrect.

  15. 11 hours ago, diesieben07 said:

    You should use send and PacketDistributor.

    Example:
    channel.send(PacketDistributor.PLAYER.with(yourTargetPlayer), msg).

     

    There are more distributors available that allow you to e.g. send to a whole dimension.

    If it's not to much trouble, could you or anyone who knows explain why this would be the preferred way to send such a packet?

  16. I'm trying to Sync up a server-side player capability with a client-side player capability. I don't know what I should send the packet to. I tried the player but I don't know exactly how to use the "sendTo" method. I tried:

    MerchantcraftPacketHandler.channel.sendTo(new SyncBalancePacketToClient(b), ???, NetworkDirection.PLAY_TO_CLIENT);

     

    I have no idea how to work with NetworkManager (the second parameter), and I'm not even sure about "NetworkDirection.PLAY_TO_CLIENT".

×
×
  • Create New...

Important Information

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