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

MWR

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by MWR

  1. 4 hours ago, warjort said:

    I don't see what the tag does for you if there is nothing in the registry. You will always have empty tags?

    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", …
    ]
    }

  2. 2 hours ago, warjort said:

    Unless I have misunderstood your requirements, I don't think what you are trying to do is going to work.

     

    The closest things in minecraft are banner patterns or paintings.

    But these are registered in code (not what you want) on both the client and the server.

    Then when it loads resource packs on the client it looks up the texture for each one.

     

    It does it this way because the game defines what should exist, then lets the user/modpack developer give them textures (with you providing a default texture).

     

    You seem to want to populate a registry from what textures exist in a resource pack? So kind of the reverse.

    This isn't going to work for at least 2 reasons:

    * By the time resource packs are loaded, the registries are frozen - It is too late.

    * Servers don't even load resource packs, so there is no way it can use this mechanism 

     

    You need some other mechanism to populate your registry.

    e.g. a configuration file holding the names of what should exist, but it doesn't sound like what you want?

    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?

  3. On 8/7/2022 at 7:04 AM, diesieben07 said:

    Registries require a special flag to be dynamic. Banner patterns currently do not do this. As such you will have to write a completely custom system for this which does not use the vanilla banner pattern registry. Look at how loot tables or tags are loaded from data packs.

    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.

  4. 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?

  5. 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!

  6. 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?

  7. 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!

  8. 11 hours ago, diesieben07 said:

    What do you mean by this?

    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.

  9. 17 hours ago, diesieben07 said:

    getArmorTexture will be used as the texture. Don't make your own layer.

    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.

  10. On 6/3/2022 at 3:40 AM, diesieben07 said:

    HumanoidArmorLayer. You can provide your own model and rendering via getArmorModel.

    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.

  11. 9 hours ago, diesieben07 said:

    That's not how tags work. If the tag is not used by the recipe, it won't have any effect.

    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.

  12. 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.

  13. 1 hour ago, Luis_ST said:

    first of all you should update to 1.16.5, you also need to mention that 1.16.5 is LTS and it will be replaced in the weeks with 1.18.2

    is there any character after your description? like a space or a new line (/n)

     

    1 hour ago, LexManos said:

    CR is carrier return, it's part of windows new lines {\r\n}.
    Convert tour toml to linux line endings {just \n}

     

    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.

  14. 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.

     

    7iXl2q0.png

     

    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.

  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. On 5/30/2022 at 8:25 AM, MFMods said:

    make a class EmblemRecipe that extends SpecialRecipe. in method "matches" confirm that the player provided a chestplate (maybe you'll allow adding things in steps?) and things you accept. in "assemble" method you make a recipe result - vanilla chestplate with nbt or your own item with nbt, that's up to you.

    use SimpleRecipeSerializer as a recipe serializer. register it in RegistryEvent.Register<IRecipeSerializer<?>> event.

    make a json file like this:
    {
      "type": "your_mod_id:recipe_name"
    }
    where recipe_name is name you give to the serializer. basically this is the recipe class:

    public class YourRecipe extends SpecialRecipe
    {
    	public static IRecipeSerializer<YourRecipe> StupidSerializer = (IRecipeSerializer<YourRecipe>) (new SimpleRecipeSerializer<YourRecipe>(YourRecipe::new).setRegistryName(YourMod.MODID, "recipe_name"));
    
    
    	public YourRecipe(ResourceLocation resourceLocation)
    	{
    		super(resourceLocation);
    	}
    
    
    
    	@Override
    	public boolean matches(CraftingInventory inventory, World world)
    	{
    		return true if items are acceptable;
    	}
    
    
    
    	@Override
    	public ItemStack assemble(CraftingInventory inventory)
    	{
    		return nice new itemstack with nbt;
    	}
    
    
    
    	@Override
    	public IRecipeSerializer<?> getSerializer()
    	{
    		return StupidSerializer;
    	}
    }

     

    Would I have to make a JSON for every combination, or is there a way to have generic ingredients and results?

  17. 13 hours ago, MFMods said:

    yes, you can use tags (nbt tags within the item, not the new "item tags").

    you need a custom recipe that takes a chestplate and some items and returns a chestplate with some data in nbt tags. and you need to render your stuff when you render your armor item.

    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}"
      }
    }
    13 hours ago, MFMods said:

    if you are going to use the crafting table (you don't have to, it can be your own block), in assemble method of the recipe call startingChestPlate.copy() to get the itemstack to return. then, result.getOrCreateTag() returns the root tag. it's best to make a CompoundTag for your mod, fill it using putString calls and then append your compound tag under the root using the put method.

    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?

×
×
  • Create New...

Important Information

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