Jump to content

Recommended Posts

Posted (edited)

It's me again. I got the custom crafting table to work – it appears in the world, I can open it, and it doesn't close right away, which is always a plus. However, it doesn't seem my new recipe type has registered. Here is a picture of my directory to see which classes I copied over.

How am I supposed to register a new recipe type?

Screen Shot 2020-05-14 at 7.45.10 PM.png

Edited by TheThorneCorporation
  • Thanks 1
Posted (edited)

debug.logBumping because I can't figure out how to register the Recipe/RecipeSerializer.

I have this class to store the advanced crafting recipe type:

public interface IThorneRecipeType<T extends IRecipe<?>> extends IRecipeType<T> {
   IRecipeType<IAdvancedCraftingRecipe> ADVANCED_CRAFTING = register("advanced_crafting");

   static <T extends IRecipe<?>> IThorneRecipeType<T> register(final String key) {
      return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(key), new IThorneRecipeType<T>() {
         public String toString() {
            return key;
         }
      });
   }

   default <C extends IInventory> Optional<T> matches(IRecipe<C> recipe, World worldIn, C inv) {
      return recipe.matches(inv, worldIn) ? Optional.of((T)recipe) : Optional.empty();
   }
}

which should have registered the recipe type. (I'm doing both shapeless and shaped advanced crafting recipes.)

I also have this class which should have registered the advanced recipe type serializers:

public interface IThorneRecipeSerializer<T extends IRecipe<?>> extends IRecipeSerializer<T> {

	IRecipeSerializer<ShapelessAdvancedRecipe> ADVANCED_CRAFTING_SHAPELESS = register("advanced_crafting_shapeless", new ShapelessAdvancedRecipe.Serializer());
	IRecipeSerializer<ShapedAdvancedRecipe> ADVANCED_CRAFTING_SHAPED = register("advanced_crafting_shaped", new ShapedAdvancedRecipe.Serializer());

	static <S extends IRecipeSerializer<T>, T extends IRecipe<?>> S register(String key, S recipeSerializer) {
		return IRecipeSerializer.register(key, recipeSerializer);
	}
}

The recipe still isn't registering, though. Am I supposed to use a RegistryEvent or something?

 

Edited by TheThorneCorporation
Oops, wrong log.
Posted

First, extending an interface is arbitrary the way you are doing it. IRecipeType does not need to be extended and can be just declared a static final variable using IRecipeType#register. Second, IRecipeSerializer needs to be extended on a ForgeRegistryEntry class. The reason I say this is even though you might have already done it is that if you looked at the original class, you can see it extends a basic implementation of a registry. So yes, you do need a RegistryEvent using the old method or could update to using DeferredRegister and RegistryObject.

 

 

  • Like 1
Posted (edited)

Okay, I rewrote IThorneRecipeSerializer like this:

public interface IThorneRecipeSerializer<T extends IRecipe<?>> extends IRecipeSerializer<T> {

	public static IRecipeSerializer<ShapelessAdvancedRecipe> ADVANCED_CRAFTING_SHAPELESS = register("advanced_crafting_shapeless", new ShapelessAdvancedRecipe.Serializer());
	public static IRecipeSerializer<ShapedAdvancedRecipe> ADVANCED_CRAFTING_SHAPED = register("advanced_crafting_shaped", new ShapedAdvancedRecipe.Serializer());

	static <S extends IRecipeSerializer<T>, T extends IRecipe<?>> S register(String key, S recipeSerializer) {
		return IRecipeSerializer.register(key, recipeSerializer);
	}
}

 

and added this to my RegistryEvents:

@SubscribeEvent
public static void registerRecipeSerializers(final RegistryEvent.Register<IRecipeSerializer<?>> event) {
	event.getRegistry().registerAll
	(
		IThorneRecipeSerializer.ADVANCED_CRAFTING_SHAPED,
		IThorneRecipeSerializer.ADVANCED_CRAFTING_SHAPELESS
	);
}

 

but it's still not working.

I'll work on getting a GitHub repo up.

Edited by TheThorneCorporation

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
    • Necro'ing that thread to ask if you found a solution ? I'm encountering the same crash on loading the world. I created the world in Creative to test my MP, went into survival to test combat, died, crashed on respawn and since then crash on loading the world. Deactivating Oculus isn't fixing it either, and I don't have Optifine (Twilight forest is incompatible)
  • Topics

×
×
  • Create New...

Important Information

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