Jump to content

Dylem

Members
  • Posts

    51
  • Joined

  • Last visited

Posts posted by Dylem

  1. Hey, I have a problem with my Sword with metadata. I made an Item using variants (A, B, C) and it works good. But when I apply the same procedure to my sword, the variants get the same texture as the basic texture, and it looks "damaged" in inventory (with the green bar under it).

     

    See the problem :

    5b57f69c2d.png

     

    Here is the code :https://github.com/dylem/DylemTestMod/blob/master/common/net/dylem/test_mod/item/ItemSoulSword.java 

     

    note : I also tried to add setHasSubtypes without seeing any change, appart from breaking my call to increase the medata to the item ( stack.setItemDamage(stack.getItemDamage() + 1); ).

    note 2 : addSoul is called from an event, but it is not related to the problem

  2. 31 minutes ago, diesieben07 said:

    Your JSON specifies 3 variants: "variant=a", "variant=b" and "variant=c". You tell Minecraft to load "test_mod:item_variants=a", "test_mod:item_variants=b" and "test_mod:item_variants=c".

    Not sure what you expected but a "hey, I cannot find what you told me to load".

     

    Always keep in mind: Variant strings are not specially parsed. They are simple strings. They either match exactly, or they don't.

    Choonster did exactly what I did and it works for him, that's why I'm confused.

    I tried to replace "variant" by "test_mod:item_variants", or just "item_variants" and it doesn't work either.

     

    {
        "forge_marker": 1,
        "defaults": {
            "model": "test_mod:item/generated"
        },
        "variants": {
            "test_mod:item_variants": {
                "a": {
                    "textures": {
                        "layer0": "test_mod:items/variants.a"
                    }
                },
                "b": {
                    "textures": {
                        "layer0": "test_mod:items/variants.b"
                    }
                },
                "c": {
                    "textures": {
                        "layer0": "test_mod:items/variants.c"
                    }
                }
            }
        }
    }

     

  3. 30 minutes ago, Choonster said:

     

    Forge will automatically try to load the model you've specified for an Item from a blockstates file when it can't find an item model with that name. I have a more detailed description of the model loading process and how ModelResourceLocations are mapped to models here.

     

    Are you sure you have a blockstates file called assets/test_mod/blockstates/item_variants.json with the variants test_mod:item_variants_atest_mod:item_variants_b and test_mod:item_variants_c? Variants don't usually have a domain, they're just a single string.

     

    Post your blockstates file and its path.

    private void registerItemModelForMeta(final Item item, final int metadata, final ModelResourceLocation modelResourceLocation) {
    	    	
    	System.out.println(modelResourceLocation.toString());
    	ModelLoader.setCustomModelResourceLocation(item, metadata, modelResourceLocation);
    }

    That prints :

    [15:04:37] [main/INFO] [STDOUT]: [net.dylem.test_mod.init.ModItems$ModelHandler:registerItemModelForMeta:146]: test_mod:item_variants#test_mod:item_variants=a
    [15:04:37] [main/INFO] [STDOUT]: [net.dylem.test_mod.init.ModItems$ModelHandler:registerItemModelForMeta:146]: test_mod:item_variants#test_mod:item_variants=b
    [15:04:37] [main/INFO] [STDOUT]: [net.dylem.test_mod.init.ModItems$ModelHandler:registerItemModelForMeta:146]: test_mod:item_variants#test_mod:item_variants=c

     

    Here is the json :

    {
        "forge_marker": 1,
        "defaults": {
            "model": "item/generated"
        },
        "variants": {
            "variant": {
                "a": {
                    "textures": {
                        "layer0": "test_mod:items/variants.a"
                    }
                },
                "b": {
                    "textures": {
                        "layer0": "test_mod:items/variants.b"
                    }
                },
                "c": {
                    "textures": {
                        "layer0": "test_mod:items/variants.c"
                    }
                }
            }
        }
    }

    From what you did in your mod, that should work, shouldn't it ?

  4. 3 hours ago, Choonster said:

    The logging of missing models was broken in Forge 1.12-14.21.0.2363 (commit dc043ac) and fixed in Forge 1.12-14.21.1.2390 (commit ede05a2). Update Forge and run Minecraft again to see the model errors.

    Thanks, I get the error now. Here it is : https://pastebin.com/0yRa9HMw

    Apparently it says it doesn't find the file item_variants.json.

    I thought I only needed the jsons for the variants ? I'm a bit confused. Do I need to set the first variant as the "base" and redirect to the other variants from its json ?

  5. Hello, I tried to make variants for an item and I get a NullPointerException from this function (which is taken from ItemDye class) :

     

    @Override
    public String getUnlocalizedName(ItemStack stack) {
    
      int i = stack.getMetadata();
      return super.getUnlocalizedName() + "." + EnumVariant.byMetadata(i).getName();
    }

     

    However, when I remove the function, my 3 variants have the same unlocalized name so it doesn't load textures or names.

     

    Crash logs : https://pastebin.com/WcPiNHMb

    Full project code on github : https://github.com/dylem/DylemTestMod

  6. On 7/7/2017 at 9:15 AM, IceMetalPunk said:

    So you want to replace only *some* Jungle Hills with your biome, but not all? That's the opposite of what you said ("every biome of a certain type").

    I'd suggest you use the same method, but before you overwrite the Jungle Hills registry entry, you grab it and store it with Biome.getBiomeForId(int id) (for Jungle Hills, the registerBiomes method shows an ID of 22, for reference). Then replace the registry entry with your own, passing the captured Jungle Hills biome to the constructor for storage. Then, in your own Biome class, you can call the default Biome's methods whenever you want (for instance, call the default 90% of the time, but skip that and call your own the other 10%).

    Yes sorry, only few should be replaced. That method would override gen layers on jungler hills I think

     

    On 7/7/2017 at 9:55 AM, LexManos said:

    No, Biomes are a full registry, use the Register<Biome> event and just register yours as the name that you wanna override.

    All other methods are hacky and you shouldn't do it.

     

    But it more sounds like you just want to add a variant to the jungle biome instead of overriding it... Just make them 1/10th the weight of the vanilla one.

     

    I want to replace the jungle hills biome because I want my biome to be surrounded by jungle. But I'm making a GenLayer, sounds easier now..

  7. 10 minutes ago, IceMetalPunk said:

    I don't know if this is the best way, but there is a Biome Registry (Biome#REGISTRY) which maps all the resource locations to biome classes. You could, I suppose, replace the class associated with the resource location of your choosing with your own biome class. The registry is public, so you should be able to just call, for instance, Biome.REGSITRY.register(plainsID, new ResourceLocation("minecraft", "plains"), new MyNewPlainsBiome()) or something similar. The plainsID is the ID of the plains biome (1), but depending on which biome you're replacing, you'll need to change that to the proper ID (they can all be found in the Biome#registerBiomes method). That should work (though I'm not 100% sure, so test it out).

     

    Never mind; there's a much better way to do this. Just call Biome.registerBiome(ID_TO_OVERWRITE, "biome_name", new YourBiome()), with the arguments changed to the appropriate values (ID_TO_OVERWRITE being the IDs from Biome#registerBiomes, same with the name, and then an instance of your actual biome class).

    That would be nice, but I want the biome to be replaced with a random factor (to explain, I want to replace jungle hills with my own biome but it should be rare enough that the player doesn't feel like my mod changes the game).

  8. Hello,

    I was wondering if there was a documentation for all these p_(inert number here) variable ?

     

    For example, a function from GenLayer :

        /**
         * returns the most frequently occurring number of the set, or a random number from those provided
         */
        protected int selectModeOrRandom(int p_151617_1_, int p_151617_2_, int p_151617_3_, int p_151617_4_)
        {
            if (p_151617_2_ == p_151617_3_ && p_151617_3_ == p_151617_4_)
            {
                return p_151617_2_;
            }
            else if (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_3_)
            {
                return p_151617_1_;
            }
            else if (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_4_)
            {
                return p_151617_1_;
            }
            else if (p_151617_1_ == p_151617_3_ && p_151617_1_ == p_151617_4_)
            {
                return p_151617_1_;
            }
            else if (p_151617_1_ == p_151617_2_ && p_151617_3_ != p_151617_4_)
            {
                return p_151617_1_;
            }
            else if (p_151617_1_ == p_151617_3_ && p_151617_2_ != p_151617_4_)
            {
                return p_151617_1_;
            }
            else if (p_151617_1_ == p_151617_4_ && p_151617_2_ != p_151617_3_)
            {
                return p_151617_1_;
            }
            else if (p_151617_2_ == p_151617_3_ && p_151617_1_ != p_151617_4_)
            {
                return p_151617_2_;
            }
            else if (p_151617_2_ == p_151617_4_ && p_151617_1_ != p_151617_3_)
            {
                return p_151617_2_;
            }
            else
            {
                return p_151617_3_ == p_151617_4_ && p_151617_1_ != p_151617_2_ ? p_151617_3_ : this.selectRandom(p_151617_1_, p_151617_2_, p_151617_3_, p_151617_4_);
            }
        }

     

    This function is pretty easy to understand as it is commented, but some aren't and sometimes waste me a lot of time for nothing.

    Is there really an interest in giving random-looking names to variables ? Is there a documentation about how they name their variables ?

     

  9. Just adding a comment to say that I found a very easy way to do it.

    Simply :

    public static LootEntry entry = new LootEntryItem(
    			StyxItems.ANCIENT_COMPASS, 100, 50, new LootFunction[0], new LootCondition[0], "styx:loot_ancient_compass");
    	
    	@SubscribeEvent
    	public void onLootTableLoad(final LootTableLoadEvent event) {
    		
                if(event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) {
            	
                    event.getTable().getPool("main").addEntry(entry);
                }
    	}

     

    That works surprisingly well and I don't have to override anything from Minecraft files.

×
×
  • Create New...

Important Information

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