Jump to content

JoasJSD

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by JoasJSD

  1. Can you give us a list of the mods that you've installed and also a list of the mods you need for the server?
  2. So I've been trying to make a custom furnace block for my mod, but whenever I go into Minecraft, the menu doesn't pop up when right clicking on the block This is my code: Knakworst Oven Entity Class: package net.iegeliers.themakkersmod.block.custom.entity; import net.iegeliers.themakkersmod.menu.MenuKnakworstOven; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.NotNull; public class BlockEntityKnakworstOven extends AbstractFurnaceBlockEntity { public BlockEntityKnakworstOven(BlockPos blockPos, BlockState blockState) { super(TMMBlockEntity.KNAKWORST_OVEN.get(), blockPos, blockState, RecipeType.SMELTING); } protected @NotNull Component getDefaultName() { return Component.translatable("block.themakkersmod.knakworst_oven"); } protected @NotNull AbstractContainerMenu createMenu(int id, @NotNull Inventory inventory) { return new MenuKnakworstOven(id, inventory, this, this.dataAccess); } @Override protected int getBurnDuration(@NotNull ItemStack itemStack) { return (super.getBurnDuration(itemStack) * 3) / 2; } } Block Entities Class: package net.iegeliers.themakkersmod.block.custom.entity; import net.iegeliers.themakkersmod.TheMakkersMod; import net.iegeliers.themakkersmod.block.TMMBlocks; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class TMMBlockEntity { public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, TheMakkersMod.MODID); public static final RegistryObject<BlockEntityType<BlockEntityKnakworstOven>> KNAKWORST_OVEN = BLOCK_ENTITIES.register("knakworst_oven", () -> BlockEntityType.Builder.of (BlockEntityKnakworstOven::new, TMMBlocks.KNAKWORST_OVEN.get()).build(null) ); public static void register(IEventBus eventBus) { BLOCK_ENTITIES.register(eventBus); } } Menu Types Class: package net.iegeliers.themakkersmod.block.custom.entity; import net.iegeliers.themakkersmod.TheMakkersMod; import net.iegeliers.themakkersmod.menu.MenuKnakworstOven; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; import net.minecraftforge.common.extensions.IForgeMenuType; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.network.IContainerFactory; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class TMMMenuType { public static final DeferredRegister<MenuType<?>> MENUS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, TheMakkersMod.MODID); public static final RegistryObject<MenuType<MenuKnakworstOven>> KNAKWORST_OVEN_MENU = registerMenuType( (ID, inventory, extraData) -> new MenuKnakworstOven(ID, inventory), "knakworst_oven_menu"); private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name) { return MENUS.register(name, () -> IForgeMenuType.create(factory)); } public static void register(IEventBus eventBus) { MENUS.register(eventBus); } } Knakworst Oven Block Class: package net.iegeliers.themakkersmod.block.custom; import net.iegeliers.themakkersmod.block.custom.entity.BlockEntityKnakworstOven; import net.iegeliers.themakkersmod.block.custom.entity.TMMBlockEntity; import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.stats.Stats; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.player.Player; import net.minecraft.core.BlockPos; import net.minecraft.world.MenuProvider; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.AbstractFurnaceBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; public class BlockKnakworstOven extends AbstractFurnaceBlock { public BlockKnakworstOven(BlockBehaviour.Properties properties) { super(properties); } public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return new BlockEntityKnakworstOven(pos, state); } @Nullable public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level level, @NotNull BlockState blockState, @NotNull BlockEntityType<T> blockEntityType) { return createFurnaceTicker(level, blockEntityType, TMMBlockEntity.KNAKWORST_OVEN.get()); } protected void openContainer(Level level, @NotNull BlockPos blockPos, @NotNull Player player) { BlockEntity blockentity = level.getBlockEntity(blockPos); if (blockentity instanceof BlockEntityKnakworstOven) { player.openMenu((MenuProvider) blockentity); player.awardStat(Stats.INTERACT_WITH_FURNACE); } } public void animateTick(BlockState blockState, @NotNull Level level, @NotNull BlockPos blockPos, @NotNull RandomSource randomSource) { if (blockState.getValue(LIT)) { double d0 = (double) blockPos.getX() + 0.5D; double d1 = blockPos.getY(); double d2 = (double) blockPos.getZ() + 0.5D; if (randomSource.nextDouble() < 0.1D) { level.playLocalSound(d0, d1, d2, SoundEvents.FURNACE_FIRE_CRACKLE, SoundSource.BLOCKS, 1.0F, 1.0F, false); } Direction direction = blockState.getValue(FACING); Direction.Axis direction$axis = direction.getAxis(); double d4 = randomSource.nextDouble() * 0.6D - 0.3D; double d5 = direction$axis == Direction.Axis.X ? (double) direction.getStepX() * 0.52D : d4; double d6 = randomSource.nextDouble() * 6.0D / 16.0D; double d7 = direction$axis == Direction.Axis.Z ? (double) direction.getStepZ() * 0.52D : d4; level.addParticle(ParticleTypes.SMOKE, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D); level.addParticle(ParticleTypes.FLAME, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D); } } } Knakworst Oven Menu Class: package net.iegeliers.themakkersmod.menu; import net.iegeliers.themakkersmod.block.custom.entity.TMMMenuType; import net.minecraft.world.Container; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.*; import net.minecraft.world.item.crafting.RecipeType; public class MenuKnakworstOven extends AbstractFurnaceMenu { public MenuKnakworstOven(int p_39532_, Inventory p_39533_) { super(TMMMenuType.KNAKWORST_OVEN_MENU.get(), RecipeType.SMELTING, RecipeBookType.FURNACE, p_39532_, p_39533_); } public MenuKnakworstOven(int p_39535_, Inventory p_39536_, Container p_39537_, ContainerData p_39538_) { super(TMMMenuType.KNAKWORST_OVEN_MENU.get(), RecipeType.SMELTING, RecipeBookType.FURNACE, p_39535_, p_39536_, p_39537_, p_39538_); } } Knakworst Oven Screen Class: package net.iegeliers.themakkersmod.screen; import net.iegeliers.themakkersmod.menu.MenuKnakworstOven; import net.minecraft.client.gui.screens.inventory.AbstractFurnaceScreen; import net.minecraft.client.gui.screens.recipebook.SmeltingRecipeBookComponent; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; public class ScreenKnakworstOven extends AbstractFurnaceScreen<MenuKnakworstOven> { private static final ResourceLocation TEXTURE = new ResourceLocation("textures/gui/container/furnace.png"); public ScreenKnakworstOven(MenuKnakworstOven menu, Inventory inventory, Component component) { super(menu, new SmeltingRecipeBookComponent(), inventory, component, TEXTURE); } @Override public void init() { super.init(); } } I registered both the Block Entities and Menu Types classes and I also registered the menuscreens in my mod's main class and yet the menu still isn't showing. Can anyone help?
  3. Hey there, For my mod I'm trying to make a custom furnace recipe type because I want some items to be only smelted in that specific furnace, but it doesn't work for me. I tried looking at Minecraft's code, I tried looking for tutorials but it all didn't help me. If someone can help me out, please let me know
×
×
  • Create New...

Important Information

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