Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

MWR

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by MWR

  1. So then maybe config file is the way to go.
  2. Hmmmm… By loading the tag, do you mean when the game is initially loaded or when something is trying to access the tag?
  3. No, my idea was that the tag just stores the names of the patterns. So for example, in tags/emblem_pattern/patterns.json: { "values": [ "border", "square", … ] }
  4. I really don't know if I need the registry to hold anything. I just want it so I can put emblems under the tags folder. If I can't do that, I won't. My pre-made emblem patterns currently are not registered and are simply textures. I ran into problems with this method when creating a menu with all the patterns. I need some way to store them, and I want them to be easily expandable. I thought of config files, but datapacks seem more user-friendly. If the menu only appears in-game when you click on the special block, then I don't see a need to register anything. The packs are already loaded at that point, so my idea was for the menu to access the list of patterns, whether it be in a JSON or config file, to get whatever information it needed. I prefer to go the datapack route, so if I need a registry to create a new tag type, can I create one without filling it?
  5. So to be clear, to make a new tag type, alongside "blocks", "fluids", "items", etc., I need a registry, right? I want to have a directory just for emblems in the tags folder.
  6. I'm making a mod that lets you add an emblem to your armor. You can make your own by combining patterns like banners. However, I also want it to be possible to add your own patterns without Java code. I thought of make a custom tag that contains all the patterns, but they're not items. They're just PNGs, and if I understand correctly, I would need to create a custom registry to create the custom TagKey. Is there a better/simpler way to achieve this?
  7. I'm making a new layer on a player to render an emblem on armor, but I don't know which Render Type to use. There are so many, and I don't know what each do. Thanks in advance.
  8. After a lot of digging, I've concluded the best way to go about this is not combining textures, as that is impossible during runtime, but to add a render layer. I've been trying to understand how the rendering works, but I don't know what buffers are, like this one in HorseMarkingLayer: public void render(PoseStack p_117058_, MultiBufferSource p_117059_, int p_117060_, Horse p_117061_, float p_117062_, float p_117063_, float p_117064_, float p_117065_, float p_117066_, float p_117067_) { ResourceLocation resourcelocation = LOCATION_BY_MARKINGS.get(p_117061_.getMarkings()); if (resourcelocation != null && !p_117061_.isInvisible()) { VertexConsumer vertexconsumer = p_117059_.getBuffer(RenderType.entityTranslucent(resourcelocation)); this.getParentModel().renderToBuffer(p_117058_, vertexconsumer, p_117060_, LivingEntityRenderer.getOverlayCoords(p_117061_, 0.0F), 1.0F, 1.0F, 1.0F, 1.0F); } } If this is a Java question, let me know, but any help is appreciated!
  9. I'm making a mod where you can add a small 4 by 4 emblem to your armor. I want to add multiple symbols, but it can get tedious to create a texture for each emblem. Also, I plan on adding the ability make your own emblems with patterns, similar to banner patterns. I looked at the code for rendering banner patterns, but I can't understand it. I know you can add layers to item model JSONs, like the spawn egg, but they're not dynamic. I thought of combining the two images and making a temporary texture while the game runs, but is there a more elegant way to achieve this?
  10. I got it working! I was using getTagElement incorrectly, I'm not sure what the correct way is to use getTagElement, but it doesn't matter. @Override public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { ArmorItem item = (ArmorItem)stack.getItem(); String texture = item.getMaterial().getName(); String domain = "minecraft"; String emblem = ""; if (stack.getTag().contains("Emblem")) { emblem = stack.getTag().getString("Emblem"); domain = "emblematic"; } texture = texture.substring(texture.indexOf(':') + 1); return String.format(java.util.Locale.ROOT, "%s:textures/models/armor/%s_layer_1%s.png", domain, texture, emblem == "" ? "" : String.format(java.util.Locale.ROOT, "_%s", emblem)); //TODO: change when including leather because of overlays } Thank you to all who helped!
  11. Where am I supposed to add it? I handled adding the tag in the custom recipe, and it adds the proper NBT data to the chestplate.
  12. One time I crashed because of a bug in my code. I was just saying that because of that, I know it’s my code being used for the chestplate and not vanilla code. Also, I learned the reason why it’s not working is because of the Emblem tag. stack.getTagElement(“Emblem”) returns null even if it has that tag. I’m not sure what is the correct way to get the Emblem tag.
  13. Here is my code for ModArmorItem: public class ModArmorItem extends ArmorItem { public ModArmorItem(ArmorMaterial material, EquipmentSlot slot, Properties properties) { super(material, slot, properties); } @Override public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { ArmorItem item = (ArmorItem)stack.getItem(); String texture = item.getMaterial().getName(); String domain = "minecraft"; String emblem = ""; if (stack.getTagElement("Emblem") != null) { emblem = stack.getTagElement("Emblem").getString("Emblem"); domain = "emblematic"; } texture = texture.substring(texture.indexOf(':') + 1); return String.format(java.util.Locale.ROOT, "%s:textures/models/armor/%s_layer_1%s.png", domain, texture, emblem == "" ? "" : String.format(java.util.Locale.ROOT, "_%s", emblem)); //TODO: change when including leather because of overlays } } I'm not sure what I did wrong. The texture does not change, but I can verify that the modified chestplate code is being used.
  14. So far, I've overridden getArmorResource: public class ModHumanoidArmorLayer<T extends LivingEntity, M extends HumanoidModel<T>, A extends HumanoidModel<T>> extends HumanoidArmorLayer<T, M, A> { ... @Override public ResourceLocation getArmorResource(net.minecraft.world.entity.Entity entity, ItemStack stack, EquipmentSlot slot, @Nullable String type) { ArmorItem item = (ArmorItem)stack.getItem(); String texture = item.getMaterial().getName(); String domain = "minecraft"; int idx = texture.indexOf(':'); if (idx != -1) { domain = texture.substring(0, idx); texture = texture.substring(idx + 1); } String emblem = stack.getTagElement("emblem").getString("emblem"); String s1 = String.format(java.util.Locale.ROOT, "%s:textures/models/armor/%s_layer_%d%s_%s.png", domain, texture, (usesInnerModel(slot) ? 2 : 1), type == null ? "" : String.format(java.util.Locale.ROOT, "_%s", type), emblem); s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type); ResourceLocation resourcelocation = ARMOR_LOCATION_CACHE.get(s1); if (resourcelocation == null) { resourcelocation = new ResourceLocation(s1); ARMOR_LOCATION_CACHE.put(s1, resourcelocation); } return resourcelocation; } } But how could I override the vanilla HumanoidArmorLayer? I made my own custom model for getArmorModel (which is copy/pasted from vanilla), but I am not sure how to control its textures without HumanoidArmorLayer.
  15. So it would be pointless unless this small mod somehow becomes incredibly popular. Thank you.
  16. Right, but in the case of some other mod using a piston in a recipe, I want my custom piston to be recognized as a piston, too. I want it to work like the “planks” tag, where you can use any type of plank to make a chest, for example.
  17. I want to declare a new item group for pistons so it can be recognized as another sticky piston or piston in general in recipes. I've made the JSONs and file paths, and I was wondering if I need to do any more. I saw code for tags in the documentation, but I wasn't sure if I needed code if the tags are only for recipes. Thanks in advance.
  18. I figured it out. I just moved the triple quotes so they are on the same line as my description. And thank you for letting me know, but I already updated to 1.18. I just happened to be editing the 1.16.4 version.
  19. In my mod description, there is an unknown character at the end of it, but I don't know how to get rid of it. The mods.toml description seems fine to me. mods.toml: modLoader="javafml" loaderVersion="[35,)" license="MIT" issueTrackerURL="https://github.com/MWR27/HoneyStickyPistonMod/issues" [[mods]] modId="honeystickypistonmod" version="${file.jarVersion}" displayName="Honey Sticky Piston Mod" logoFile="logo.png" credits="Thanks to Cy4 and their community for teaching me how to mod and samjviana for a helpful reference!" authors="MWR_" description=''' A new sticky piston that you can craft with honey! ''' [[dependencies.honeystickypistonmod]] modId="forge" mandatory=true versionRange="[35,)" ordering="NONE" side="BOTH" [[dependencies.honeystickypistonmod]] modId="minecraft" mandatory=true versionRange="[1.16.4,1.17)" ordering="NONE" side="BOTH" Thanks in advance.
  20. Ok so I just need to figure how to change textures based on NBT data.
  21. Do I need to make my own model if I just want change the texture?
  22. I'm not sure if there is a more elegant way to hold a list of potential ingredients, but this works: public class EmblemRecipe extends CustomRecipe { ArrayList<Item> ingredients = new ArrayList<>(Arrays.asList(Items.GUNPOWDER, Items.BONE, Items.REDSTONE)); String[] emblems = {"Creeper", "Skeleton", "Redstone"}; public EmblemRecipe(ResourceLocation id) { super(id); } @Override public boolean matches(CraftingContainer inv, Level level) { ItemStack chestplate = ItemStack.EMPTY; ItemStack ingredient = ItemStack.EMPTY; for(int i = 0; i < inv.getContainerSize(); ++i) { ItemStack itemstack = inv.getItem(i); if (chestplate.isEmpty() && itemstack.getItem() instanceof ArmorItem && ((ArmorItem)itemstack.getItem()).getSlot() == EquipmentSlot.CHEST) { chestplate = itemstack; } if (ingredient.isEmpty() && ingredients.contains(itemstack.getItem())) { ingredient = itemstack; } } return !chestplate.isEmpty() && !ingredient.isEmpty(); } @Override public ItemStack assemble(CraftingContainer inv) { ItemStack chestplate = null; CompoundTag compoundtag = null; String emblem = null; for(int i = 0; i < inv.getContainerSize(); ++i ) { ItemStack itemstack = inv.getItem(i); if (itemstack.getItem() instanceof ArmorItem) { chestplate = itemstack.copy(); compoundtag = chestplate.getOrCreateTagElement("emblem"); } if (ingredients.contains(itemstack.getItem())) { emblem = emblems[ingredients.indexOf(itemstack.getItem())]; } } compoundtag.putString("Emblem", emblem); chestplate.setTag(compoundtag); return chestplate; } @Override public boolean canCraftInDimensions(int width, int height) { return width * height >= 2; } @Override public ItemStack getResultItem() { return ItemStack.EMPTY; } @Override public RecipeSerializer<?> getSerializer() { return ModRecipeSerializer.EMBLEM_RECIPE.get(); } @Override public RecipeType<?> getType() { return RecipeType.CRAFTING; } } Now my struggle is rendering the armor. I can't find where vanilla armor is rendered, and when I do, would I need to extend that class and make my own renderer for armor?
  23. Would I have to make a JSON for every combination, or is there a way to have generic ingredients and results?
  24. Ok, so I came up with this: { "type": "minecraft:crafting_shapeless", "ingredients": [ { "item": "minecraft:diamond_chestplate" }, { "item": "minecraft:gunpowder" } ], "result": { "item": "minecraft:diamond_chestplate", "nbt": "{Emblem:Creeper}" } } Where would this assemble method go? Would I need to make an ArmorItem class of some sort? The custom recipe added this tag without needing code, so do I just need to figure out how to render it based on this NBT tag? Would I need to override the vanilla ArmorItem, or make a new one? If possible, I don't want to change vanilla chestplates, in case it somehow breaks functionality with other mods.
  25. I have this idea where you can add emblems to your chestplate to distinguish yourself. What I am wondering is whether or not I need to register every variant. It can get quite overwhelming to need to register 4 chestplates for every symbol, and they wouldn’t be treated as the vanilla chestplate. Would I be able to avoid this through tags or some other way?
×
×
  • Create New...

Important Information

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