Jump to content

Recommended Posts

Posted

In my mod i have some item Substitution Aliases that I register with 

 

@SubscribeEvent

public void onRegisterItem(RegistryEvent.Register<Item> event) {

    try {

        GameRegistry.addSubstitutionAlias("minecraft:compass", GameRegistry.Type.ITEM, GiacomosTeleport.myCompass);

        GameRegistry.addSubstitutionAlias("minecraft:map", GameRegistry.Type.ITEM, GiacomosTeleport.myEmptyMap);

        GameRegistry.addSubstitutionAlias("minecraft:filled_map", GameRegistry.Type.ITEM, GiacomosTeleport.myFilledyMap);

    } catch (ExistingSubstitutionException e) {

        e.printStackTrace();

    }

}

 

But recipes and trades that use aliased items seem broken.

I try to fix this in the init method:

 

@EventHandler

public void init(FMLInitializationEvent event) {

 

//Overwriting some recipes to fix bugs: recipes that use maps or compasses are broken!!!

RecipeSorter.register(MODID + ":mapextending", RecipesMyMapExtending.class, SHAPED, "after:minecraft:shaped before:minecraft:shapeless");

RecipeSorter.register(MODID + ":mapcloning", RecipesMyMapCloning.class, SHAPELESS, "after:minecraft:shaped before:minecraft:shapeless");

GameRegistry.addRecipe(new RecipesMyMapExtending());

GameRegistry.addRecipe(new RecipesMyMapCloning());

 

GameRegistry.addShapedRecipe(new ItemStack(myEmptyMap), "ppp", "pbp", "ppp", 'b', Items.COMPASS, 'p', Items.PAPER);

GameRegistry.addShapedRecipe(new ItemStack(myCompass), " i ", "iri", " i ", 'r', Items.REDSTONE, 'i', Items.IRON_INGOT);

 

//Overwriting items in trades: Fix cartographer trade compass for emeralds!!! 

VillagerProfession profession = VillagerRegistry.getById(1);

VillagerCareer career = profession.getCareer(1);

EmeraldForItems trade = (EmeraldForItems) career.getTrades(1).get(0);

 

trade.buyingItem = Items.COMPASS;

 

}

 

This way it seems to work but is this the right way? 

Posted

This is a teleport mod. The player can teleport by using a compass or a map. In the method Item.onItemUseFinish is where the teleport is implemented.

Posted

So the suggestion is to avoid using substitution aliases... 

And I also think so, but in ItemMyCompass I have other stuff for handling enchantments: only enchanted compasses and maps can be used to teleport.

And the player should perform and animation during the cast.

The question is how to make substitution aliases work with trades and recipes?

 

Posted

Yes, you are right! I implemented the teleport with events you suggested and it works fine!

There are still two things I do not know how to do:

1) How to set an animation during item usage (using compasses with the bow animation was funny)

2) When an empty map is rightclicked  i want to add to the resulting filled map a tag that contains the coordinates where the map was created to use for teleport back there

    

 

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.