Jump to content

Recommended Posts

Posted

Okay, so - I have an item "craftablechainmail:chainmail_plate". I want to change the repair item of chainmail armor to this item.

...how do I do this?

Pretend my display name is "ADudeCalledLeo", please.

Discord: ADudeCalledLeo#8665

Posted

Gotcha. So, do that in an event that's run after item registration, which would be...? Is there an event list sorted by order?

Pretend my display name is "ADudeCalledLeo", please.

Discord: ADudeCalledLeo#8665

Posted (edited)

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

Edited by Kfir40Forge

Pretend my display name is "ADudeCalledLeo", please.

Discord: ADudeCalledLeo#8665

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

Pretend my display name is "ADudeCalledLeo", please.

Discord: ADudeCalledLeo#8665

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

Pretend my display name is "ADudeCalledLeo", please.

Discord: ADudeCalledLeo#8665

Posted
  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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