Posted October 26, 20195 yr Spoiler Spoiler Registering my GuiHandler public static void initRegistries() { NetworkRegistry.INSTANCE.registerGuiHandler(Main.instance, new GuiHandler()); } AltarBase (Altar Block) package com.magiksmostevile.blocks; import java.util.Random; import com.magiksmostevile.EvileLog; import com.magiksmostevile.Main; import com.magiksmostevile.EvileLog.EnumLogLevel; import com.magiksmostevile.guis.GuiAltar; import com.magiksmostevile.init.EvileBlocks; import com.magiksmostevile.tileentity.TileEntityAltar; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityEnchantmentTable; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class AltarBase extends BlockBase implements ITileEntityProvider { public static AxisAlignedBB ALTAR_AABB = new AxisAlignedBB(0D, 0D, 0D, 1D, 1D, 1D); private World world; public AltarBase(String name, Material material) { super(name, material); EvileLog.logText(true, EnumLogLevel.INFO, "Constructing ALTAR"); setHardness(5); setSoundType(SoundType.CLOTH); } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return ALTAR_AABB; } // ====================================================================================================================== // TILE ENTITY @Override public TileEntity createNewTileEntity(World worldIn, int meta) { EvileLog.logText(true, EnumLogLevel.INFO, "creating tile entity for ALTAR"); return new TileEntityAltar(); } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(EvileBlocks.ALTAR); } @Override public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { return new ItemStack(EvileBlocks.ALTAR); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { try { playerIn.sendMessage(new TextComponentString("Altar activated! +++++++++++++++++++++++++++")); if (!worldIn.isRemote) { playerIn.openGui(Main.instance, Main.GUI_ALTAR, worldIn, pos.getX(), pos.getY(), pos.getZ()); } } catch (Exception e) { EvileLog.logText(true, EnumLogLevel.ERROR, "An error has occurred opening the GUI for Altar at : " + pos + " : This is not an intended feature! :/"); e.printStackTrace(); } return true; } private void openAltarGui(World worldIn, BlockPos pos, EntityPlayer playerIn) { playerIn.sendMessage(new TextComponentString("Opening altar gui, ID: " + Main.GUI_ALTAR)); playerIn.openGui(Main.instance, Main.GUI_ALTAR, worldIn, pos.getX(), pos.getY(), pos.getZ()); } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { EvileLog.logText(true, EnumLogLevel.WARN, "Altar placed! Evile-ness incoming!"); } public static void setState() { // TODO Check whether method needs population } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntityAltar tileentity = (TileEntityAltar) worldIn.getTileEntity(pos); InventoryHelper.dropInventoryItems(worldIn, pos, tileentity); super.breakBlock(worldIn, pos, state); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override public IBlockState withRotation(IBlockState state, Rotation rot) { return super.withRotation(state, rot); } @Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return super.withMirror(state, mirrorIn); } @Override protected BlockStateContainer createBlockState() { return super.createBlockState(); } @Override public IBlockState getStateFromMeta(int meta) { return super.getStateFromMeta(meta); } @Override public int getMetaFromState(IBlockState state) { return super.getMetaFromState(state); } // https://www.youtube.com/watch?v=JMdDf0PCxIE&list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR&index=19&t=451s } Spoiler TileEntityAltar package com.magiksmostevile.tileentity; import java.util.Iterator; import com.google.common.collect.ImmutableMap; import com.magiksmostevile.EvileLog; import com.magiksmostevile.EvileLog.EnumLogLevel; import com.magiksmostevile.Main; import com.magiksmostevile.init.EvileItems; import com.magiksmostevile.tileentity.container.ContainerAltar; import net.minecraft.block.Block; import net.minecraft.block.BlockCrops; import net.minecraft.block.BlockPotato; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerEnchantment; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.IInteractionObject; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityAltar extends TileEntity implements ITickable, IInventory, IInteractionObject { private NonNullList<ItemStack> inventory = NonNullList.<ItemStack>withSize(4, ItemStack.EMPTY); private String customName; private World world; private int currentRitual; public TileEntityAltar() { super(); EvileLog.logText(true, EnumLogLevel.INFO, "Constructing altar tile entity"); } public int getCurrentRitual() { return this.currentRitual; } public void setAltarRitual(World worldIn, BlockPos pos, int ritualToSet) { TileEntityAltar tileentity = (TileEntityAltar) worldIn.getTileEntity(pos); tileentity.currentRitual = ritualToSet; } public String getName() { return this.hasCustomName() ? this.customName : "container.altar"; } public boolean hasCustomName() { return this.customName != null && !this.customName.isEmpty(); } private void setCustomName(String customNameIn) { this.customName = customNameIn; } public ITextComponent getDisplayName() { return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName()); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.inventory = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY); ItemStackHelper.loadAllItems(compound, this.inventory); this.currentRitual = compound.getInteger("CurrentRitual"); if (compound.hasKey("CustomName", 8)) this.setCustomName(compound.getString("CustomName")); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("CurrentRitual", (short) this.currentRitual); if (this.hasCustomName()) compound.setString("CustomName", this.customName); return compound; } @Override public void onLoad() { // HELPFUL POST FOR GETTING WORLD>>> // https://www.minecraftforge.net/forum/topic/41640-world-and-position-empty-in-tile-entity/ this.world = this.getWorld(); } @Override public void update() { } @Override public int getSizeInventory() { return this.inventory.size(); } @Override public boolean isEmpty() { for (ItemStack stack : this.inventory) { if (stack.isEmpty()) return false; } return true; } @Override public ItemStack getStackInSlot(int index) { return (ItemStack) this.inventory.get(index); } @Override public ItemStack decrStackSize(int index, int count) { return ItemStackHelper.getAndSplit(this.inventory, index, count); } @Override public ItemStack removeStackFromSlot(int index) { return ItemStackHelper.getAndRemove(this.inventory, index); } @Override public void setInventorySlotContents(int index, ItemStack stack) { ItemStack itemstack = (ItemStack) this.inventory.get(index); boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack); this.inventory.set(index, stack); if (stack.getCount() > this.getInventoryStackLimit()) { stack.setCount(this.getInventoryStackLimit()); } if (index == 0 && index + 1 == 1 && !flag) { ItemStack stack1 = (ItemStack) this.inventory.get(index + 1); this.markDirty(); } } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUsableByPlayer(EntityPlayer player) { // TODO Auto-generated method stub return false; } @Override public void openInventory(EntityPlayer player) { EvileLog.logText(true, EnumLogLevel.INFO, "Opening ALTAR_GUI"); System.out.println("TileEntityAltar Opening ALTAR_GUI"); player.openGui(Main.instance, Main.GUI_ALTAR, world, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()); } @Override public void closeInventory(EntityPlayer player) { // TODO Auto-generated method stub } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { // TODO Decide on slot allocation!!!!!!! if (index == 1) { return false; } else if (index != 2) { return true; } else { return true; } } public String getGuiID() { return "magiksmostevile:gui_altar"; } @Override public int getField(int id) { // https://www.youtube.com/watch?v=PcZ4JgTqCU8&list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR&index=19 // TODO Decide slot allocation + see link! 12:22 return 0; } @Override public void setField(int id, int value) { // TODO Auto-generated method stub } @Override public int getFieldCount() { return 4; } @Override public void clear() { this.inventory.clear(); } @Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { System.out.println("creating container for Altar GUI"); return new ContainerAltar(playerInventory, this); } public String getGuiId() { return "magiksmostevile:gui_altar"; } } Spoiler ContainerAltar package com.magiksmostevile.tileentity.container; import com.magiksmostevile.tileentity.TileEntityAltar; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerAltar extends Container { // https://www.youtube.com/watch?v=rARVLYm9TBs&list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR&index=22&t=366s private final TileEntityAltar tileentity; public ContainerAltar(InventoryPlayer player, TileEntityAltar tileentity) { this.tileentity = tileentity; System.out.println("Constructing ContainerAltar"); this.addSlotToContainer(new Slot(tileentity, 0, 305, 185)); this.addSlotToContainer(new Slot(tileentity, 1, 327, 185)); this.addSlotToContainer(new Slot(tileentity, 2, 305, 208)); this.addSlotToContainer(new Slot(tileentity, 3, 327, 208)); for (int y = 0; y < 3; y++) { for (int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } for (int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x, 8 + x * 18, 142)); } } @Override public void addListener(IContainerListener listener) { super.addListener(listener); listener.sendAllWindowProperties(this, this.tileentity); } @Override public void detectAndSendChanges() { // TODO Auto-generated method stub super.detectAndSendChanges(); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.tileentity.isUsableByPlayer(playerIn); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { return super.transferStackInSlot(playerIn, index); } } Spoiler GuiAltar package com.magiksmostevile.guis; import com.magiksmostevile.Main; import com.magiksmostevile.tileentity.TileEntityAltar; import com.magiksmostevile.tileentity.container.ContainerAltar; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; public class GuiAltar extends GuiContainer { private static final ResourceLocation TEXTURES = new ResourceLocation(Main.MODID, "textures/gui/altar/gui_altar.png"); private final InventoryPlayer player; private final TileEntityAltar tileentity; public GuiAltar(InventoryPlayer player, TileEntityAltar tileentity) { super(new ContainerAltar(player, tileentity)); this.player = player; this.tileentity = tileentity; System.out.println("path to textures" + TEXTURES.getResourcePath()); System.out.println("path to textures" + TEXTURES.getResourceDomain()); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { System.out.println("Drawing gui bg"); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); this.mc.getTextureManager().bindTexture(TEXTURES); this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { System.out.println("Drawing gui fg"); String tileName = this.tileentity.getDisplayName().getUnformattedText(); this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) + 3, 115, 4210752); this.fontRenderer.drawString(this.player.getDisplayName().getUnformattedText(), 295, this.ySize - 96 + 2, 4210752); } } // https://www.minecraftforge.net/forum/topic/38014-19-solved-gui-doesnt-open-on-right-click/ Spoiler GuiHandler package com.magiksmostevile.handler; import com.magiksmostevile.guis.GuiAltar; import com.magiksmostevile.tileentity.TileEntityAltar; import com.magiksmostevile.tileentity.container.ContainerAltar; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { /* @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == Main.GUI_ALTAR) return new ContainerAltar(player.inventory, (TileEntityAltar) world.getTileEntity(new BlockPos(x, y, z))); return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == Main.GUI_ALTAR) return new GuiAltar(player.inventory, (TileEntityAltar) world.getTileEntity(new BlockPos(x, y, z))); return null; } */ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if(tileEntity instanceof TileEntityAltar) { TileEntityAltar tileEntityAltar = (TileEntityAltar)tileEntity; return new ContainerAltar(player.inventory, tileEntityAltar); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if(tileEntity instanceof TileEntityAltar) { TileEntityAltar tileEntityAltar = (TileEntityAltar)tileEntity; return new GuiAltar(player.inventory, tileEntityAltar); } return null; } } Spoiler Main package com.magiksmostevile; import com.magiksmostevile.entity.EntityVampireBat; import com.magiksmostevile.entity.render.RenderVampireBat; import com.magiksmostevile.handler.RegistryHandler; import com.magiksmostevile.init.EntityInit; import com.magiksmostevile.proxy.CommonProxy; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = Main.MODID, name = Main.NAME, version = Main.VERSION) public class Main { public static final String MODID = "magiksmostevile"; public static final String VERSION = "1.0"; public static final String NAME = "MagiksMostEvile"; public static final String ACCEPTED_VERSIONS = "{1.12.2}"; public static final String CLIENT_PROXY_CLASS = "com.magiksmostevile.proxy.ClientProxy"; public static final String COMMON_PROXY_CLASS = "com.magiksmostevile.proxy.CommonProxy"; public static final int ENTITY_VAMPIRE_BAT = 6750; public static final int GUI_ALTAR = 1; public static Item amethyst; public static Block amethystOre; @Mod.Instance("main") public static Main instance; @SidedProxy(clientSide = CLIENT_PROXY_CLASS, serverSide = COMMON_PROXY_CLASS) public static CommonProxy proxy; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { if (event.getSide() == Side.CLIENT) { System.out.println("preInit: Client"); RenderingRegistry.registerEntityRenderingHandler(EntityVampireBat.class, RenderVampireBat::new); RegistryHandler.otherRegistries(); } } @EventHandler public void init(FMLInitializationEvent event) { } @EventHandler public void load(FMLInitializationEvent event) { } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { } } Hello all! I'm trying to open a gui when I right click on a block (Altar), but although my logging code says the opening code is running, the gui doesn't appear. I don't know what the problem is, but I think it's just not opening (rather than just not rendering) as the game doesn't make me press Esc before I can move again. The GUI textures are located in magiksmostevile:textures/gui/altar/altar_gui.png and the texture is attached. As in the image, it should have four basic slots in the four areas to the right, and when I can actually see the gui I will add a scrolling menu on the left. I have used the following resources to help: Primarily: https://www.youtube.com/playlist?list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR -- specifically the 5/6 tutorials on the Sintering Furnace Also: https://www.youtube.com/watch?v=MHgS0GTNqq0&t=229s just for another potential way to open a gui And: http://jabelarminecraft.blogspot.com/p/minecraft-modding-containers.html As well as the minecraft source for the Enchantment Table, Furnace, Anvil, Villagers, Chest and this forum post. So after all that, I still don't know the problem. I know there's gotta be something I'm missing, so any help from anyone who knows how to open a gui would be much appreciated! Ps Sorry for the data-dump of code, but I figured it would be better to provide people with hopefully everything they need, rather than having to add more later. How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
October 26, 20195 yr 5 hours ago, GenElectrovise said: implements ITileEntityProvider Dont use this. 5 hours ago, GenElectrovise said: BlockBase BlockBase serves no purpose. You probably have something like "registerModels" in here. You could easily switch this to Block and be capable of extending any Block class. 5 hours ago, GenElectrovise said: createNewTileEntity You're using the wrong create method. Use the one with an IBlockState parameter. 5 hours ago, GenElectrovise said: openAltarGui Remove this method it is useless. 5 hours ago, GenElectrovise said: implements ITickable, IInventory Do not implement IInventory. Instead use the IItemHandler Capability. It's way easier to use and is the compatible option to use with other mods. No mods expect your TE to use IInventory anymore and stuff like pipes/machines/etc. Do not support it. 5 hours ago, GenElectrovise said: this.world = this.getWorld(); This is literally the same as this.world = this.world; It serves no purpose. The load method is called after the TileEntity has been added to the world and has had its world field initialized. You dont need this function unless you have important stuff to do when the TileEntity is first created and placed or when the chunk gets loaded. 5 hours ago, GenElectrovise said: IInteractionObject There is no point to this if you dont use it anywhere. Fix all this and your code will be better and easier to understand. Your error should also go away. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 27, 20195 yr Author Ok shall make those changes, @Animefan8888. Will post results once done! (will likely be in a few hours) Thanks for the response! Also, for @loordgek, any particular reason for 14 hours ago, loordgek said: dont watch Harry Talks I see that some of his choices aren't the best, but anything else specific? Edited October 27, 20195 yr by GenElectrovise Added clarification How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
October 27, 20195 yr 6 hours ago, GenElectrovise said: I see that some of his choices aren't the best, but anything else specific? His code (and coding practice) is such garbage it needs to be taken out back, shot, set on fire, and buried, never to be seen again. As in, almost everything he does is wrong in some way. And sure "it works for him" but everyone who watches his crap shows up here with the same garbage code, we've enshrined several of the problems created by him in the Common Issues thread. Problematic Code #4, #5, #14 Code Style #1, #2, #3, #4 Edited October 27, 20195 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 27, 20195 yr Author Question: How does the container (ContainerAltar) work when using IItemHandler ? Is it still necessary, because I'm getting a lot of errors from when I previously tried to add slots. this.addSlotToContainer(new Slot(tileentity, 0, 305, 185)); Soooooo I'm guessing that's a IInventory thing. Does this have an equivalent with IItemHandler and Capabilities ? Do I even still need the container? The Altar will have an inventory (of 4 slots), so therefore it needs to persist the data, right? So that means that TileEntityAltar should implement ICapabilitySerializable<T extends NBTBase> ? The How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
October 27, 20195 yr Author 2 hours ago, Draco18s said: His code (and coding practice) is such garbage it needs to be taken out back, shot, set on fire, and buried, never to be seen again. As in, almost everything he does is wrong in some way. And sure "it works for him" but everyone who watches his crap shows up here with the same garbage code, we've enshrined several of the problems created by him in the Common Issues thread. Problematic Code #4, #5, #14 Code Style #1, #2, #3, #4 Right. Ok. That's the explanation I needed. How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
October 27, 20195 yr 4 minutes ago, GenElectrovise said: Question: How does the container (ContainerAltar) work when using IItemHandler ? Is it still necessary, because I'm getting a lot of errors from when I previously tried to add slots. this.addSlotToContainer(new Slot(tileentity, 0, 305, 185)); Soooooo I'm guessing that's a IInventory thing. Does this have an equivalent with IItemHandler and Capabilities ? SlotItemHandler. You can select a class name and either "search for all references" or "open type hierarchy" to get an idea of what alternatives exist or how something's used. 4 minutes ago, GenElectrovise said: Do I even still need the container? Yes 4 minutes ago, GenElectrovise said: The Altar will have an inventory (of 4 slots), so therefore it needs to persist the data, right? So that means that TileEntityAltar should implement ICapabilitySerializable<T extends NBTBase> ? The No, TileEntity already implements that. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 27, 20195 yr Author Spoiler [20:06:25] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.AttachCapabilitiesEvent@5c44a1bf: java.lang.StackOverflowError: null at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_201] at java.io.FilePermission.init(FilePermission.java:203) ~[?:1.8.0_201] at java.io.FilePermission.<init>(FilePermission.java:277) ~[?:1.8.0_201] at java.lang.SecurityManager.checkRead(SecurityManager.java:888) ~[?:1.8.0_201] at java.io.File.exists(File.java:814) ~[?:1.8.0_201] at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:434) ~[?:1.8.0_201] at java.io.File.getCanonicalPath(File.java:618) ~[?:1.8.0_201] at java.io.FilePermission$1.run(FilePermission.java:215) ~[?:1.8.0_201] at java.io.FilePermission$1.run(FilePermission.java:203) ~[?:1.8.0_201] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_201] at java.io.FilePermission.init(FilePermission.java:203) ~[?:1.8.0_201] at java.io.FilePermission.<init>(FilePermission.java:277) ~[?:1.8.0_201] at java.lang.SecurityManager.checkRead(SecurityManager.java:888) ~[?:1.8.0_201] at java.io.File.exists(File.java:814) ~[?:1.8.0_201] at sun.misc.URLClassPath$FileLoader.getResource(URLClassPath.java:1334) ~[?:1.8.0_201] at sun.misc.URLClassPath.getResource(URLClassPath.java:249) ~[?:1.8.0_201] at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[?:1.8.0_201] at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_201] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_201] at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_201] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_201] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[?:1.8.0_201] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_201] at org.apache.logging.log4j.core.impl.MutableLogEvent.getThrownProxy(MutableLogEvent.java:338) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter.format(ExtendedThrowablePatternConverter.java:61) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.pattern.PatternFormatter.format(PatternFormatter.java:38) ~[log4j-core-2.8.1.jar:2.8.1] at net.minecraftforge.server.terminalconsole.HighlightErrorConverter.format(HighlightErrorConverter.java:100) ~[forgeSrc-1.12.2-14.23.5.2768.jar:?] at org.apache.logging.log4j.core.pattern.PatternFormatter.format(PatternFormatter.java:38) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.layout.PatternLayout$PatternSelectorSerializer.toSerializable(PatternLayout.java:455) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.layout.PatternLayout$PatternSelectorSerializer.toSerializable(PatternLayout.java:444) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.layout.PatternLayout.toSerializable(PatternLayout.java:208) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.layout.PatternLayout.toSerializable(PatternLayout.java:57) ~[log4j-core-2.8.1.jar:2.8.1] at net.minecraftforge.server.terminalconsole.TerminalConsoleAppender.append(TerminalConsoleAppender.java:320) ~[forgeSrc-1.12.2-14.23.5.2768.jar:?] at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:156) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:129) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:120) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:448) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:433) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:417) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:403) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146) ~[log4j-core-2.8.1.jar:2.8.1] at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2091) ~[log4j-api-2.8.1.jar:2.8.1] at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2011) ~[log4j-api-2.8.1.jar:2.8.1] at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1884) ~[log4j-api-2.8.1.jar:2.8.1] at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:854) ~[log4j-api-2.8.1.jar:2.8.1] at net.minecraftforge.fml.common.eventhandler.EventBus.handleException(EventBus.java:203) ~[EventBus.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:187) ~[EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:668) ~[ForgeEventFactory.class:?] at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:632) ~[ForgeEventFactory.class:?] at net.minecraft.tileentity.TileEntity.<init>(TileEntity.java:508) ~[TileEntity.class:?] at com.magiksmostevile.tileentity.TileEntityAltar.<init>(TileEntityAltar.java:42) ~[TileEntityAltar.class:?] at com.magiksmostevile.handler.RegistryHandler.registerGuiRelations(RegistryHandler.java:41) ~[RegistryHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_8_RegistryHandler_registerGuiRelations_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) ~[EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:668) ~[ForgeEventFactory.class:?] at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:632) ~[ForgeEventFactory.class:?] at net.minecraft.tileentity.TileEntity.<init>(TileEntity.java:508) ~[TileEntity.class:?] at com.magiksmostevile.tileentity.TileEntityAltar.<init>(TileEntityAltar.java:42) ~[TileEntityAltar.class:?] at com.magiksmostevile.handler.RegistryHandler.registerGuiRelations(RegistryHandler.java:41) ~[RegistryHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_8_RegistryHandler_registerGuiRelations_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) ~[EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:668) ~[ForgeEventFactory.class:?] at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:632) ~[ForgeEventFactory.class:?] at net.minecraft.tileentity.TileEntity.<init>(TileEntity.java:508) ~[TileEntity.class:?] at com.magiksmostevile.tileentity.TileEntityAltar.<init>(TileEntityAltar.java:42) ~[TileEntityAltar.class:?] at com.magiksmostevile.handler.RegistryHandler.registerGuiRelations(RegistryHandler.java:41) ~[RegistryHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_8_RegistryHandler_registerGuiRelations_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Ok, so now I'm getting a loop when the game tries to register the tile entity and its capabilities, which is resulting in a StackOverFlowException. (The loop occurs between the area marked with + in the stacktrace). I think it's because when I try to register the capabilities, I do this: @SubscribeEvent public static void registerGuiRelations(AttachCapabilitiesEvent<TileEntity> event) { event.addCapability(new ResourceLocation(Main.MODID + ":capabilites_altar"), new TileEntityAltar()); } I create a new TileEntityAltar which then calls its superconstructor which goes to line 508 in the TileEntity constructor: private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities; public TileEntity() { capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this); } Which causes forge to do.... something: @Nullable public static CapabilityDispatcher gatherCapabilities(TileEntity tileEntity) { return gatherCapabilities(new AttachCapabilitiesEvent<TileEntity>(TileEntity.class, tileEntity), null); } So how should I be registering the capabilities? -- it's pretty evident I'm doing this wrong! Also, my updated code from @Animefan8888's post: TileEntityAltar, ContainerAltar, registering capabilities, registering TileEntities Spoiler package com.magiksmostevile.tileentity; import com.magiksmostevile.EvileLog; import com.magiksmostevile.EvileLog.EnumLogLevel; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; public class TileEntityAltar extends TileEntity implements ITickable, IItemHandler { public static Capability<IItemHandler> ITEM_HANDLER_CAPABILITY = CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; private final IItemHandler inventory = new ItemStackHandler(4) { @Override protected void onContentsChanged(int slot) { super.onContentsChanged(slot); markDirty(); } }; private String customName; public TileEntityAltar() { super(); System.out.println("Capability ITEM_HANDLER for Altar : " + this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)); EvileLog.logText(true, EnumLogLevel.INFO, "Constructing altar tile entity"); } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { System.out.println("Checking ITEM_HANDLER_CAPABILIITY"); if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } System.out.println("Does not have ITEM_HANDLER_CAPABILIITY"); return super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { System.out.println("Getting ITEM_HANDLER_CAPABILIITY"); if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) inventory; } System.out.println("Cannot get ITEM_HANDLER_CAPABILIITY"); return super.getCapability(capability, facing); } public String getName() { return this.hasCustomName() ? this.customName : "container.altar"; } public boolean hasCustomName() { return this.customName != null && !this.customName.isEmpty(); } private void setCustomName(String customNameIn) { this.customName = customNameIn; } public ITextComponent getDisplayName() { return this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName()); } @Override public void readFromNBT(NBTTagCompound compound) { } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { return compound; } @Override public void onLoad() { } @Override public void update() { } @Override public ItemStack getStackInSlot(int slot) { return (ItemStack) this.inventory.getStackInSlot(slot); } public String getGuiID() { return "magiksmostevile:gui_altar"; } @Override public int getSlots() { return 4; } @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { return null; } @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { return null; } @Override public int getSlotLimit(int slot) { return 64; } } Spoiler package com.magiksmostevile.tileentity.container; import com.magiksmostevile.tileentity.TileEntityAltar; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.items.SlotItemHandler; public class ContainerAltar extends Container { // https://www.youtube.com/watch?v=rARVLYm9TBs&list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR&index=22&t=366s private final TileEntityAltar tileentity; public ContainerAltar(InventoryPlayer player, TileEntityAltar tileentity) { this.tileentity = tileentity; System.out.println("Constructing ContainerAltar"); this.addSlotToContainer(new SlotItemHandler(tileentity, 0, 305, 185)); this.addSlotToContainer(new SlotItemHandler(tileentity, 1, 327, 185)); this.addSlotToContainer(new SlotItemHandler(tileentity, 2, 305, 208)); this.addSlotToContainer(new SlotItemHandler(tileentity, 3, 327, 208)); for (int y = 0; y < 3; y++) { for (int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } for (int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x, 8 + x * 18, 142)); } } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); } @Override public boolean canInteractWith(EntityPlayer playerIn) { return this.tileentity.getDistanceSq(playerIn.getPosition().getX(), playerIn.getPosition().getY(), playerIn.getPosition().getZ()) < 3; } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { return super.transferStackInSlot(playerIn, index); } } Spoiler @SubscribeEvent public static void registerGuiRelations(AttachCapabilitiesEvent<TileEntity> event) { event.addCapability(new ResourceLocation(Main.MODID + ":capabilites_altar"), new TileEntityAltar()); } Spoiler GameRegistry.registerTileEntity(TileEntityAltar.class, new ResourceLocation(Main.MODID, "tile_entity_altar")); Those are the main changes, but I haven't included minor ones like removing my own useless methods. Thanks! How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
October 27, 20195 yr 16 minutes ago, GenElectrovise said: registerGuiRelations(AttachCapabilitiesEvent<TileEntity> You dont need to use this when it's your TileEntity. Also you wouldn't use new TileEntityAltar here there is a field in the event parameter. 17 minutes ago, GenElectrovise said: net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this) You dont ever have to do this unless you are adding a new object type that has Capabilities. 18 minutes ago, GenElectrovise said: implements ITickable, IItemHandler Get rid of IItemHandler here you only need the field in your class. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
October 29, 20195 yr Author Hi again! Sorry for the belated response! I have done the things mentioned above, however, I also noticed that I was only opening the GUI on the server ( !world.isRemote ) Spoiler @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { try { playerIn.sendMessage(new TextComponentString("Altar activated! +++++++++++++++++++++++++++")); if (worldIn.isRemote) { playerIn.sendMessage(new TextComponentString("World is not remote")); playerIn.openGui(Main.instance, Main.GUI_ALTAR, worldIn, pos.getX(), pos.getY(), pos.getZ()); } } catch (Exception e) { EvileLog.logText(true, EnumLogLevel.ERROR, "An error has occurred opening the GUI for Altar at : " + pos + " : This is not an intended feature! :/"); EvileLog.logText(true, EnumLogLevel.ERROR, e.getMessage() == null ? "No message to print!" : e.getMessage()); e.printStackTrace(); } return true; } and as GUIs don't exist as a GUI on the server -- only the GuiContainer I changed that to openGui if world.isRemote (therefore on the client) and now I get a helpful stacktrace! Spoiler [17:55:22] [main/INFO] [minecraft/GuiNewChat]: [CHAT] Altar activated! +++++++++++++++++++++++++++ [17:55:22] [main/INFO] [minecraft/GuiNewChat]: [CHAT] World is not remote [17:55:22] [main/INFO] [STDOUT]: [com.magiksmostevile.EvileLog:logText:23]: EVILE EXCEPTION! THAT'S AN ERROR! : An error has occurred opening the GUI for Altar at : BlockPos{x=238, y=64, z=250} : This is not an intended feature! [17:55:22] [main/INFO] [STDOUT]: [com.magiksmostevile.EvileLog:logText:23]: EVILE EXCEPTION! THAT'S AN ERROR! : No message to print! [17:55:22] [main/INFO] [STDERR]: [com.magiksmostevile.blocks.AltarBase:onBlockActivated:109]: java.lang.NullPointerException at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:276) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:111) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2809) at com.magiksmostevile.blocks.AltarBase.onBlockActivated(AltarBase.java:104) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:455) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1693) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2380) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2146) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1934) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1187) at net.minecraft.client.Minecraft.run(Minecraft.java:441) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25) [17:55:22] [main/INFO] [minecraft/GuiNewChat]: [CHAT] Altar activated! +++++++++++++++++++++++++++ Even if it should still be !world.isRemote which might seem logical as the client should be getting its prompts from the server, this should still be useful (right?) as it's exposed an error which was unknown and failing silently before. ====== Oh also On 10/27/2019 at 8:49 PM, Animefan8888 said: net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this) wasn't me calling it specifically, it was being called from TileEntity.java when I construct my TileEntityAltar and called its super constructor. Again sorry for taking so long and thanks for all the assistance so far! How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
October 29, 20195 yr Author Also for easier reviewing for future I'm going to make a github repo for this. Also means I'll have a backup! How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
October 29, 20195 yr 55 minutes ago, GenElectrovise said: however, I also noticed that I was only opening the GUI on the server ( !world.isRemote ) This is the correct way to do this. You tell the server hey open this gui from this mod. The server says ok it creates the server side Container and then sends a packet to the Player(client) and then the client opens the gui and container on that side. 55 minutes ago, GenElectrovise said: wasn't me calling it specifically, it was being called from TileEntity.java when I construct my TileEntityAltar and called its super constructor. My bad, but you've solved this by getting rid of the AttachCapabilityEvent right? 50 minutes ago, GenElectrovise said: Also for easier reviewing for future I'm going to make a github repo for this. Also means I'll have a backup! Nice 55 minutes ago, GenElectrovise said: and failing silently before. It might not have been also I failed to notice this on my first glance through your code, but... On 10/26/2019 at 2:02 AM, GenElectrovise said: @Mod.Instance("main") public static Main instance; The string in the Instance annotation needs to be your modid. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.