-
Posts
75 -
Joined
-
Last visited
Everything posted by JayZX535
-
This is what I'm calling currently: public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entityIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { float f1 = 0.0F; float f2 = 0.0F; float f3 = 1.0F; renderCopyCutoutModel(this.getEntityModel(), this.model, TECTONIC_GLOW, matrixStackIn, bufferIn, packedLightIn, entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, partialTicks, f1, f2, f3); } renderCopyCutoutModel is the same method used for sheep wool and tropical fish, so I expected it would work here as well? It does render the layer, it's just completely untinted. I suppose I could try making my own renderer if I really need to, but I'd like to avoid that if there's a better solution...
-
Hey all, I've been trying to figure out modding in 1.15 after coming from 1.14, and I'm a little bit at a loss. I'm trying to use a texture layer for an entity with color applied to it and it... looks like the new system should support it more innately than the old? There's RGB variables in modelIn.render(matrixStackIn, ivertexbuilder, packedLightIn, LivingRenderer.getPackedOverlay(entityIn, 0.0F), red, green, blue, 1.0F); and judging by the sheep and tropical fish layers, these are used to set the color of the layer. The problem is, it... doesn't seem to work with modded entities? I've been using renderCopyCutoutModel(this.getEntityModel(), entitymodel, entitylivingbaseIn.getPatternTexture(), matrixStackIn, bufferIn, packedLightIn, entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, partialTicks, 0.0F, 0.0F, 1.0F; along with other variations in the render method of my layer class and nothing seems to work. I'm totally at a loss. Has anyone gotten a working colored render layer, and if so, how did you do it? Or is something broken at present for modded entities? I'm not sure if there's a step I'm missing or what, but whatever the case may be, I can't seem to find any info on it either. So I'm hoping someone here may be able to help. Thanks, and have a great day.
-
[1.14.4] Getting Items from Recipe / Drawing Items on GUI
JayZX535 replied to JayZX535's topic in Modder Support
Makes sense. Looks like that's the function of the test boolean from Ingredient-- to check a specific stack and make sure it fits. Right now for my GUI I've asked it to give me the first stack from Ingredient#getMatchingStacks() to display in the GUI. This seems to work with the recipes I have so far, but I'll continue to monitor it (especially if I end up with any recipes with multiple possible inputs). My biggest concern is if the recipe gets changed (I know some modpacks really like doing that, for example), but I think this should at least return a result if the recipe is craftable (and I'd imagine blank if it's not?). And if people really want to know how to craft something, I expect they'll look first to the crafting guide. The GUI I'm working with here is the lore book, so it has more info on how the stuff actually works-- the recipes are just there for easy reference. So I'm hoping this will at least function acceptably for what I'm trying to get it to do. Thanks! -
[1.14.4] Getting Items from Recipe / Drawing Items on GUI
JayZX535 replied to JayZX535's topic in Modder Support
Ohhh I see that now! I was confused by that getMatchingStacks at first, but given that item tags are a thing, I think I understand it now? I assume that's why it's an array rather than a static ItemStack-- to account for recipes that take in multiple possible ingredients? Happy to say I've got it all working now! I know some modpacks like to change/remove recipes, so I wanted to make sure I got the recipe from its source rather than hardcoding it in. ItemRenderer works like a charm too. Thanks for the help! -
[1.14.4] Getting Items from Recipe / Drawing Items on GUI
JayZX535 replied to JayZX535's topic in Modder Support
ItemRenderer looks exactly like what I need to draw the items. Thank you so much! I didn't realize the beacon used anything that wasn't slot based. Only question now is, how do I get them from the recipe in the first place? -
Hello again, I'm wondering what the best way to get an item/itemstack from a recipe is. I'm trying to draw a recipe to the screen-- sort of like the crafting guide, but not quite. I don't want to hardcode it because of the way recipes can now be altered with a datapack. So basically I'm trying to load the current (shaped) recipe for an item (if it exists), loop through it and get the item/itemstack (if not empty) for each space in the grid, and draw it to the screen. It's worth noting that, due to the way this particular GUI is set up, I'm not using an actual container for it. I'd like to avoid using a container if at all possible just due to the way this particular GUI works-- so I need a way to draw the stacks on the screen without a container, either by drawing the item/stack directly or by getting its texture location. Is there a good way I can go about doing this? Thanks, and have a great day.
-
Looks like that's controlled by the bee's AI and not from the block or tileentity. Take a look at BeeEntity#EnterBeehiveGoal() . It looks like it's looking for a BeehiveTileEntity to enter. Did you extend BeehiveBlock/BeehiveTileEntity for your classes, or just copy their code?
-
Ahhh, that was about what I figured the problem was. On the smallest sized window I've been looking at, one pixel does take up a 2x2. On the largest one it's a 5x5. I was hoping maybe I could snag the raw 1x1 pixel data before Minecraft scales it up to the size of the rest of the GUI because if I set it to 0.5 it was weird on the large size (trying to draw 2.5x2.5) and if I did 0.8 it was weird on the small size (trying to draw 1.6x1.6), and by getting the data before it scales up I could then calculate up rather than down and more easily ensure it would never be a fraction of a pixel, but... after poking around with it some more, that's seeming to be more trouble than I think it's worth. I'd have to worry about so many possible pixel sizes, and even when I did try the 1x1 pixel for the small window it was too small to read well, not to mention potential issues with the GUI scale, so... I guess I'll be sticking with the larger font size for now. Thank you for the answer!
-
Hey all, I'm working on the lore book for my mod, but I felt like I couldn't get enough info on its pages with Minecraft's default font size. I did some research and figured out that you have to change the GL scale to be able to change the font size. I finally got this working, mostly, but... it's presented me with a new problem. On my fairly large monitor with the window full size, the text looks fine... but when I make the window smaller... the scaling is very uneven and reduces legibility-- which is especially a big issue at such a small size. The code I'm using to scale the text is called through the render method of my GUI (extends Screen, since it has no inventory): GL11.glPushMatrix(); GL11.glScalef(fontScale, fontScale, fontScale); this.font.drawSplitString(I18n.format(pageSegments.get(i)), (int) scaleUp(xOffset), (int) scaleUp(yPos), (int) scaleUp(textWidth), this.textColorDark); GL11.glPopMatrix(); fontScale is at 0.8F. I'm guessing the problem is occurring because I'm scaling down and therefore losing pixels. But the font is a pixel one to begin with, so... in theory, shouldn't it be possible to start with it at a 1pixel scale and then scale it up? I'm just not sure how to override Minecraft's default GUI sizing for this. I still want it to be based off the GUI scale so that people can change the sizing as they wish, but I need to do my own calculation to get it at 0.8 the normal size instead of 1.0. Unless I'm totally wrong about that guess, which is also totally possible. In any case, I'm hoping someone here may have a solution... Thanks, and have a great day!
-
Oooh, those first ideas seem pretty feasible. There's code in the game that allows for "unnatural spawns" (i.e. interdimensional teleportation), so I might be able to utilize that to recall them. Possibly implement a delay before respawning them, so they don't instantly warp... hmmm... Though, I suppose that'd hinge on the hive itself being loaded. Hmm. Is there a way to load a certain chunk based off a block even when no players are near? I know some mods have managed to make chunk loaders but I'm not sure of a good example offhand... That's another good option! I've definitely got some more direction now, so thank y'all for your help!
-
Hey all, So I'm theorycrafting some of my mod mechanics and I think I want my entities to have a "home block"-- similar to how bees will try and return to their nest. However, this brings up an interesting situation. When I've played in 1.15, I've noticed my bees tend to wander off and disappear if not enclosed. If I have a full hive, eventually some of the bees will just disappear-- and if I venture to chunks outside my usual travel range, all of a sudden there are a bunch of homeless bees. I'm guessing this is because the bees fly off when I'm in the area, but then get stranded in unloaded chunks if I walk away. I'd like to avoid this problem if at all possible, so I'm trying to figure out ways to do it. My current idea is to catch the chunk unload event, scan for my entities, and, if found, warp them back to/closer to their home block. This runs the risk of being a little janky, but if the player is far enough away from them to be unloading those chunks in the first place, I'm guessing it wouldn't be super noticeable? Better yet, I could catch the unload event for the entities themselves, and use that as the warp trigger. I don't know of any mods that do something like this off the top of my head, though, so I was curious as to its plausibility. Is there anyone who's tried something like this before? What events would I need to intercept? Is there a good way to force a chunk to load temporarily (i.e. if the home chunk is already unloaded, make it load back in, warp the entities, and then let it unload once more)? Is there anything else I should be aware of when considering this? Thank you for your time, and have a great day.
-
I'm aware they do different things and I'm aware of what they do. I'm being "extra certain" by covering both possibilities.
-
Thanks for the confirmation! Works like a charm on both server and client. Ended up using both checks just to be extra certain and it all seems just fine.
-
Hey all, I'm working on implementing a lore book to my mod. It works similarly to vanilla books, except the text is all predefined. As such, I'm trying to figure out how to create and access a GUI for it. My question is, I'm not sure if I need to use a container for it, or if it even needs serverside access at all. I'm planning on using info that's drawn from the mod's lang file and a player capability (which I've already coded to sync to the client), and it shouldn't need to send any info back to the server (nothing the player can edit except the currently viewed page, which I can easily handle via the client) so if I'm understanding everything right, it doesn't actually need to pull any data from the server. As such, I'm not sure if I need to use a container at all, or if I should just make it a screen. However, I want to ensure that I'm doing this properly. I see that ClientPlayerEntity uses the following method... (which is called from the book items) public void openBook(ItemStack stack, Hand hand) { Item item = stack.getItem(); if (item == Items.WRITABLE_BOOK) { this.mc.displayGuiScreen(new EditBookScreen(this, stack, hand)); } } So I'm guessing I may need to do something like that. Is this.mc.displayGUIScreen() the right method to use for modded GUIs? Do I need to register the GUI anywhere, or if it's not linked to a container can I just open it like this? I assume I need a client safe method to call to open this, so I'm guessing I should run that method through my proxy for safety? Is there anything I should be aware of when it comes to using a client-only screen, and is there any reason I might still want to opt to use a container in this case? If the method is clientside only, is there anything special I need to do to block movement (or anything else noteworthy)? Thanks, and have a great day.
-
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
JayZX535 replied to JayZX535's topic in Modder Support
Aha! It's in IForgeItem-- apparently I'd missed that one. Overrode the method to make it check for the color variable before returning the stack and it works like a charm. Thanks everyone, for helping me figure this one out. -
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
JayZX535 replied to JayZX535's topic in Modder Support
Because nothing else I tried was working. I figured I might as well see if that would, and it didn't. The override method isn't working for me. It didn't auto-suggest anything, and when I tried manually typing in what I thought it probably would be, the only thing it did was give me an incorrect return type and suggest I change it to the Item one. I've literally never seen it suggest a method like that either, so I don't know if something is off by default or what. Does anyone know what the method that deprecation note referred to even is? Because I sure as heck don't see it. -
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
JayZX535 replied to JayZX535's topic in Modder Support
Which one? Because the only one I see in the item class is this: @Nullable @Deprecated // Use ItemStack sensitive version. public final Item getContainerItem() { return this.containerItem; } I don't even see where the "ItemStack sensitive version" is. A lot of the times those notes have an actual link, but I'm not finding anything with ctrl + f either. Just this and the one I referenced earlier in properties (which is how this.containerItem is set in this method). -
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
JayZX535 replied to JayZX535's topic in Modder Support
Unfortunately no. I tried adding a custom extension to properties in my Item class, but the problem is, the method is this: public Item.Properties containerItem(Item containerItemIn) { this.containerItem = containerItemIn; return this; } Which takes an Item and not an ItemStack. Good thought though... -
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
JayZX535 replied to JayZX535's topic in Modder Support
Oh yeah, I know how to edit the NBT data for the result item, which goes into the output slot. I just don't know how to edit the NBT data for an item that gets left behind in the crafting grid, like buckets from the cake recipe, or (in 1.15) empty bottles after crafting a honey block. -
[1.14.4] Using .containerItem() to leave behind an item with NBT data?
JayZX535 replied to JayZX535's topic in Modder Support
That was my first thought but the method that does it, getRemainingItems(C inv) comes from the IRecipe interface and is a default, so I can't just override and insert my own code. Which is a shame because the method itself would be easy enough to alter. -
Hey all, I have a set of items that can be dyed dynamically (think leather armor, but simpler-- just the main 16 colors). This works by assigning an NBT tag to the dyed ItemStack, which the game then checks for when applying tints to the layer. This function itself works fine, however I've run into a bit of a block when trying to add additional functionality. Put simply, this item can be crafted with another item to make a 'combined' item. I'd like to make it possible to un-craft that combination, returning the item crafted with it in the output slot, and leaving the base item in the crafting grid (i.e. buckets after crafting cake). There are multiple items that can be crafted with the base item, which are also saved in the stack NBT data, so I'd like to keep those secondary items as the output, since that seems like it should be easier to determine which item to output that way. However, as I understand it, if I just use the default .containerItem() to return the base item, it will create a new stack of that item, thus wiping the NBT (and any color data that might have been stored in it). Is there a good way I could ensure that the color NBT data is copied over to the base item, so that it doesn't revert to its un-dyed version upon crafting? Thanks, and have a great day.
-
Thank you so much-- this helped me a lot! Blocks seem to handle containers differently than most other things-- Forge handles them a bit better inherently (which is as to be expected-- most GUIs would be coming from blocks, after all). I eventually also found the registry method that allows me to send data with the container. I used that to pass the entityID, allowing me to register it as... event.getRegistry().register(IForgeContainerType.create((windowId, inv, data) -> { int id = data.readInt(); return new WCCanineEntityContainer(windowId, inv, id); }).setRegistryName("wc_canine_inventory")); It's now up and running as expected, so thank you again for your help!
-
Apologies for the massively delayed response. I've been troubleshooting... a lot 9.9 I was a little bit blind and was looking at the wrong method in the blocks. Blocks use this to open GUIs... public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { player.openContainer(state.getContainer(worldIn, pos)); return true; } Which works. Well, kind of. The game now tries to open the GUI-- before erroring and crashing. It's having issues with the inventory container, and in particular, the inventory getting passed to it being null. Which brings up a totally different problem... The registry: public static ContainerType<WCTradingPostContainer> WC_TRADING_POST_CONTAINER; public static ContainerType<WCKibblePressContainer> WC_KIBBLE_PRESS_CONTAINER; public static ContainerType<WCCanineEntityContainer> WC_CANINE_INVENTORY_CONTAINER; @SuppressWarnings ("unchecked") public static void registerContainerTypes(final RegistryEvent.Register<ContainerType<?>> event){ event.getRegistry().registerAll( WC_TRADING_POST_CONTAINER = (ContainerType<WCTradingPostContainer>) new ContainerType<WCTradingPostContainer>(WCTradingPostContainer::new).setRegistryName("wc_trading_post"), WC_KIBBLE_PRESS_CONTAINER = (ContainerType<WCKibblePressContainer>) new ContainerType<WCKibblePressContainer>(WCKibblePressContainer::new).setRegistryName("wc_kibble_press"), WC_CANINE_INVENTORY_CONTAINER = (ContainerType<WCCanineEntityContainer>) new ContainerType<WCCanineEntityContainer>(WCCanineEntityContainer::new).setRegistryName("wc_canine_inventory") ); } Relevant part of the container code... public WCCanineEntityContainer(int windowId, PlayerInventory playerInv) { this(windowId, playerInv, null); } public WCCanineEntityContainer(int windowId, PlayerInventory playerInv, final WCAnimalEntity animal) { super(WCRegistry.WC_CANINE_INVENTORY_CONTAINER, windowId); this.animal = animal; System.out.println(animal); this.animalInventory = animal.animalInventory(); animalInventory.openInventory(playerInv.player); } That print statement indicates that "animal" is null. I'm passing the animal in through the getContainer method I use to open the GUI... @Nullable @Override public INamedContainerProvider getContainer() { return new SimpleNamedContainerProvider((windowId, playerInv, name) -> { return new WCCanineEntityContainer(windowId, playerInv, this); }, this.getTranslationText()); } but I assume that's being overridden by the registry seems to call the first method, which passes the animal as "null". The block guis get around it by using this... public WCKibblePressContainer(int windowId, PlayerInventory playerInv) { this(windowId, playerInv, IWorldPosCallable.DUMMY); } public WCKibblePressContainer(int windowId, PlayerInventory playerInv, final IWorldPosCallable worldPos) { super(WCRegistry.WC_KIBBLE_PRESS_CONTAINER, windowId); this.worldPos = worldPos; } So... I can only assume that the difference comes from that "IWorldPosCallable.Dummy", unless I've just been staring at this for so long that I'm missing something glaring. But I don't have any sort of dummy method to use instead of null, and frankly I'm not quite sure how to make one. The animal itself does get initialized properly, so it shouldn't be an issue there? I feel like I'm missing something big, and I have yet to find an example of a working entity inventory to go off-- aside from horses, which have their own special opener hard-coded into the player (as mentioned previously). Anyone know how I could get around this?
-
Hey all, I'm currently in the process of trying to implement an inventory for an entity. I want the player to be able to click the entity and access its inventory. So far I've been basing a lot off the horse classes, however the horse handles opening the gui by calling playerEntity.openHorseInventory(this, this.horseChest); , but since my entity isn't connected to the horse classes, that's not gonna work for me. Is there another way I can open the entity's GUI? I think everything else should be set up beyond that-- it's just a matter of opening the GUI in the first place. I assume registration is the same for an entity container as for a tileentity container, so unless that's different I think everything else should work... Thanks!
-
[1.14.4+] Unlocking Lore Book Sections as Player Progresses
JayZX535 replied to JayZX535's topic in Modder Support
Apologies for the delayed response. Sounds like I have some options to play around with when setting this up-- thanks! I'll keep these in mind for when I start adding lore!