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

MWR

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by MWR

  1. 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!
  2. 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?
  3. 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!
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. So it would be pointless unless this small mod somehow becomes incredibly popular. Thank you.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. Ok so I just need to figure how to change textures based on NBT data.
  14. Do I need to make my own model if I just want change the texture?
  15. 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?
  16. Would I have to make a JSON for every combination, or is there a way to have generic ingredients and results?
  17. 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.
  18. 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?
  19. Thank you for the video, but I found the issue. I had to update the Gradle from 7.2 to 7.3 in gradle/wrapper/gradle-wrapper.properties.
  20. I've been trying to update my mod to 1.18, but when I run this command: gradlew genEclipseRuns --refresh-dependencies It fails to build with this error: Execution failed for task ':downloadMcpConfig'. > Input property 'artifact' with value 'de.oceanlabs.mcp:mcp_config:1.18-20211130.085255@zip' cannot be serialized. I tried deleting the build folder, but nothing changed. How can I resolve this? Thanks in advance.
  21. I've been trying to update my mod from 1.16.5 to 1.17.1, but it is not functioning correctly. When I activate my custom honey sticky piston, it essentially turns into an entity. I can walk through it, and it can be destroyed with TNT. I went as far as rewriting all the code, which isn't very difficult since it's mostly copy-and-paste, but nothing has changed. Is this a Block Entity issue, or something else? Thanks in advance.
  22. I already have, and I've learned that the mod works in 1.16.5, but the version of Minecraft I run within Eclipse is not working. It keeps trying to run 1.16.4. I ran the genEclipseRuns task in the command line, which said it downloaded forge 1.16.5, but Eclipse still refers to the old version. I tried refreshing both the Gradle and entire project, but nothing worked.
  23. modLoader="javafml" loaderVersion="[36,)" license="MIT" [[mods]] modId="honeystickypistonmod" version="${file.jarVersion}" displayName="Honey Sticky Piston Mod" logoFile="examplemod.png" credits="Thanks to Cy4 and their community for teaching me how to mod and samjviana for some helpful code!" authors="MWR_" description=''' A new sticky piston that you can craft with honey! ''' [[dependencies.myfirstmod]] modId="forge" mandatory=true versionRange="[36,)" ordering="NONE" side="BOTH" [[dependencies.myfirstmod]] modId="minecraft" mandatory=true versionRange="[1.16.5,1.17)" ordering="NONE" side="BOTH" Actually I think I know the problem. It isn't the mod itself but the referenced libraries. Even with refreshing, it still keeps the jar files for 1.16.4, so when I load the client, it runs 1.16.4 and not 1.16.5. If I build the mod and play it through the Minecraft launcher on Forge 1.16.5, it works fine. If that's the issue, then how do I refresh those libraries?
  24. I did, but it still won’t update, even after refreshing the Gradle and entire project.
  25. I have been trying to update my mod from 1.16.4 to 1.16.5, so I updated the Gradle and mods.toml file to match with 1.16.5. Even when refreshing, I boot up the dev client and get the error "Mod File in-development needs language provider javafml:36 or above to load." How can I update javafml? Or am I updating the mod incorrectly?
×
×
  • Create New...

Important Information

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