Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Luis_ST

Members
  • Joined

  • Last visited

Everything posted by Luis_ST

  1. okay thanks but now i got an error when i place the block. beacuse i not init my Recipe Serializer so now my question is there a special way to register the serializer or can I use DeferredRegister <IRecipeSerializer <?>>
  2. What do you mean by "declare correctly" should I replace my container (SmeltingContainer) with generally all Containers (Container class). So what do i have to do. I understand the problem but don't know how to fix it
  3. event.enqueueWork(() -> ScreenManager.registerFactory(CaveContainer.SMELTING_CONTAINER.get(), SmeltingScreen::new)); why does it not work that way (at SmeltingSreen::new) my screen extends the vanilla Furnace screen and the constructor looks like the vanilla one: package net.luis.cave.blocks.container; import net.minecraft.client.gui.screen.inventory.AbstractFurnaceScreen; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class SmeltingScreen extends AbstractFurnaceScreen<SmeltingContainer> { private static final ResourceLocation FURNACE_GUI_TEXTURES = new ResourceLocation("textures/gui/container/furnace.png"); public SmeltingScreen(SmeltingContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, null, inv, titleIn, FURNACE_GUI_TEXTURES); } } this is the factory: create(T p_create_1_, PlayerInventory p_create_2_, ITextComponent p_create_3_); so i dont understand why my IDE show me an error ("The type SmeltingScreen does not define SmeltingScreen(M, PlayerInventory, ITextComponent) that is applicable here")
  4. I already registered it but forgot to add the registration to my mod constructor I tested it again and it still doesn't work and the consol show this: [10:19:50] [Render thread/WARN] [minecraft/ScreenManager]: Failed to create screen for menu type: cave:smelting_container I know where the error is coming from I still have to create a screen but where do I have to register / pass the container
  5. i think you have to change the light from where it comes from. the options are "side light" and "front light" since your model is visible from the front and is not sloping, you have to change the option to "front light"
  6. I've tested it with the NetworkHooks and the gui still won't open
  7. so like this: @Override protected void interactWith(World worldIn, BlockPos pos, PlayerEntity player) { TileEntity tileentity = worldIn.getTileEntity(pos); if (player instanceof ServerPlayerEntity && tileentity instanceof SmeltingFurnaceTileEntity) { NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tileentity, pos); } }
  8. in the tileEntity? I've never used that before a few more information would be helpful
  9. another question about my container. i can't open it on rightclicked my block but why? Block: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/blocks/SmeltingFurnace.java the tile Entity: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/blocks/tileentity/SmeltingFurnaceTileEntity.java and my container: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/blocks/container/SmeltingContainer.java
  10. i just edit the recipe class / serializer class now is this correct? package net.luis.cave.blocks.recipes; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import net.luis.cave.init.CaveRecipe; import net.luis.cave.init.blocks.CaveBlocks; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.AbstractCookingRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; import net.minecraftforge.registries.ForgeRegistryEntry; public class SmeltingRecipe extends AbstractCookingRecipe { public static int time; @SuppressWarnings("static-access") public SmeltingRecipe(ResourceLocation idIn, String groupIn, Ingredient ingredientIn, ItemStack resultIn, float experienceIn, int cookTimeIn) { super(IRecipeType.register("cave_smelting"), idIn, groupIn, ingredientIn, resultIn, experienceIn, cookTimeIn); this.time = cookTimeIn; } @Override public ItemStack getIcon() { return new ItemStack(CaveBlocks.SMELTING_FURNACE.get()); } @Override public IRecipeSerializer<?> getSerializer() { return CaveRecipe.SMELTING_RECIPE.get(); } public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<SmeltingRecipe> { @Override @SuppressWarnings("deprecation") public SmeltingRecipe read(ResourceLocation recipeId, JsonObject json) { String s = JSONUtils.getString(json, "group", ""); JsonElement jsonelement = (JsonElement) (JSONUtils.isJsonArray(json, "ingredient") ? JSONUtils.getJsonArray(json, "ingredient") : JSONUtils.getJsonObject(json, "ingredient")); Ingredient ingredient = Ingredient.deserialize(jsonelement); ItemStack itemstack; if (!json.has("result")) { throw new JsonSyntaxException("Missing result, expected to find a string or object"); } if (json.get("result").isJsonObject()) { itemstack = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result")); } else { String s1 = JSONUtils.getString(json, "result"); ResourceLocation resourcelocation = new ResourceLocation(s1); itemstack = new ItemStack(Registry.ITEM.getOptional(resourcelocation).orElseThrow(() -> { return new IllegalStateException("Item: " + s1 + " does not exist"); })); } float f = JSONUtils.getFloat(json, "experience", 0.0F); int i = JSONUtils.getInt(json, "cookingtime", SmeltingRecipe.time); return new SmeltingRecipe(recipeId, s, ingredient, itemstack, f, i); } @Override public SmeltingRecipe read(ResourceLocation recipeId, PacketBuffer buffer) { String s = buffer.readString(32767); Ingredient ingredient = Ingredient.read(buffer); ItemStack itemstack = buffer.readItemStack(); float f = buffer.readFloat(); int i = buffer.readVarInt(); return new SmeltingRecipe(recipeId, s, ingredient, itemstack, f, i); } @Override public void write(PacketBuffer buffer, SmeltingRecipe recipe) { buffer.writeString(recipe.group); recipe.ingredient.write(buffer); buffer.writeItemStack(recipe.result); buffer.writeFloat(recipe.experience); buffer.writeVarInt(recipe.cookTime); } } }
  11. i currently creat this: 1. is this correct? 2. i have to set the cookingTime but it's a private field so can i create a own one or should i use ObfuscationReflectionHelper to get the field public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<SmeltingRecipe> { @Override @SuppressWarnings("deprecation") public SmeltingRecipe read(ResourceLocation recipeId, JsonObject json) { String s = JSONUtils.getString(json, "group", ""); JsonElement jsonelement = (JsonElement) (JSONUtils.isJsonArray(json, "ingredient") ? JSONUtils.getJsonArray(json, "ingredient") : JSONUtils.getJsonObject(json, "ingredient")); Ingredient ingredient = Ingredient.deserialize(jsonelement); ItemStack itemstack; if (!json.has("result")) { throw new JsonSyntaxException("Missing result, expected to find a string or object"); } if (json.get("result").isJsonObject()) { itemstack = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result")); } else { String s1 = JSONUtils.getString(json, "result"); ResourceLocation resourcelocation = new ResourceLocation(s1); itemstack = new ItemStack(Registry.ITEM.getOptional(resourcelocation).orElseThrow(() -> { return new IllegalStateException("Item: " + s1 + " does not exist"); })); } float f = JSONUtils.getFloat(json, "experience", 0.0F); // int i = JSONUtils.getInt(json, "cookingtime", cookingTime); return new SmeltingRecipe(recipeId, s, ingredient, itemstack, f, 0); } @Override public SmeltingRecipe read(ResourceLocation recipeId, PacketBuffer buffer) { String s = buffer.readString(32767); Ingredient ingredient = Ingredient.read(buffer); ItemStack itemstack = buffer.readItemStack(); float f = buffer.readFloat(); int i = buffer.readVarInt(); return new SmeltingRecipe(recipeId, s, ingredient, itemstack, f, i); } @Override public void write(PacketBuffer buffer, SmeltingRecipe recipe) { buffer.writeString(recipe.group); recipe.ingredient.write(buffer); buffer.writeItemStack(recipe.result); buffer.writeFloat(recipe.experience); buffer.writeVarInt(recipe.cookTime); } }
  12. I found out that I need to create a serializer class in my recipe, but I don't understand what to do in the class, is there a forge documentation or can i copy the read and write methods from the CookingRecipeSerializer when i return my SmeltingRecipe
  13. have I to implement / extend IRecipeSerializer? now i creat this package net.luis.cave.init; import net.luis.cave.blocks.recipes.SmeltingRecipe; import net.minecraft.item.crafting.CookingRecipeSerializer; import net.minecraft.item.crafting.IRecipeSerializer; public class CaveRecipeSerializer { CookingRecipeSerializer<SmeltingRecipe> CAVE_SMELTING = IRecipeSerializer.register("cave_smelting", new CookingRecipeSerializer<>(SmeltingRecipe::new, 100)); } but i got an error: "The type CookingRecipeSerializer.IFactory<SmeltingRecipe> from the descriptor computed for the target context is not visible here."
  14. So do I have to create another class for the serializer even if I already have a recipe class? https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/blocks/recipes/SmeltingRecipe.java and from which class extends the Serializer?
  15. I found. I had to add a Packetbuffer i don't know what i need it for but the container works. but how to get the serializer
  16. my IDE show this error: "The type SmeltingContainer does not define SmeltingContainer(int, PlayerInventory, PacketBuffer) that is applicable here" this is my container class: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/blocks/container/SmeltingContainer.java i mean the recipe serializer this is my registration class: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/main/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/init/CaveRecipe.java and my recipe serializer class: https://github.com/Luis-st/Forge-1.16.5-36.0.1-mdk/blob/b55bad37a4e156a1cbc7979697809e027e3a4589/forge-1.16.5-36.0.1-mdk/src/main/java/net/luis/cave/blocks/recipes/SmeltingRecipe.java#L12 like this: public static final RegistryObject<IRecipeSerializer<?>> SMELTING_RECIPE = RECIPE_SERIALIZERS.register("smelting_recipe", SmeltingRecipe::new); but i get the same error: "The type SmeltingRecipe does not define SmeltingRecipe() that is applicable here" So what am I doing wrong / where is the mistake
  17. and for more information just read my post at the beginning
  18. you have to create a normal block but you have to register it with the minecraft id public static final DeferredRegister<Item> VANILLA_ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Minecraft_Id); public static final RegistryObject<Item> SUGAR = VANILLA_ITEMS.register("sugar", Sugar::new); package net.luis.cave.items.vanilla; import net.minecraft.item.Food; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; public class Sugar extends Item { @SuppressWarnings("deprecation") public Sugar() { super(new Item.Properties() .group(ItemGroup.FOOD) .food(new Food.Builder() .hunger(2) .saturation(1.0f) .effect(new EffectInstance(Effects.SPEED, 300, 3), 1) .setAlwaysEdible() .build())); } } this is my overwriting of sugar, but it works also with blocks (you have to change ForgeRegistries)
  19. Okay thanks, but the more important question is how to properly register the container and recipe because that's the reason why i ask? public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, Cave.Mod_Id); public static final RegistryObject<ContainerType<?>> SMELTING_CONTAINER = CONTAINERS.register("smelting_container", () -> IForgeContainerType.create(null)); and public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, Cave.Mod_Id); public static final RegistryObject<IRecipeSerializer<?>> SMELTING_RECIPE = RECIPE_SERIALIZERS.register("smelting_recipe", null);
  20. But back to my questions
  21. normal furnace - No. I think you don't understand exactly what I want, so simplified I want recipes for a custom furnace with the same gui like the vanilla furnace Short: I want custom recipes that only work in my furnace
  22. i not want to use the normal recipes that already work but minecraft has the blast furnace which smelt ores and the smoker which "cook" food. i want to creat a furnace which process / smelt the other recipes faster (like cobblestone to stone in 5 seconds instead of 10 seconds)
  23. i just creat a block which is called smelting furnace it should be a faster furnace for the default smelting recipes (like stone, clay, etc.). At the moment the block has the normal furnace container and the normal recipes and i try to creat custom (container and recipe), but now im stuck. 1. registration of container: - i creat a container which extends the vanilla AbstractFurnaceContainer public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, Cave.Mod_Id); public static final RegistryObject<ContainerType<?>> SMELTING_CONTAINER = CONTAINERS.register("smelting_container", () -> IForgeContainerType.create(SmeltingContainer::new)); but i cant register the container/ why doesn't work that way 2. registration of recipe serializer - how to register a custom AbstractCookingRecipe and how to create form that a IRecipeType which i need for the container public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, Cave.Mod_Id); public static final RegistryObject<IRecipeSerializer<?>> SMELTING_RECIPE = RECIPE_SERIALIZERS.register("smelting_recipe", null); what i have to set at "null"
  24. did you get an error
  25. did you added the registration to your mod class constructor like this: yourClass.RECIPE_SERIALIZERS.register(FMLJavaModLoadingContext.get().getModEventBus());

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.