
Kenneth201998
Members-
Posts
77 -
Joined
-
Last visited
Everything posted by Kenneth201998
-
Try this: Create a new package: data.minecraft.tags.blocks Put the tag files in there. I think that is what I did. What this theoretically does is it appends the file to the default minecraft tags. Just try it. Also make sure you create a new world while testing it. Testing it in an already created world will still make them decay.
-
Did you set up the folders properly? Remember the data folder does not go in assets. Show me your data folder setup.
-
Name one file logs, and another to leaves. And when it comes to minecraft tags, no you do not need to add them, just make sure replace is set to false.
-
Sorry for not marking my post solved but the issue here has to do with block tags: https://minecraft.gamepedia.com/Tag Your mod has to have a file tagging your leaves block as leaves and another another tagging your log block as a log. Or something to that affect. I will be updating my post soon.
-
[1.14.4] how to make a gui progress bar?
Kenneth201998 replied to Kenneth201998's topic in Modder Support
How would I go about doing this? -
[1.14.4] how to make a gui progress bar?
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Ok so I have: package com.kenneths_medieval_mod.objects.blocks.workstations.smelting_forge; import org.lwjgl.opengl.GL11; import com.kenneths_medieval_mod.KenmodMain; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; public class SmeltingForgeGUI extends ContainerScreen<SmeltingForgeContainer> { SmeltingForgeTileEntity tile_entity; private static final ResourceLocation texture = new ResourceLocation("kenmod:textures/gui/smelting_forge_gui_1.png"); public SmeltingForgeGUI(SmeltingForgeContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { super(screenContainer, inv, titleIn); this.xSize = 176; this.ySize = 166; this.tile_entity = (SmeltingForgeTileEntity)screenContainer.tile_entity; } @Override public void render(int mouseX, int mouseY, float partialTicks) { this.renderBackground(); super.render(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getInstance().getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.blit(k, l, 0, 0, this.xSize, this.ySize); if(tile_entity != null) { //int burn_time = Math.round(24 * (100 - tile_entity.getBurnTime()) / 100); int cook_progress = Math.round(24 / tile_entity.getCookProgress()); int le = this.guiLeft; int to = this.guiTop; //this.blit(le + 17, to + 40, 176, 14, burn_time + 1, 16); this.blit(le + 67, to + 39, 176, 14, cook_progress + 1, 16); } } @Override public void tick() { super.tick(); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.font.drawString("Smelting Forge", 16, 5, -1); } @Override public void removed() { super.removed(); Minecraft.getInstance().keyboardListener.enableRepeatEvents(false); } @Override public void init(Minecraft minecraft, int width, int height) { super.init(minecraft, width, height); minecraft.keyboardListener.enableRepeatEvents(true); } } And: package com.kenneths_medieval_mod.objects.blocks.workstations.smelting_forge; import com.kenneths_medieval_mod.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class SmeltingForgeTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider { protected ItemStackHandler slots = new ItemStackHandler(); private final LazyOptional<IItemHandler> slots_holder = LazyOptional.of(() -> slots); private int burn_time; private int cook_progress; private int cook_goal = 200; public SmeltingForgeTileEntity() { super(BlockList.smelting_forge_tile_entity); slots = new ItemStackHandler(); slots.setSize(4); } @Override public void tick() { //Fuel sent to the furnace has a max fuel life. if(burn_time < 1000 && slots.getStackInSlot(0) != ItemStack.EMPTY) { burn_time++; if(cook_progress < cook_goal) { cook_progress++; } else { cook_progress = 0; } } else { //When burn time reaches max fuel life get more fuel and reset the burn timer: burn_time = 0; } } public float getCookProgress () { return Math.round(cook_progress + 1 / cook_goal); } public int getBurnTime () { return burn_time; } @Override public void read(CompoundNBT tag) { super.read(tag); slots.deserializeNBT(tag.getCompound("kenmod:slots")); burn_time = tag.getInt("kenmod:burn_time"); cook_progress = tag.getInt("kenmod:cook_progress"); } @Override public CompoundNBT write(CompoundNBT tag) { super.write(tag); tag.put("kenmodlcb:slots", slots.serializeNBT()); tag.putInt("kenmod:burn_time", burn_time); tag.putInt("kenmod:cook_progress", cook_progress); return tag; } @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return slots_holder.cast(); } return super.getCapability(cap, side); } @Override public Container createMenu(int id, PlayerInventory player_inventory, PlayerEntity player) { return new SmeltingForgeContainer(id, player_inventory, slots, this); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("block.kenmodlcb.furnace_station"); } public void openGUI (ServerPlayerEntity player) { if(!world.isRemote) { NetworkHooks.openGui(player, this, getPos()); } } } But the arrow does not update. Whats wrong? -
[1.14.4] how to make a gui progress bar?
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Can you help me with this? I am not sure where you are getting your numbers in you blit function from but I can give you the GUI I created so you can help me get those numbers: There is a free program: https://pixlr.com/editor/ It allows you to see the coordinates of each pixel by hovering over the image. -
[1.14.4] how to make a gui progress bar?
Kenneth201998 replied to Kenneth201998's topic in Modder Support
where does the 40 come from in you blit function? -
[1.14.4] how to make a gui progress bar?
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Im talking about the arrow and flame you see in the furnace gui... -
I am so close to finishing my custom furnace yet this is the last obstacle I face. Any idea how to go about doing this?
-
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Whatever I did seems to work. My furnace is now fully functional and I am implementing custom recipes. -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Fixed it: @SubscribeEvent public static void registerContainer(RegistryEvent.Register<ContainerType<?>> event) { BlockList.furnace_station_container = IForgeContainerType.create(FurnaceStationContainer::new); BlockList.furnace_station_container.setRegistryName("furnace_station_container"); event.getRegistry().register(BlockList.furnace_station_container); debugString("Containers registered..."); } ^^^ New subscribe event ^^^ Thanks everyone for the help -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Ok some after those fixes it gives me another error when I right click on the block: [m[33m[09:46:36] [Client thread/WARN] [minecraft/ScreenManager]: Trying to open invalid screen with name: block.kenmodlcb.furnace_station Here is the tile entity code: package com.log_cabin_blocks.objects.blocks.workstations.furnace_station; import com.log_cabin_blocks.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class FurnaceStationTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider { protected ItemStackHandler slots = new ItemStackHandler(); private final LazyOptional<IItemHandler> slots_holder = LazyOptional.of(() -> slots); public FurnaceStationTileEntity() { super(BlockList.furnace_station_tile_entity); slots = new ItemStackHandler(); slots.setSize(3); } @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return slots_holder.cast(); } return super.getCapability(cap, side); } @Override public void read(CompoundNBT tag) { super.read(tag); slots.deserializeNBT(tag.getCompound("kenmodlcb:slots")); } @Override public CompoundNBT write(CompoundNBT tag) { super.write(tag); tag.put("kenmodlcb:slots", slots.serializeNBT()); return tag; } @Override public void tick() { } @Override public Container createMenu(int id, PlayerInventory player_inventory, PlayerEntity player) { return new FurnaceStationContainer(id, player_inventory, slots, this); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("block.kenmodlcb.furnace_station"); } public void openGUI (ServerPlayerEntity player) { if(!world.isRemote) { NetworkHooks.openGui(player, this, getPos()); } } } -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
I have changed the code to my main class by adding this: @SuppressWarnings("rawtypes") private static TileEntityType registerTileEntity (Supplier<TileEntity> supplier, String registryName, Block block, RegistryEvent.Register<TileEntityType<?>> regitstryEvent) { TileEntityType tileEntityType = TileEntityType.Builder.create(supplier, block).build(null); tileEntityType.setRegistryName(registryName); regitstryEvent.getRegistry().register(tileEntityType); return tileEntityType; } And by changing my subscribe event to this: @SuppressWarnings("unchecked") @SubscribeEvent public static void registerTileEntities (final RegistryEvent.Register<TileEntityType<?>> event) { //event.getRegistry().register(TileEntityType.Builder.create(FurnaceStationTileEntity::new, BlockList.furnace_station).build(null).setRegistryName("furnace_station")); BlockList.furnace_station_tile_entity = registerTileEntity(FurnaceStationTileEntity::new, "furnace_station", BlockList.furnace_station, event); debugString("Tile entities registered..."); } But it still gives me the same error even though I initialized it. The error keeps pointing me to the "write" method in the blocks tile entity, specifically at the line: super.write(tag) package com.log_cabin_blocks.objects.blocks.workstations.furnace_station; import com.log_cabin_blocks.LogCabinBlocks; import com.log_cabin_blocks.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class FurnaceStationTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider { protected ItemStackHandler slots = new ItemStackHandler(); private final LazyOptional<IItemHandler> slots_holder = LazyOptional.of(() -> slots); public FurnaceStationTileEntity() { super(BlockList.cabin_furnace_tile_entity); slots = new ItemStackHandler(); slots.setSize(3); } @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return slots_holder.cast(); } return super.getCapability(cap, side); } @Override public void read(CompoundNBT tag) { super.read(tag); slots.deserializeNBT(tag.getCompound("kenmodlcb:slots")); } @Override public CompoundNBT write(CompoundNBT tag) { super.write(tag); tag.put("kenmodlcb:slots", slots.serializeNBT()); return tag; } @Override public void tick() { LogCabinBlocks.debugString("TEST"); } @Override public Container createMenu(int id, PlayerInventory player_inventory, PlayerEntity player) { return new FurnaceStationContainer(id, player_inventory, slots, this); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("furnace_station"); } public void openGUI (ServerPlayerEntity player) { if(!world.isRemote) { NetworkHooks.openGui(player, this, getPos()); } } } I am sure the problem is there... I just don't know how to fix it yet. -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
package com.log_cabin_blocks; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.log_cabin_blocks.objects.blocks.BlockList; import com.log_cabin_blocks.objects.blocks.doors.KenmodDoorBase; import com.log_cabin_blocks.objects.blocks.utility_blocks.water_utility_blocks.WaterPump; import com.log_cabin_blocks.objects.blocks.walls.LogWall; import com.log_cabin_blocks.objects.blocks.walls.LogWallCorner; import com.log_cabin_blocks.objects.blocks.window_frames.WindowFrame; import com.log_cabin_blocks.objects.blocks.workstations.furnace_station.FurnaceStation; import com.log_cabin_blocks.objects.blocks.workstations.furnace_station.FurnaceStationContainer; import com.log_cabin_blocks.objects.blocks.workstations.furnace_station.FurnaceStationTileEntity; import com.log_cabin_blocks.objects.items.ItemList; import com.log_cabin_blocks.proxy.ClientProxy; import com.log_cabin_blocks.proxy.IProxy; import com.log_cabin_blocks.proxy.ServerProxy; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.inventory.container.ContainerType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.ToolType; import net.minecraftforge.common.extensions.IForgeContainerType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.simple.SimpleChannel; @Mod("kenmodlcb") public class LogCabinBlocks { public static LogCabinBlocks instance; public static final String modid = "kenmodlcb"; private static final Logger logger = LogManager.getLogger(modid); private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel PACKET_HANDLER = NetworkRegistry.newSimpleChannel(new ResourceLocation("kenmod", "kenmod"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals); public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy()); public LogCabinBlocks () { instance = this; FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries); MinecraftForge.EVENT_BUS.register(this); } private void setup (final FMLCommonSetupEvent event) { proxy.init(); debugString("Settup method registered..."); } private void clientRegistries (final FMLClientSetupEvent event) { debugString("Client registries method registered..."); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( ItemList.oak_log_wall_type_0 = new BlockItem(BlockList.oak_log_wall_type_0, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(BlockList.oak_log_wall_type_0.getRegistryName()), ItemList.oak_log_wall_type_1 = new BlockItem(BlockList.oak_log_wall_type_1, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(BlockList.oak_log_wall_type_1.getRegistryName()), ItemList.oak_log_wall_corner = new BlockItem(BlockList.oak_log_corner, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(BlockList.oak_log_corner.getRegistryName()), ItemList.oak_cabin_door = new BlockItem(BlockList.oak_cabin_door, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(BlockList.oak_cabin_door.getRegistryName()), ItemList.oak_window_frame = new BlockItem(BlockList.oak_window_frame, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(BlockList.oak_window_frame.getRegistryName()), ItemList.water_pump = new BlockItem(BlockList.water_pump, new Item.Properties().group(ItemGroup.DECORATIONS)).setRegistryName(BlockList.water_pump.getRegistryName()), ItemList.furnace_station= new BlockItem(BlockList.furnace_station, new Item.Properties().group(ItemGroup.DECORATIONS)).setRegistryName(BlockList.furnace_station.getRegistryName()) ); debugString("Items registered..."); } @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll( BlockList.oak_log_wall_type_0 = new LogWall(Block.Properties.create(Material.WOOD).hardnessAndResistance(3.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE)).setRegistryName(location("oak_log_wall_type_0")), BlockList.oak_log_wall_type_1 = new LogWall(Block.Properties.create(Material.WOOD).hardnessAndResistance(3.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE)).setRegistryName(location("oak_log_wall_type_1")), BlockList.oak_log_corner = new LogWallCorner(Block.Properties.create(Material.WOOD).hardnessAndResistance(3.0f).sound(SoundType.WOOD).harvestTool(ToolType.AXE)).setRegistryName(location("oak_log_wall_corner")), BlockList.oak_cabin_door = new KenmodDoorBase(Block.Properties.create(Material.WOOD).hardnessAndResistance(3.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE)).setRegistryName(location("oak_cabin_door")), BlockList.oak_window_frame = new WindowFrame(Block.Properties.create(Material.WOOD).hardnessAndResistance(3.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE)).setRegistryName(location("oak_window_frame")), BlockList.water_pump = new WaterPump(Block.Properties.create(Material.ROCK).hardnessAndResistance(10.0F).sound(SoundType.STONE).harvestTool(ToolType.PICKAXE)).setRegistryName(location("water_pump")), BlockList.furnace_station = new FurnaceStation(Block.Properties.create(Material.ROCK).hardnessAndResistance(10.0F).sound(SoundType.STONE).harvestTool(ToolType.PICKAXE)).setRegistryName(location("furnace_station")) ); debugString("Blocks registered..."); } //START TILE ENTITY REGISTRY @SubscribeEvent public static void registerTileEntities (final RegistryEvent.Register<TileEntityType<?>> event) { event.getRegistry().register(TileEntityType.Builder.create(FurnaceStationTileEntity::new, BlockList.furnace_station).build(null).setRegistryName("furnace_station")); debugString("Tile entities registered..."); } //END TILE ENTITY REGISTRY @SubscribeEvent public static void registerContainer(RegistryEvent.Register<ContainerType<?>> event) { event.getRegistry().register(IForgeContainerType.create((windowId, inv, data) -> { return new FurnaceStationContainer (windowId, inv, data); }).setRegistryName("furnace_station")); debugString("Containers registered..."); } } private static ResourceLocation location(String name) { return new ResourceLocation(modid, name); } public static void debugString (String toSay) { logger.info(toSay); } } -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Made major changes: Here is the tile entity: package com.log_cabin_blocks.objects.blocks.workstations.furnace_station; import com.log_cabin_blocks.LogCabinBlocks; import com.log_cabin_blocks.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class FurnaceStationTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider { protected ItemStackHandler slots = new ItemStackHandler(); private final LazyOptional<IItemHandler> slots_holder = LazyOptional.of(() -> slots); public FurnaceStationTileEntity() { super(BlockList.cabin_furnace_tile_entity); slots = new ItemStackHandler(); slots.setSize(3); } @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return slots_holder.cast(); } return super.getCapability(cap, side); } @Override public void read(CompoundNBT tag) { super.read(tag); slots.deserializeNBT(tag.getCompound("kenmodlcb:slots")); } @Override public CompoundNBT write(CompoundNBT tag) { super.write(tag); tag.put("kenmodlcb:slots", slots.serializeNBT()); return tag; } @Override public void tick() { LogCabinBlocks.debugString("TEST"); } @Override public Container createMenu(int id, PlayerInventory player_inventory, PlayerEntity player) { return new FurnaceStationContainer(id, player_inventory, slots, this); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("furnacestation"); } public void openGUI (ServerPlayerEntity player) { if(!world.isRemote) { NetworkHooks.openGui(player, this, getPos()); } } } But it still gives the missing mapping error: [1;31m[16:13:32] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception net.minecraft.crash.ReportedException: Ticking block entity at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:869) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Unknown Source) [?:1.8.0_201] {} Caused by: java.lang.NullPointerException at net.minecraft.world.World.func_217391_K(World.java:670) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:370) ~[?:?] {re:classloading} at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) ~[?:?] {re:classloading,pl:accesstransformer:B} ... 4 more [m[1;31m[16:13:32] [Server thread/ERROR] [minecraft/MinecraftServer]: This crash report has been saved to: C:\Users\carri\OneDrive\Desktop\Forge Mods\11_54 AM 11_19_2019\Log_Cabin_Blocks\run\.\crash-reports\crash-2019-11-22_16.13.32-server.txt [m[32m[16:13:32] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server [m[32m[16:13:32] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players [m[32m[16:13:32] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Dev lost connection: Disconnected [m[32m[16:13:32] [Server thread/INFO] [minecraft/MinecraftServer]: Dev left the game [m[32m[16:13:32] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Stopping singleplayer server as player logged out [m[32m[16:13:32] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds [m[32m[16:13:32] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test Area 033'/minecraft:overworld [m[1;31m[16:13:32] [Server thread/ERROR] [minecraft/Chunk]: A TileEntity type com.log_cabin_blocks.objects.blocks.workstations.furnace_station.FurnaceStationTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class com.log_cabin_blocks.objects.blocks.workstations.furnace_station.FurnaceStationTileEntity is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.tileentity.TileEntity.write(TileEntity.java:66) ~[?:?] {re:classloading} at com.log_cabin_blocks.objects.blocks.workstations.furnace_station.FurnaceStationTileEntity.write(FurnaceStationTileEntity.java:50) ~[?:?] {re:classloading} at net.minecraft.world.chunk.Chunk.func_223134_j(Chunk.java:444) ~[?:?] {re:classloading} at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:303) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:677) ~[?:?] {re:classloading} at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) [?:1.8.0_201] {} at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) [?:1.8.0_201] {} at java.util.stream.AbstractPipeline.copyInto(Unknown Source) [?:1.8.0_201] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) [?:1.8.0_201] {} at java.util.stream.AbstractPipeline.evaluate(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ReferencePipeline.forEach(Unknown Source) [?:1.8.0_201] {} at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:336) [?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:309) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:770) [?:?] {re:classloading} at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:528) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:571) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:235) [?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:685) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Unknown Source) [?:1.8.0_201] {} [m[32m[16:13:33] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (Test Area 033): All chunks are saved [m[36m[16:13:33] [Server thread/DEBUG] [ne.mi.fm.FMLWorldPersistenceHook/WP]: Gathering id map for writing to world save Test Area 033 [m[32m[16:13:33] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (Test Area 033): All chunks are saved [m It crashes at the exact same time I place the block. Any fixes? -
[1.14.4] get item out slot of lazyoptional<IItemHandler>?
Kenneth201998 replied to Kenneth201998's topic in Modder Support
I made some changes and now have a problem opening the gui again and it says there is a mapping missing. It said it is at the line : "return super.write(tag)" package com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace; import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.log_cabin_blocks.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class CabinFurnaceTileEntity extends TileEntity implements INamedContainerProvider { private LazyOptional<IItemHandler> handler = LazyOptional.of(this::createHandler); public CabinFurnaceTileEntity() { super(BlockList.cabin_furnace_tile_entity); } @SuppressWarnings("unchecked") @Override public void read(CompoundNBT tag) { CompoundNBT invTag = tag.getCompound("inv"); handler.ifPresent(h -> ((INBTSerializable<CompoundNBT>) h).deserializeNBT(invTag)); super.read(tag); } @SuppressWarnings("unchecked") @Override public CompoundNBT write(CompoundNBT tag) { handler.ifPresent(h -> { CompoundNBT compound = ((INBTSerializable<CompoundNBT>) h).serializeNBT(); tag.put("inv", compound); }); return super.write(tag); } private IItemHandler createHandler() { return new ItemStackHandler(3) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public boolean isItemValid(int slot, @Nonnull ItemStack stack) { return stack.getItem() == Items.DIAMOND; } @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if (stack.getItem() != Items.DIAMOND) { return stack; } return super.insertItem(slot, stack, simulate); } }; } @Override public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) { return new CabinFurnaceContainer(p_createMenu_1_, pos, p_createMenu_2_, p_createMenu_3_); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("cabinfurnace"); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return handler.cast(); } return super.getCapability(cap, side); } } Error [m[36m[10:17:44] [Server thread/DEBUG] [ne.mi.fm.FMLWorldPersistenceHook/WP]: Gathering id map for writing to world save Test Area 029 [m[33m[10:17:44] [Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Is the server overloaded? Running 3870ms or 77 ticks behind [m[32m[10:17:49] [Client thread/INFO] [minecraft/AdvancementList]: Loaded 2 advancements [m[1;31m[10:18:00] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server java.lang.UnsupportedOperationException: Unable to construct this menu by type at net.minecraft.inventory.container.Container.getType(Container.java:52) ~[?:?] {re:classloading} at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:189) ~[?:?] {re:classloading} at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:154) ~[?:?] {re:classloading} at com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnace.onBlockActivated(CabinFurnace.java:69) ~[?:?] {re:classloading} at net.minecraft.block.BlockState.onBlockActivated(BlockState.java:296) ~[?:?] {re:classloading} at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:332) ~[?:?] {re:classloading} at net.minecraft.network.play.ServerPlayNetHandler.processTryUseItemOnBlock(ServerPlayNetHandler.java:870) ~[?:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:42) ~[?:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:12) ~[?:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[?:?] {re:classloading} at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[?:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:140) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) [?:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:110) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:726) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:720) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:123) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:706) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:650) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Unknown Source) [?:1.8.0_201] {} [m[1;31m[10:18:00] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server java.lang.UnsupportedOperationException: Unable to construct this menu by type at net.minecraft.inventory.container.Container.getType(Container.java:52) ~[?:?] {re:classloading} at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:189) ~[?:?] {re:classloading} at net.minecraftforge.fml.network.NetworkHooks.openGui(NetworkHooks.java:154) ~[?:?] {re:classloading} at com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnace.onBlockActivated(CabinFurnace.java:69) ~[?:?] {re:classloading} at net.minecraft.block.BlockState.onBlockActivated(BlockState.java:296) ~[?:?] {re:classloading} at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:332) ~[?:?] {re:classloading} at net.minecraft.network.play.ServerPlayNetHandler.processTryUseItemOnBlock(ServerPlayNetHandler.java:870) ~[?:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:42) ~[?:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:12) ~[?:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[?:?] {re:classloading} at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[?:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:140) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) [?:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:110) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:726) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:720) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:123) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:706) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:650) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Unknown Source) [?:1.8.0_201] {} [m[32m[10:18:01] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game... [m[32m[10:18:01] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test Area 029'/minecraft:overworld [m[1;31m[10:18:01] [Server thread/ERROR] [minecraft/Chunk]: A TileEntity type com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnaceTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author java.lang.RuntimeException: class com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnaceTileEntity is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:72) ~[?:?] {re:classloading} at net.minecraft.tileentity.TileEntity.write(TileEntity.java:66) ~[?:?] {re:classloading} at com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnaceTileEntity.write(CabinFurnaceTileEntity.java:47) ~[?:?] {re:classloading} at net.minecraft.world.chunk.Chunk.func_223134_j(Chunk.java:444) ~[?:?] {re:classloading} at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:303) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.func_219229_a(ChunkManager.java:677) ~[?:?] {re:classloading} at net.minecraft.world.server.ChunkManager.lambda$save$9(ChunkManager.java:352) ~[?:?] {re:classloading} at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) [?:1.8.0_201] {} at java.util.Iterator.forEachRemaining(Unknown Source) [?:1.8.0_201] {} at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source) [?:1.8.0_201] {} at java.util.stream.AbstractPipeline.copyInto(Unknown Source) [?:1.8.0_201] {} at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) [?:1.8.0_201] {} at java.util.stream.AbstractPipeline.evaluate(Unknown Source) [?:1.8.0_201] {} at java.util.stream.ReferencePipeline.forEach(Unknown Source) [?:1.8.0_201] {} at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:349) [?:?] {re:classloading} at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:309) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:770) [?:?] {re:classloading} at net.minecraft.server.MinecraftServer.save(MinecraftServer.java:528) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:113) [?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Unknown Source) [?:1.8.0_201] {} [m[36m[10:18:02] [Server thread/DEBUG] [ne.mi.fm.FMLWorldPersistenceHook/WP]: Gathering id map for writing to world save Test Area 029 [m[32m[10:18:10] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game... [m[32m[10:18:10] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test Area 029'/minecraft:overworld [m[36m[10:18:10] [Server thread/DEBUG] [ne.mi.fm.FMLWorldPersistenceHook/WP]: Gathering id map for writing to world save Test Area 029 [m[32m[10:18:10] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Dev lost connection: Disconnected [m[32m[10:18:10] [Server thread/INFO] [minecraft/MinecraftServer]: Dev left the game [m[32m[10:18:10] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Stopping singleplayer server as player logged out [m[32m[10:18:10] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server [m[32m[10:18:10] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players [m[32m[10:18:10] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds [m[32m[10:18:10] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test Area 029'/minecraft:overworld [m[32m[10:18:11] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (Test Area 029): All chunks are saved [m[36m[10:18:11] [Server thread/DEBUG] [ne.mi.fm.FMLWorldPersistenceHook/WP]: Gathering id map for writing to world save Test Area 029 [m[32m[10:18:11] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (Test Area 029): All chunks are saved [m[32m[10:18:11] [Client thread/INFO] [minecraft/Minecraft]: Stopping! [m -
[1.14.4] get item out slot of lazyoptional<IItemHandler>?
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Do you know anywhere I can get some example code / documentation implementing this? I have been taking java classes and minecraft modding has been proving a challenge -
I have this line of code in my block's tile entity: private LazyOptional<IItemHandler> handler = LazyOptional.of(this::createHandler); And this code in my block's container: this.tile_entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { this.addSlot(new SlotItemHandler(h, 0, 26, 21)); this.addSlot(new SlotItemHandler(h, 1, 26, 48)); this.addSlot(new SlotItemHandler(h, 2, 80, 35)); }); And this code also in my block's tile entity: private IItemHandler createHandler() { return new ItemStackHandler(3) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public boolean isItemValid(int slot, @Nonnull ItemStack stack) { if(slot != 2) { return true; } else { return false; } } @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { return super.insertItem(slot, stack, simulate); } }; } It seems to me that this has something to do with the block's inventory. I have a few questions because this is very new and I don't know much about it: How do you check the item in one of the slots? How do you set what that item is? How do you change the size of that slot? I have been trying time and time again to figure out the answer to these questions with no luck. Thanks for any help.
-
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Edit: Changed code in Tile entity insert item to : @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { return super.insertItem(slot, stack, simulate); } and that seemed to fix it. -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Ok, so I made some changes. Here is the code as of now for the tile entity and the container: package com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace; import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.log_cabin_blocks.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class CabinFurnaceTileEntity extends TileEntity implements INamedContainerProvider { private LazyOptional<IItemHandler> handler = LazyOptional.of(this::createHandler); @SuppressWarnings("unchecked") @Override public void read(CompoundNBT tag) { CompoundNBT invTag = tag.getCompound("inv"); handler.ifPresent(h -> ((INBTSerializable<CompoundNBT>) h).deserializeNBT(invTag)); super.read(tag); } @SuppressWarnings("unchecked") @Override public CompoundNBT write(CompoundNBT tag) { handler.ifPresent(h -> { CompoundNBT compound = ((INBTSerializable<CompoundNBT>) h).serializeNBT(); tag.put("inv", compound); }); return super.write(tag); } public CabinFurnaceTileEntity() { super(BlockList.cabin_furnace_tile_entity); } private IItemHandler createHandler() { return new ItemStackHandler(3) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public boolean isItemValid(int slot, @Nonnull ItemStack stack) { if(slot != 2) { return true; } else { return false; } } @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { return stack; } }; } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return handler.cast(); } return super.getCapability(cap, side); } @Nullable @Override public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) { return new CabinFurnaceContainer(p_createMenu_1_, world, pos, p_createMenu_2_, p_createMenu_3_); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("cabinfurnace"); } } package com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace; import com.log_cabin_blocks.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.SlotItemHandler; public class CabinFurnaceContainer extends Container { private TileEntity tile_entity; public CabinFurnaceContainer(int id, World world, BlockPos pos, PlayerInventory player_inventory, PlayerEntity player) { super(BlockList.cabin_furnace_container, id); this.tile_entity = world.getTileEntity(pos); this.tile_entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { this.addSlot(new SlotItemHandler(h, 0, 26, 21)); this.addSlot(new SlotItemHandler(h, 1, 26, 48)); this.addSlot(new SlotItemHandler(h, 2, 80, 35)); }); int si; int sj; for (si = 0; si < 3; ++si) { for (sj = 0; sj < 9; ++sj) { this.addSlot(new Slot(player_inventory, sj + (si + 1) * 9, 0 + 8 + sj * 18, 0 + 84 + si * 18)); } } for (si = 0; si < 9; ++si) { this.addSlot(new Slot(player_inventory, si, 0 + 8 + si * 18, 0 + 142)); } } @Override public boolean canInteractWith(PlayerEntity playerIn) { return true; } @Override public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < 3) { if (!this.mergeItemStack(itemstack1, 3, this.inventorySlots.size(), true)) { return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); } else if (!this.mergeItemStack(itemstack1, 0, 3, false)) { if (index < 3 + 27) { if (!this.mergeItemStack(itemstack1, 3 + 27, this.inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else { if (!this.mergeItemStack(itemstack1, 3, 3 + 27, false)) { return ItemStack.EMPTY; } } return ItemStack.EMPTY; } if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, itemstack1); } return itemstack; } protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) { boolean flag = false; int i = startIndex; if (reverseDirection) { i = endIndex - 1; } if (stack.isStackable()) { while (!stack.isEmpty()) { if (reverseDirection) { if (i < startIndex) { break; } } else if (i >= endIndex) { break; } Slot slot = this.inventorySlots.get(i); ItemStack itemstack = slot.getStack(); if (slot.isItemValid(itemstack) && !itemstack.isEmpty() && areItemsAndTagsEqual(stack, itemstack)) { int j = itemstack.getCount() + stack.getCount(); int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize()); if (j <= maxSize) { stack.setCount(0); itemstack.setCount(j); slot.putStack(itemstack); flag = true; } else if (itemstack.getCount() < maxSize) { stack.shrink(maxSize - itemstack.getCount()); itemstack.setCount(maxSize); slot.putStack(itemstack); flag = true; } } if (reverseDirection) { --i; } else { ++i; } } } if (!stack.isEmpty()) { if (reverseDirection) { i = endIndex - 1; } else { i = startIndex; } while (true) { if (reverseDirection) { if (i < startIndex) { break; } } else if (i >= endIndex) { break; } Slot slot1 = this.inventorySlots.get(i); ItemStack itemstack1 = slot1.getStack(); if (itemstack1.isEmpty() && slot1.isItemValid(stack)) { if (stack.getCount() > slot1.getSlotStackLimit()) { slot1.putStack(stack.split(slot1.getSlotStackLimit())); } else { slot1.putStack(stack.split(stack.getCount())); } slot1.onSlotChanged(); flag = true; break; } if (reverseDirection) { --i; } else { ++i; } } } return flag; } @Override public void onContainerClosed(PlayerEntity playerIn) { super.onContainerClosed(playerIn); } } The block GUI now opens. But the only way I can put item stacks in the first two slots is by shift clicking them. Any fixes? -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Here is also the code to the tile entity: package com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace; import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.log_cabin_blocks.objects.blocks.BlockList; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class CabinFurnaceTileEntity extends TileEntity implements INamedContainerProvider { private LazyOptional<IItemHandler> handler = LazyOptional.of(this::createHandler); @SuppressWarnings("unchecked") @Override public void read(CompoundNBT tag) { CompoundNBT invTag = tag.getCompound("inv"); handler.ifPresent(h -> ((INBTSerializable<CompoundNBT>)h).deserializeNBT(invTag)); super.read(tag); } @SuppressWarnings("unchecked") @Override public CompoundNBT write(CompoundNBT tag) { handler.ifPresent(h -> { CompoundNBT compound = ((INBTSerializable<CompoundNBT>)h).serializeNBT(); tag.put("inv", compound); }); return super.write(tag); } public CabinFurnaceTileEntity() { super(BlockList.cabin_furnace_tile_entity); } private IItemHandler createHandler () { return new ItemStackHandler(1) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { return stack; } }; } @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return handler.cast(); } return super.getCapability(cap, side); } @Nullable @Override public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) { return new CabinFurnaceContainer(p_createMenu_1_, world, pos, p_createMenu_2_, p_createMenu_3_); } @Override public ITextComponent getDisplayName() { return new StringTextComponent("cabinfurnace"); } } which I based off the code here: https://github.com/McJty/YouTubeModding14/blob/master/src/main/java/com/mcjty/mytutorial/blocks/FirstBlockTile.java -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
I originally had: @Override public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { player.openContainer(state.getContainer(worldIn, pos)); return true; } but then changed it to: @Override public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { TileEntity te = worldIn.getTileEntity(pos); if(te instanceof CabinFurnaceTileEntity) { player.openContainer((INamedContainerProvider) te); } return true; } But now get a new error: [m[1;31m[13:49:12] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server java.lang.RuntimeException: Slot 1 not in valid range - [0,1) at net.minecraftforge.items.ItemStackHandler.validateSlotIndex(ItemStackHandler.java:217) ~[?:?] {re:classloading} at net.minecraftforge.items.ItemStackHandler.getStackInSlot(ItemStackHandler.java:73) ~[?:?] {re:classloading} at net.minecraftforge.items.SlotItemHandler.getStack(SlotItemHandler.java:54) ~[?:?] {re:classloading} at net.minecraft.inventory.container.Container.getInventory(Container.java:117) ~[?:?] {re:classloading} at net.minecraft.inventory.container.Container.addListener(Container.java:97) ~[?:?] {re:classloading} at net.minecraft.entity.player.ServerPlayerEntity.openContainer(ServerPlayerEntity.java:866) ~[?:?] {re:classloading,pl:accesstransformer:B} at com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnace.onBlockActivated(CabinFurnace.java:64) ~[?:?] {re:classloading} at net.minecraft.block.BlockState.onBlockActivated(BlockState.java:296) ~[?:?] {re:classloading} at net.minecraft.server.management.PlayerInteractionManager.func_219441_a(PlayerInteractionManager.java:332) ~[?:?] {re:classloading} at net.minecraft.network.play.ServerPlayNetHandler.processTryUseItemOnBlock(ServerPlayNetHandler.java:870) ~[?:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:42) ~[?:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemOnBlockPacket.processPacket(CPlayerTryUseItemOnBlockPacket.java:12) ~[?:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[?:?] {re:classloading} at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[?:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:140) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) [?:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:110) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:726) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:720) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:705) [?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:650) [?:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Unknown Source) [?:1.8.0_201] {} [m[1;31m[13:49:12] [Client thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Client java.lang.NullPointerException: null at com.log_cabin_blocks.LogCabinBlocks$RegistryEvents.lambda$1(LogCabinBlocks.java:108) ~[main/:?] {re:classloading} at net.minecraftforge.fml.network.IContainerFactory.create(IContainerFactory.java:34) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.inventory.container.ContainerType.create(ContainerType.java:46) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.gui.ScreenManager$IScreenFactory.createScreen(ScreenManager.java:113) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.gui.ScreenManager.lambda$openScreen$0(ScreenManager.java:42) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at java.util.Optional.ifPresent(Unknown Source) ~[?:1.8.0_201] {} at net.minecraft.client.gui.ScreenManager.openScreen(ScreenManager.java:42) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.network.play.ClientPlayNetHandler.func_217272_a(ClientPlayNetHandler.java:1094) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.network.play.server.SOpenWindowPacket.processPacket(SOpenWindowPacket.java:47) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.network.play.server.SOpenWindowPacket.processPacket(SOpenWindowPacket.java:14) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:140) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:110) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:896) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:384) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:128) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201] {} at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201] {} at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-4.1.0.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-4.1.0.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101) [forge-1.14.4-28.1.70_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} [m[32m[13:49:13] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game... [m[32m[13:49:13] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test Area 014'/minecraft:overworld [m[36m[13:49:14] [Server thread/DEBUG] [ne.mi.fm.FMLWorldPersistenceHook/WP]: Gathering id map for writing to world save Test Area 014 [m[32m[13:49:14] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Dev lost connection: Disconnected [m[32m[13:49:14] [Server thread/INFO] [minecraft/MinecraftServer]: Dev left the game [m[32m[13:49:14] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Stopping singleplayer server as player logged out [m[32m[13:49:14] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server [m[32m[13:49:14] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players [m[32m[13:49:14] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds [m[32m[13:49:14] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test Area 014'/minecraft:overworld [m[32m[13:49:15] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (Test Area 014): All chunks are saved [m[36m[13:49:15] [Server thread/DEBUG] [ne.mi.fm.FMLWorldPersistenceHook/WP]: Gathering id map for writing to world save Test Area 014 [m[32m[13:49:15] [Server thread/INFO] [minecraft/ChunkManager]: ThreadedAnvilChunkStorage (Test Area 014): All chunks are saved [m[32m[13:49:37] [Client thread/INFO] [minecraft/Minecraft]: Stopping! [m -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
I have tried: package com.log_cabin_blocks.objects.blocks; import com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnaceContainer; import com.log_cabin_blocks.objects.blocks.utility_blocks.cooking_utilities.cabin_furnace.CabinFurnaceTileEntity; import net.minecraft.block.Block; import net.minecraft.inventory.container.ContainerType; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; public class BlockList { public static Block oak_log_wall_type_0; public static Block oak_log_wall_type_1; public static Block oak_log_corner; public static Block oak_cabin_door; public static Block oak_window_frame; public static Block water_pump; @ObjectHolder("lcb:cabin_furnace") public static Block cabin_furnace; @ObjectHolder("lcb:cabin_furnace") public static TileEntityType<CabinFurnaceTileEntity> cabin_furnace_tile_entity; @ObjectHolder("lcb:cabin_furnace") public static ContainerType<CabinFurnaceContainer> cabin_furnace_container; } but now nothing happens when I right click on the block Can you show me what setting the tile entity type would look like? -
[1.14.4] Tile entity is missing a mapping.
Kenneth201998 replied to Kenneth201998's topic in Modder Support
Now that you ask, I don't think I did. I placed the field without a set value in my blockslist class. Do you know what the set value might look like? I posted the blocklist class in one of the replies above.