How do I have a block run a function every few ticks while it is on the world?
I have looked at the Hopper and Repeater blocks and I can't figure it out.
It looks like the "tick" method on a Block is deprecated, but it doesn't say anything about what to replace it with.
It looks like `getAllRecipesFor` is returning a List of CraftingRecipe, because this is valid:
List<CraftingRecipe> recipes = world.getRecipeManager().getAllRecipesFor(RecipeType.CRAFTING);
for (CraftingRecipe recipe : recipes) {
// ...
}
I have tried doing this:
Item result = recipe.getResultItem(RegistryAccess.EMPTY).getItem();
NonNullList<Ingredient> in = recipe.getIngredients();
for (Ingredient i : in) {
for (ItemStack stack : i.getItems()) {
Item ingredient = stack.getItem();
}
}
But this seems like a roundabout way of doing this, and I'm not sure whether it works. And I'm not sure why each Ingredient contains a list of items.
Then what?
List<CraftingRecipe> recipes = world.getRecipeManager().getAllRecipesFor(RecipeType.CRAFTING);
for (CraftingRecipe recipe : recipes) {
// ...
}
How do I get Item objects for the ingredients and result?
I want to get a list of all the recipes, even ones defined in other mods.
I found net.minecraft.world.item.crafting.Recipe, but I have no idea how to get a list of these.
I have searched online, but most answers mention ForgeRegistries.RECIPES, which doesn't exist anymore.
I'm trying to display some text in the player's action bar:
player.displayClientMessage(SomeComponent, true);
But I'm having trouble creating a newline (that would create two lines of text).
I tried this, but it doesn't work:
Component.literal("\n")
Anyone have any idea how to do this?
I want to make the player jump. Simple as that.
I have tried already:
net.minecraft.world.entity.player.Player player;
player.jumpFromGround(); // doesn't work
player.setJumping(true); // doesn't work
I can't believe no one has already asked this...
How do I create a GUI with text and buttons, like you see in MCreator?
Note: Text and buttons are the only two things I am going to want to add.