Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JayZX535

Members
  • Joined

  • Last visited

Everything posted by JayZX535

  1. Hey all, I'm attempting to figure out how to make some functions of my mod editable via datapacks, in much the same way as recipes, advancements, etc. can be edited. I'd love to see examples of how others have done this, since I'm struggling to figure out how it's even set up in the first place. I know Origins makes use of custom datapacks to edit powers, but it runs on Fabric, not Forge, so not as helpful for figuring out how to do it on Forge specifically. I also need to make sure that datapacks are able to append their data to each existing entry instead of just overwriting it. If anyone has or knows of examples of this I'd love to see them, I'm having a hard time actually tracking anything down to look at since I end up just getting results for actual datapacks, oops. Thank you for your time, and have a great day! EDIT: Just to specify, I'm talking about adding new types of data, not just using existing ones. I know how to add stuff like item tags, recipes, etc. I want to add a new type of data that can be edited through a datapack in the same sort of way-- like what Origins does to allow for the adding of new powers and such. I just don't know how to do that in Forge. Sorry for the initial confusion.
  2. That does indeed sound like it-- though I'm having a hard time finding any examples of how it's used. How would I go about setting one of those up? Admittedly this is rather uncharted terrain for me...
  3. Hey all, I'm working on a mod where I need to check if items can be used in/outputted from a recipe-- in this case, campfire recipes, but I may expand that to other types at some point in the future. Since both mods and datapacks can add recipes, I'd like to make this function as dynamic as possible. I'd also like to avoid having to iterate through all the possible recipes every time I need to test if something is a viable outcome, especially since some of the checks will be for the recipe output and not input (which seems less straightforward to figure out). It seems like it'd be less resource intensive to build a list of viable items once upon each load/reload, and then just use that list to check if something is a viable option or not. But, since recipes can change when datapacks are added/reloaded, I need to make sure these lists are regenerated after every reload, as well as after the initial recipe registration. Basically, what I'd like to do is listen for a server load or reload, loop through the list of recipes to find recipe inputs/outputs that match a certain set of criteria, add them to a set of lists that just hold the proper items, and then I can just check "is this item on this list? yes, okay or no, nevermind". Is there a good way I could go about this, and is there an event or something I could listen for to know when to trigger it? Or is it better just to loop through all the recipes every time as needed, even considering that there's a possibility of other mods adding a lot of possible recipes that could qualify? Will that be a lag concern or should that be fine? (usually I err toward the side of it being better to have a larger lag spike very infrequently than smaller ones that happen more often/interruptingly). Thanks, and have a great day!
  4. Are you saying you want the entity to take damage when you are sneaking on it? Not damage except when you're sneaking on it (i.e. magma blocks)? If so, you'll want to check entityIn.isSneaking(), not !entityIn.isSneaking(). The latter returns true when the entity isn't sneaking.
  5. Anyone know what else I could try to fix this? I'm truly at a loss Edit 6/30/20: Updating for anyone who may come here seeking answers later: I... fixed it? I ended up recreating my modding workspace, and now it's working again. So I'm guessing something got goofed up there? Truly, this is one of the more mysterious things I've encountered, and I wish I had a more solid idea on what I did. But when all else fails, redo your workspace I guess?
  6. Ah, I'd been trying the first part that way originally but saw a suggestion to try it like this. Didn't help, so I've changed it back now. Hmmm. I had mine set up to take a string (as noted in my ServerConfig file) but I tried changing it to a path. It now looks like this: @Mod.EventBusSubscriber public class ServerConfig { private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); public static final ForgeConfigSpec CONFIG; static { GeneralConfig.initServer(BUILDER); CONFIG = BUILDER.build(); } public static void loadConfig(ForgeConfigSpec config, Path path) { final CommentedFileConfig file = CommentedFileConfig.builder(path).sync().autosave().writingMode(WritingMode.REPLACE).build(); file.load(); config.setConfig(file); } } But still no dice. Still getting the error
  7. Hey all, So I'm trying to set up a config for my mod and having some issues. It keeps tossing the following error at me: I've been searching high and low to figure it out and I'm having a time of it. I'm not sure if I found a forge bug or if I'm just missing something stupid, but in any case, hopefully someone here can help. Code is as follows... Main: ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.CONFIG, "modid-server.toml"); ServerConfig.loadConfig(ServerConfig.CONFIG, FMLPaths.CONFIGDIR.get().resolve("modid-server.toml").toString()); ServerConfig: @Mod.EventBusSubscriber public class ServerConfig { private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); public static final ForgeConfigSpec CONFIG; static { GeneralConfig.initServer(BUILDER); CONFIG = BUILDER.build(); } public static void loadConfig(ForgeConfigSpec config, String path) { final CommentedFileConfig file = CommentedFileConfig.builder(new File(path)).sync().autosave().writingMode(WritingMode.REPLACE).build(); file.load(); config.setConfig(file); } } GeneralConfig: public class GeneralConfig { public static ForgeConfigSpec.BooleanValue SIMPLE_DAY_CYCLE; protected static void initServer(ForgeConfigSpec.Builder server){ setupGeneralSettingsConfig(server); } private static void setupGeneralSettingsConfig(ForgeConfigSpec.Builder builder){ builder.comment("General Settings").push("generalsettings"); SIMPLE_DAY_CYCLE = builder.comment("").define("simpledaycycle", false); builder.pop(); } } Thanks, and have a great day!
  8. WAIT. I just realized you meant the actual entity model class itself and not the layer renderer class (this is what I get for coding late into the night asdfghjkl). My model was indeed calling this: @Override public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ chestBase.render(matrixStack, buffer, packedLight, packedOverlay); bodyBase.render(matrixStack, buffer, packedLight, packedOverlay); tailBase.render(matrixStack, buffer, packedLight, packedOverlay); } When it should have been calling this: @Override public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ chestBase.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); bodyBase.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); tailBase.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); } I use BlockBench for my modeling and have been working with the autogenned export mostly, so it's good to know it doesn't add those by default. Everything works great now, so thank you again for your help!
  9. 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...
  10. 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.
  11. 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!
  12. 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!
  13. 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?
  14. 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.
  15. 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?
  16. 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!
  17. 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!
  18. 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!
  19. 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.
  20. I'm aware they do different things and I'm aware of what they do. I'm being "extra certain" by covering both possibilities.
  21. 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.
  22. 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.
  23. 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.
  24. 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.
  25. 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).

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.