Jump to content

Kfir40Forge

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Kfir40Forge

  1. 3 minutes ago, diesieben07 said:

    Yes, thats how you would do it.

     

     

    No.

    Well that's... confusing.

    Well whatever, this is what I do now:

    public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
    
    public static final RegistryObject<Item> CHAINMAIL_PLATE = ITEMS.register("chainmail_plate", () -> new Item(new Item.Properties().group(ItemGroup.MISC)));

    Anyway, it works now! Only problem is that JEI still shows iron ingots in the repair recipe.

  2. 3 minutes ago, diesieben07 said:

    You are not using @ObjectHolder correctly. When put in a field it must hold a registry name, not a resource domain.

    So it was staying "null", and some part of the process detected that and undid it or something??? Because I saw no NPEs in the log. Regardless... whoops.

    @ObjectHolder("MOD_ID_HERE");
    class ModThing {
    	@ObjectHolder("ITEM_REGISTRY_NAME_HERE");
    	public static final Item ITEM_THINGY = null;
    }

    Is this how it's done, or does

    @Mod

    imply

    @ObjectHolder

    ?

    5 minutes ago, diesieben07 said:

    Any reason you are not using DeferredRegister?

    I had no idea it existed. Will change to it.

  3. 10 minutes ago, Alpvax said:

    I believe that isn't the case any more, with forge >= 1.13 (since the complete rewrite) unless something has changed recently.

    Forge 1.13+ support has been fixed on the develop branch (which is pretty stable RN). In fact, that branch has (the startings of) a Twitch modpack browser!

  4. This doesn't seem to work...

    @ObjectHolder(MODID)
    public static final Item CHAINMAIL_PLATE = null;
    
    public ExampleMod() {
    	FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
    }
    
    private void setup(FMLCommonSetupEvent e) {
    	DeferredWorkQueue.runLater(ExampleMod::doReplaceChainmailRepairMaterial);
    }
    
    private static final String OBSFUCATED_FIELD_NAME_ARMORMATERIAL_REPAIRMATERIAL = "field_200914_m";
    
    static void doReplaceChainmailRepairMaterial() {
    	try {
    		ObfuscationReflectionHelper.setPrivateValue(
    				ArmorMaterial.class,
    				ArmorMaterial.CHAIN,
    				new LazyLoadBase<>(() -> Ingredient.fromItems(CHAINMAIL_PLATE)),
    				OBSFUCATED_FIELD_NAME_ARMORMATERIAL_REPAIRMATERIAL);
    	} catch(ObfuscationReflectionHelper.UnableToFindFieldException e) {
    		throw new RuntimeException("Could not find field ArmorMaterial.CHAIN.repairMaterial", e);
    	} catch(ObfuscationReflectionHelper.UnableToAccessFieldException e) {
    		throw new RuntimeException("Could not access field ArmorMaterial.CHAIN.repairMaterial", e);
    	}
    }

    No exceptions, it just doesn't have any effect in-game.

    Full code: https://github.com/Leo40Git/CraftableChainmail/blob/1.14.4/src/main/java/adudecalledleo/craftablechainmail/CraftableChainmail.java

×
×
  • Create New...

Important Information

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