Jump to content

[Part-solved] Container Tile Entity doesn't like me...


Flenix

Recommended Posts

My original problem is now solved, but the tile entity wont save it's state now. Code is further down the page.

Original post kept below so others can learn from it.


 

Hey guys,

 

I've been trying to make a chest following the Containers and GUIs tutorial on the wiki. Honestly, a few things were missing, but I got it mostly working.

 

My chest is there (textureless and invisibile for now), the GUI opens, and all the slots line up nicely. But, whenever I put something inside, it's stacked across all the diagonal slots:

518cdb81bcfa0.jpg

 

Shift-clicking them moves it to a different section, and duplicates the block. Also, the top-left is mirrored onto the two right-hand extra slots:

518cdbc0585e7.jpg

 

I can't work out why it's doing it at all. Here's my code - I replaced the TileEntity code from the tutorial with the one from the vanilla chest; the tutorial one doesn't store the items after the game closes.

 

 

[spoiler=TileEntitySilvaniteChest]

package co.uk.silvania.Remula.tileentity;

import java.util.Iterator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;

public class TileEntitySilvaniteChest extends TileEntity implements IInventory
{
    private ItemStack[] chestContents = new ItemStack[36];

    /** Determines if the check for adjacent chests has taken place. */
    public boolean adjacentChestChecked = false;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestZNeg;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestXPos;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestXNeg;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestZPosition;

    /** The current angle of the lid (between 0 and 1) */
    public float lidAngle;

    /** The angle of the lid last tick */
    public float prevLidAngle;

    /** The number of players currently using this chest */
    public int numUsingPlayers;

    /** Server sync counter (once per 20 ticks) */
    private int ticksSinceSync;

    /**
     * Returns the number of slots in the inventory.
     */
    public int getSizeInventory()
    {
        return 56;
    }
    //The above is 56; 54 for standard double-chest storage size, and 2 for the bucket slots on the right.
    /**
     * Returns the stack in slot i
     */
    public ItemStack getStackInSlot(int par1)
    {
        return this.chestContents[par1];
    }

    /**
     * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
     * new stack.
     */
    public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.chestContents[par1] != null)
        {
            ItemStack var3;

            if (this.chestContents[par1].stackSize <= par2)
            {
                var3 = this.chestContents[par1];
                this.chestContents[par1] = null;
                this.onInventoryChanged();
                return var3;
            }
            else
            {
                var3 = this.chestContents[par1].splitStack(par2);

                if (this.chestContents[par1].stackSize == 0)
                {
                    this.chestContents[par1] = null;
                }

                this.onInventoryChanged();
                return var3;
            }
        }
        else
        {
            return null;
        }
    }

    /**
     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
     * like when you close a workbench GUI.
     */
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.chestContents[par1] != null)
        {
            ItemStack var2 = this.chestContents[par1];
            this.chestContents[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }

    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     */
    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.chestContents[par1] = par2ItemStack;

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
            par2ItemStack.stackSize = this.getInventoryStackLimit();
        }

        this.onInventoryChanged();
    }

    /**
     * Returns the name of the inventory.
     */
    public String getInvName()
    {
        return "container.chest";
    }

    /**
     * Reads a tile entity from NBT.
     */
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
        this.chestContents = new ItemStack[this.getSizeInventory()];

        for (int var3 = 0; var3 < var2.tagCount(); ++var3)
        {
            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
            int var5 = var4.getByte("Slot") & 255;

            if (var5 >= 0 && var5 < this.chestContents.length)
            {
                this.chestContents[var5] = ItemStack.loadItemStackFromNBT(var4);
            }
        }
    }

    /**
     * Writes a tile entity to NBT.
     */
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeToNBT(par1NBTTagCompound);
        NBTTagList var2 = new NBTTagList();

        for (int var3 = 0; var3 < this.chestContents.length; ++var3)
        {
            if (this.chestContents[var3] != null)
            {
                NBTTagCompound var4 = new NBTTagCompound();
                var4.setByte("Slot", (byte)var3);
                this.chestContents[var3].writeToNBT(var4);
                var2.appendTag(var4);
            }
        }

        par1NBTTagCompound.setTag("Items", var2);
    }

    /**
     * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
     * this more of a set than a get?*
     */
    public int getInventoryStackLimit()
    {
        return 64;
    }

    /**
     * Do not make give this method the name canInteractWith because it clashes with Container
     */
    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    {
        return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    }

    /**
     * Causes the TileEntity to reset all it's cached values for it's container block, blockID, metaData and in the case
     * of chests, the adjcacent chest check
     */
    public void updateContainingBlockInfo()
    {
        super.updateContainingBlockInfo();
        this.adjacentChestChecked = false;
    }

    private void func_90009_a(TileEntitySilvaniteChest par1TileEntityChest, int par2)
    {
        if (par1TileEntityChest.isInvalid())
        {
            this.adjacentChestChecked = false;
        }
        else if (this.adjacentChestChecked)
        {
            switch (par2)
            {
                case 0:
                    if (this.adjacentChestZPosition != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }

                    break;
                case 1:
                    if (this.adjacentChestXNeg != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }

                    break;
                case 2:
                    if (this.adjacentChestZNeg != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }

                    break;
                case 3:
                    if (this.adjacentChestXPos != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }
            }
        }
    }

    /**
     * Performs the check for adjacent chests to determine if this chest is double or not.
     */
    public void checkForAdjacentChests()
    {
        if (!this.adjacentChestChecked)
        {
            this.adjacentChestChecked = true;
            this.adjacentChestZNeg = null;
            this.adjacentChestXPos = null;
            this.adjacentChestXNeg = null;
            this.adjacentChestZPosition = null;

            if (this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) == Block.chest.blockID)
            {
                this.adjacentChestXNeg = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
            }

            if (this.worldObj.getBlockId(this.xCoord + 1, this.yCoord, this.zCoord) == Block.chest.blockID)
            {
                this.adjacentChestXPos = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord);
            }

            if (this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord - 1) == Block.chest.blockID)
            {
                this.adjacentChestZNeg = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
            }

            if (this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord + 1) == Block.chest.blockID)
            {
                this.adjacentChestZPosition = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1);
            }

            if (this.adjacentChestZNeg != null)
            {
                this.adjacentChestZNeg.func_90009_a(this, 0);
            }

            if (this.adjacentChestZPosition != null)
            {
                this.adjacentChestZPosition.func_90009_a(this, 2);
            }

            if (this.adjacentChestXPos != null)
            {
                this.adjacentChestXPos.func_90009_a(this, 1);
            }

            if (this.adjacentChestXNeg != null)
            {
                this.adjacentChestXNeg.func_90009_a(this, 3);
            }
        }
    }

    /**
     * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
     * ticks and creates a new spawn inside its implementation.
     */
    public void updateEntity()
    {
        super.updateEntity();
        this.checkForAdjacentChests();
        ++this.ticksSinceSync;
        float var1;

        if (!this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0)
        {
            this.numUsingPlayers = 0;
            var1 = 5.0F;
            List var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)((float)this.xCoord - var1), (double)((float)this.yCoord - var1), (double)((float)this.zCoord - var1), (double)((float)(this.xCoord + 1) + var1), (double)((float)(this.yCoord + 1) + var1), (double)((float)(this.zCoord + 1) + var1)));
            Iterator var3 = var2.iterator();

            while (var3.hasNext())
            {
                EntityPlayer var4 = (EntityPlayer)var3.next();

                if (var4.openContainer instanceof ContainerChest)
                {
                    IInventory var5 = ((ContainerChest)var4.openContainer).getLowerChestInventory();

                    if (var5 == this || var5 instanceof InventoryLargeChest && ((InventoryLargeChest)var5).isPartOfLargeChest(this))
                    {
                        ++this.numUsingPlayers;
                    }
                }
            }
        }

        this.prevLidAngle = this.lidAngle;
        var1 = 0.1F;
        double var11;

        if (this.numUsingPlayers > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
        {
            double var8 = (double)this.xCoord + 0.5D;
            var11 = (double)this.zCoord + 0.5D;

            if (this.adjacentChestZPosition != null)
            {
                var11 += 0.5D;
            }

            if (this.adjacentChestXPos != null)
            {
                var8 += 0.5D;
            }

            this.worldObj.playSoundEffect(var8, (double)this.yCoord + 0.5D, var11, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
        }

        if (this.numUsingPlayers == 0 && this.lidAngle > 0.0F || this.numUsingPlayers > 0 && this.lidAngle < 1.0F)
        {
            float var9 = this.lidAngle;

            if (this.numUsingPlayers > 0)
            {
                this.lidAngle += var1;
            }
            else
            {
                this.lidAngle -= var1;
            }

            if (this.lidAngle > 1.0F)
            {
                this.lidAngle = 1.0F;
            }

            float var10 = 0.5F;

            if (this.lidAngle < var10 && var9 >= var10 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
            {
                var11 = (double)this.xCoord + 0.5D;
                double var6 = (double)this.zCoord + 0.5D;

                if (this.adjacentChestZPosition != null)
                {
                    var6 += 0.5D;
                }

                if (this.adjacentChestXPos != null)
                {
                    var11 += 0.5D;
                }

                this.worldObj.playSoundEffect(var11, (double)this.yCoord + 0.5D, var6, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
            }

            if (this.lidAngle < 0.0F)
            {
                this.lidAngle = 0.0F;
            }
        }
    }

    /**
     * Called when a client event is received with the event number and argument, see World.sendClientEvent
     */
    public void receiveClientEvent(int par1, int par2)
    {
        if (par1 == 1)
        {
            this.numUsingPlayers = par2;
        }
    }

    public void openChest()
    {
        ++this.numUsingPlayers;
        this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Block.chest.blockID, 1, this.numUsingPlayers);
    }

    public void closeChest()
    {
        --this.numUsingPlayers;
        this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Block.chest.blockID, 1, this.numUsingPlayers);
    }

    /**
     * invalidates a tile entity
     */
    public void invalidate()
    {
        super.invalidate();
        this.updateContainingBlockInfo();
        this.checkForAdjacentChests();
    }
}

 

 

 

[spoiler=ContainerSilvaniteChest]

package co.uk.silvania.Remula.tileentity;

import co.uk.silvania.Remula.Remula;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerSilvaniteChest extends Container {

protected TileEntitySilvaniteChest tileEntity;

public ContainerSilvaniteChest (InventoryPlayer inventoryPlayer, TileEntitySilvaniteChest te) {
	tileEntity = te;
	//Main Storage
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 9; j++) {
			addSlotToContainer(new Slot(tileEntity, j + i, -1 + j * 18, -10 + i * 18));
		}
	}
	//Upper Bucket Slot
        for (int i = 0; i < 1; i++) {
            addSlotToContainer(new Slot(tileEntity, i, 163 + i * 18, -10));
        }
        //Lower Bucket Slot
        for (int i = 0; i < 1; i++) {
            addSlotToContainer(new Slot(tileEntity, i, 163 + i * 18, 148));
        }
	bindPlayerInventory(inventoryPlayer);
}

    @Override
    public boolean canInteractWith(EntityPlayer player) {
            return tileEntity.isUseableByPlayer(player);
    }

    //Player Inventory
    protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
            for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 9; j++) {
                            addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, -1 + j * 18, 112 + i * 18));
                    }
            }
            //Player's hotbar
            for (int i = 0; i < 9; i++) {
                    addSlotToContainer(new Slot(inventoryPlayer, i, -1 + i * 18, 170));
            }
    }

    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
            ItemStack stack = null;
            Slot slotObject = (Slot) inventorySlots.get(slot);

            if (slotObject != null && slotObject.getHasStack()) {
                    ItemStack stackInSlot = slotObject.getStack();
                    stack = stackInSlot.copy();

                    if (slot < 9) {
                            if (!this.mergeItemStack(stackInSlot, 9, 45, true)) {
                                    return null;
                            }
                    }

                    else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
                            return null;
                    }

                    if (stackInSlot.stackSize == 0) {
                            slotObject.putStack(null);
                    } else {
                            slotObject.onSlotChanged();
                    }

                    if (stackInSlot.stackSize == stack.stackSize) {
                            return null;
                    }
                    slotObject.onPickupFromSlot(player, stackInSlot);
            }
            return stack;
    }
}

 

 

 

[spoiler=SilvaniteChest]

package co.uk.silvania.Remula.tileentity;

import java.util.Random;

import co.uk.silvania.Remula.CommonProxy;
import co.uk.silvania.Remula.Remula;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class SilvaniteChest extends BlockContainer {

        public SilvaniteChest (int id) {
                super(id, Material.iron);
                setHardness(2.0F);
                setResistance(5.0F);
                setCreativeTab(Remula.tabRemula);
                this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
        }

        @Override
        public boolean onBlockActivated(World world, int x, int y, int z,
                        EntityPlayer player, int idk, float what, float these, float are) {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if (tileEntity == null || player.isSneaking()) {
                        return false;
                }
        player.openGui(Remula.instance, 0, world, x, y, z);
                return true;
        }

        @Override
        public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
                dropItems(world, x, y, z);
                super.breakBlock(world, x, y, z, par5, par6);
        }
        
        public boolean isOpaqueCube()
        {
            return false;
        }

        public boolean renderAsNormalBlock()
        {
            return false;
        }

        public int getRenderType()
        {
            return 22;
        }
        
        public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
        {
            int var6 = par1World.getBlockId(par2, par3, par4 - 1);
            int var7 = par1World.getBlockId(par2, par3, par4 + 1);
            int var8 = par1World.getBlockId(par2 - 1, par3, par4);
            int var9 = par1World.getBlockId(par2 + 1, par3, par4);
            byte var10 = 0;
            int var11 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

            if (var11 == 0)
            {
                var10 = 2;
            }

            if (var11 == 1)
            {
                var10 = 5;
            }

            if (var11 == 2)
            {
                var10 = 3;
            }

            if (var11 == 3)
            {
                var10 = 4;
            }

            if (var6 != this.blockID && var7 != this.blockID && var8 != this.blockID && var9 != this.blockID)
            {
                par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
            }
            else
            {
                if ((var6 == this.blockID || var7 == this.blockID) && (var10 == 4 || var10 == 5))
                {
                    if (var6 == this.blockID)
                    {
                        par1World.setBlockMetadataWithNotify(par2, par3, par4 - 1, var10);
                    }
                    else
                    {
                        par1World.setBlockMetadataWithNotify(par2, par3, par4 + 1, var10);
                    }

                    par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
                }

                if ((var8 == this.blockID || var9 == this.blockID) && (var10 == 2 || var10 == 3))
                {
                    if (var8 == this.blockID)
                    {
                        par1World.setBlockMetadataWithNotify(par2 - 1, par3, par4, var10);
                    }
                    else
                    {
                        par1World.setBlockMetadataWithNotify(par2 + 1, par3, par4, var10);
                    }

                    par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
                }
            }
        }
        
        @Override
        public String getTextureFile () {
                return CommonProxy.BLOCK_PNG;
        }

        @SideOnly(Side.CLIENT)

        /**
         * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
         */
        public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
        {
            return 4;
        }

        /**
         * Returns the block texture based on the side being looked at.  Args: side
         */
        public int getBlockTextureFromSide(int par1)
        {
            return 4;
        }

        private void dropItems(World world, int x, int y, int z){
                Random rand = new Random();

                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if (!(tileEntity instanceof IInventory)) {
                        return;
                }
                IInventory inventory = (IInventory) tileEntity;

                for (int i = 0; i < inventory.getSizeInventory(); i++) {
                        ItemStack item = inventory.getStackInSlot(i);

                        if (item != null && item.stackSize > 0) {
                                float rx = rand.nextFloat() * 0.8F + 0.1F;
                                float ry = rand.nextFloat() * 0.8F + 0.1F;
                                float rz = rand.nextFloat() * 0.8F + 0.1F;

                                EntityItem entityItem = new EntityItem(world,
                                                x + rx, y + ry, z + rz,
                                                new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));

                                if (item.hasTagCompound()) {
                                        entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
                                }

                                float factor = 0.05F;
                                entityItem.motionX = rand.nextGaussian() * factor;
                                entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
                                entityItem.motionZ = rand.nextGaussian() * factor;
                                world.spawnEntityInWorld(entityItem);
                                item.stackSize = 0;
                        }
                }
        }

        @Override
        public TileEntity createNewTileEntity(World world) {
                return new TileEntitySilvaniteChest();
        }
}

 

 

 

[spoiler=SilvaniteGuiHandler]

package co.uk.silvania.Remula.tileentity;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class SilvaniteGuiHandler implements IGuiHandler {
        //returns an instance of the Container you made earlier
        @Override
        public Object getServerGuiElement(int id, EntityPlayer player, World world,
                        int x, int y, int z) {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if(tileEntity instanceof TileEntitySilvaniteChest){
                        return new ContainerSilvaniteChest(player.inventory, (TileEntitySilvaniteChest) tileEntity);
                }
                return null;
        }

        //returns an instance of the Gui you made earlier
        @Override
        public Object getClientGuiElement(int id, EntityPlayer player, World world,
                        int x, int y, int z) {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if(tileEntity instanceof TileEntitySilvaniteChest){
                        return new SilvaniteGuiChest(player.inventory, (TileEntitySilvaniteChest) tileEntity);
                }
                return null;

        }
}

 

 

 

[spoiler=SilvaniteGuiChest]

package co.uk.silvania.Remula.tileentity;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;

import org.lwjgl.opengl.GL11;

public class SilvaniteGuiChest extends GuiContainer {

        public SilvaniteGuiChest (InventoryPlayer inventoryPlayer, TileEntitySilvaniteChest tileEntity) {
                                super(new ContainerSilvaniteChest(inventoryPlayer, tileEntity));
        }
        
        /** The X size of the inventory window in pixels. */
        protected int xSize = 194;

        /** The Y size of the inventory window in pixels. */
        protected int ySize = 222;

        @Override
        protected void drawGuiContainerForegroundLayer(int param1, int param2) {
                fontRenderer.drawString("Silvanite Chest", 0, -22, 4210752);
                fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 0, ySize - 122, 4210752);
        }

        @Override
        protected void drawGuiContainerBackgroundLayer(float par1, int par2,
                        int par3) {
                int texture = mc.renderEngine.getTexture("/co/uk/silvania/Remula/gui/silvanitechest.png");
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                this.mc.renderEngine.bindTexture(texture);
                int x = (width - xSize) / 2;
                int y = (height - ySize) / 2;
                this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
        }

}

 

 

 

Any help would be really great :) If you need to see other classes let me know. It's probably just a noobie mistake somewhere, this is my first real attempt at tile entites.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

The problem is in your container file. Note the second argument in the constructor of Slot(). That is the ID of the slot, which corresponds to the array index in the TE inventory. Your current implementation of i+j is neither linear nor unique.

That is to say, there are multiple times you will find the same value of i+j (for example 2+4 and 3+3), and as such what you are actually seeing is one slot being represented in multiple GUI instances. Additionally, the diagonal arrangement is because the IDs are not counting as, say, a chest does:

000102030405060708

091010111314151617

181920212223242526

You are instead getting this:

000102030405060708

010203040506070809

020304050607080910

 

Normally, I would provide the exact code, but this one is so easy and so important to understand that I want you to try to work it out on your own first.

Link to comment
Share on other sites

The problem is in your container file. Note the second argument in the constructor of Slot(). That is the ID of the slot, which corresponds to the array index in the TE inventory. Your current implementation of i+j is neither linear nor unique.

That is to say, there are multiple times you will find the same value of i+j (for example 2+4 and 3+3), and as such what you are actually seeing is one slot being represented in multiple GUI instances. Additionally, the diagonal arrangement is because the IDs are not counting as, say, a chest does:

000102030405060708

091010111314151617

181920212223242526

You are instead getting this:

000102030405060708

010203040506070809

020304050607080910

 

Normally, I would provide the exact code, but this one is so easy and so important to understand that I want you to try to work it out on your own first.

 

Alright, so to clarify:

"addSlotToContainer(new Slot(tileEntity, j + i /*something here*/, -1 + j * 18, -10 + i * 18));"

 

I need to put something in there. Looking over the tutorial again, I saw there was a * 3 in there. Experimented a little with multiplying by different amounts, and the position of the duplication did change, but I could never get rid of it. I started getting an Out of Bounds error if I went too high... Any idea what I'm missing?

 

Thanks for helping me try and work this out myself. I do prefer this kind of help, and I think that's the issue with the tutorial I followed; it just gives the code with little to no explanation...

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

For now, forget the tutorial entirely and try to do this by understanding the function of the code itself. Have a look in ContainerChest (or whatever its name may be).

See how it is making the slot IDs correspond to their positions, as a function of row and column (i and j)? Referring back to the table I put in my previous post, try to work out how that little piece of code creates such an arrangement. Maybe even try experimenting.

 

As for the IndexOutOfBounds exception, that is what happens when you try to access slots beyond your inventory's size. So if your size was, say, 54, and you used i+16*j, you would crash as soon as you reached i = 6, j = 3, as 3*16+6 = 54, which is invalid. (I assume you understand array function).

Link to comment
Share on other sites

As for the IndexOutOfBounds exception, that is what happens when you try to access slots beyond your inventory's size. So if your size was, say, 54, and you used i+16*j, you would crash as soon as you reached i = 6, j = 3, as 3*16+6 = 54, which is invalid. (I assume you understand array function).

 

I think this may be the issue. I looked in ContainerChest, and it has the same i+j*9 that I was trying to do (albeit they were var5 and var4). I figure there must be an error somewhere, my out of bounds is saying:

2013-05-12 12:14:28 [iNFO] [sTDERR] Caused by: java.lang.ArrayIndexOutOfBoundsException: 36
2013-05-12 12:14:28 [iNFO] [sTDERR] 	at co.uk.silvania.Remula.tileentity.TileEntitySilvaniteChest.getStackInSlot(TileEntitySilvaniteChest.java:60)
2013-05-12 12:14:28 [iNFO] [sTDERR] 	at net.minecraft.inventory.Slot.getStack(Slot.java:87)
2013-05-12 12:14:28 [iNFO] [sTDERR] 	at net.minecraft.client.gui.inventory.GuiContainer.drawSlotInventory(GuiContainer.java:317)
2013-05-12 12:14:28 [iNFO] [sTDERR] 	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:109)
2013-05-12 12:14:28 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1004)
2013-05-12 12:14:28 [iNFO] [sTDERR] 	... 3 more

 

 

I figure I should be using * 9, because that would be the same as a chest which effectively is what this is.

The error references the return line here, in my TileEntity file:

 

    /**
     * Returns the stack in slot i
     */
    public ItemStack getStackInSlot(int par1)
    {
        return this.chestContents[par1];
    }

 

Which I thought was just checking the contents of the chest... but then again I don't understand tile entities as much as I'd like to.

 

I would have thought that this line would be relevant though, also in the TileEntity:

    /**
     * Returns the number of slots in the inventory.
     */
    public int getSizeInventory()
    {
        return 56;
    }

 

Because surely, my IndexOutOfBounds shouldn't trigger until I reach 56, not 36?

 

I'm almost certain that "i + j * 9" is the right thing judging from what you've said, and the fact that it's in the Inventory code below - and if I change that to say * 4, the inventory code gets the same bug.

:(

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

I feel stupid, ignore me.

 

I just noticed at the top of my TileEntity, I had a line:

private ItemStack[] chestContents = new ItemStack[36];

 

Which I promptly changed to 56.

 

I then changed my Container file:

addSlotToContainer(new Slot(tileEntity, j + i * 9 + 2, -1 + j * 18, -10 + i * 18));

and everything is placing nicely across all 56 slots!

 

Unfortunately, I do still have bugs: Shift-clicking dupilicates the item (Although it's just a ghost, you don't actually get more items, but still annoying)

 

More importantly however, the inventory isn't actually saving:

2013-05-12 12:39:30 [sEVERE] [ForgeModLoader] A TileEntity type co.uk.silvania.Remula.tileentity.TileEntitySilvaniteChest has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class co.uk.silvania.Remula.tileentity.TileEntitySilvaniteChest is missing a mapping! This is a bug!
at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:107)
at co.uk.silvania.Remula.tileentity.TileEntitySilvaniteChest.writeToNBT(TileEntitySilvaniteChest.java:165)
at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:311)
at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:127)
at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:232)
at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:284)
at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:844)
at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:373)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

Here's an up-to-date version of my TileEntitySilvaniteChest and ContainerSilvaniteChest files. Most of the TileEntitySilvaniteChest is pretty much the same as vanilla chest, but I changed a few things trying to get it to work...

 

[spoiler=TileEntitySilvaniteChest]

package co.uk.silvania.Remula.tileentity;

import java.util.Iterator;
import java.util.List;

import co.uk.silvania.Remula.Remula;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;

public class TileEntitySilvaniteChest extends TileEntity implements IInventory
{
    private ItemStack[] silvaniteChestContents = new ItemStack[56];

    /** Determines if the check for adjacent chests has taken place. */
    public boolean adjacentChestChecked = false;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestZNeg;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestXPos;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestXNeg;

    /** Contains the chest tile located adjacent to this one (if any) */
    public TileEntitySilvaniteChest adjacentChestZPosition;

    /** The current angle of the lid (between 0 and 1) */
    public float lidAngle;

    /** The angle of the lid last tick */
    public float prevLidAngle;

    /** The number of players currently using this chest */
    public int numUsingPlayers;

    /** Server sync counter (once per 20 ticks) */
    private int ticksSinceSync;

    /**
     * Returns the number of slots in the inventory.
     */
    public int getSizeInventory()
    {
        return 56;
    }

    /**
     * Returns the stack in slot i
     */
    public ItemStack getStackInSlot(int par1)
    {
        return this.silvaniteChestContents[par1];
    }

    /**
     * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
     * new stack.
     */
    public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.silvaniteChestContents[par1] != null)
        {
            ItemStack var3;

            if (this.silvaniteChestContents[par1].stackSize <= par2)
            {
                var3 = this.silvaniteChestContents[par1];
                this.silvaniteChestContents[par1] = null;
                this.onInventoryChanged();
                return var3;
            }
            else
            {
                var3 = this.silvaniteChestContents[par1].splitStack(par2);

                if (this.silvaniteChestContents[par1].stackSize == 0)
                {
                    this.silvaniteChestContents[par1] = null;
                }

                this.onInventoryChanged();
                return var3;
            }
        }
        else
        {
            return null;
        }
    }

    /**
     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
     * like when you close a workbench GUI.
     */
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.silvaniteChestContents[par1] != null)
        {
            ItemStack var2 = this.silvaniteChestContents[par1];
            this.silvaniteChestContents[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }

    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     */
    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.silvaniteChestContents[par1] = par2ItemStack;

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
            par2ItemStack.stackSize = this.getInventoryStackLimit();
        }

        this.onInventoryChanged();
    }

    /**
     * Returns the name of the inventory.
     */
    public String getInvName()
    {
        return "Silvanite Chest";
    }

    /**
     * Reads a tile entity from NBT.
     */
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
        this.silvaniteChestContents = new ItemStack[this.getSizeInventory()];

        for (int var3 = 0; var3 < var2.tagCount(); ++var3)
        {
            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
            int var5 = var4.getByte("Slot") & 255;

            if (var5 >= 0 && var5 < this.silvaniteChestContents.length)
            {
                this.silvaniteChestContents[var5] = ItemStack.loadItemStackFromNBT(var4);
            }
        }
    }

    /**
     * Writes a tile entity to NBT.
     */
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeToNBT(par1NBTTagCompound);
        NBTTagList var2 = new NBTTagList();

        for (int var3 = 0; var3 < this.silvaniteChestContents.length; ++var3)
        {
            if (this.silvaniteChestContents[var3] != null)
            {
                NBTTagCompound var4 = new NBTTagCompound();
                var4.setByte("Slot", (byte)var3);
                this.silvaniteChestContents[var3].writeToNBT(var4);
                var2.appendTag(var4);
            }
        }

        par1NBTTagCompound.setTag("Items", var2);
    }

    /**
     * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
     * this more of a set than a get?*
     */
    public int getInventoryStackLimit()
    {
        return 64;
    }

    /**
     * Do not make give this method the name canInteractWith because it clashes with Container
     */
    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    {
        return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    }

    /**
     * Causes the TileEntity to reset all it's cached values for it's container block, blockID, metaData and in the case
     * of Chests, the adjcacent Chest check
     */
    public void updateContainingBlockInfo()
    {
        super.updateContainingBlockInfo();
        this.adjacentChestChecked = false;
    }

    private void func_90009_a(TileEntitySilvaniteChest par1TileEntityChest, int par2)
    {
        if (par1TileEntityChest.isInvalid())
        {
            this.adjacentChestChecked = false;
        }
        else if (this.adjacentChestChecked)
        {
            switch (par2)
            {
                case 0:
                    if (this.adjacentChestZPosition != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }

                    break;
                case 1:
                    if (this.adjacentChestXNeg != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }

                    break;
                case 2:
                    if (this.adjacentChestZNeg != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }

                    break;
                case 3:
                    if (this.adjacentChestXPos != par1TileEntityChest)
                    {
                        this.adjacentChestChecked = false;
                    }
            }
        }
    }

    /**
     * Performs the check for adjacent silvaniteChests to determine if this silvaniteChest is double or not.
     */
    public void checkForAdjacentChests()
    {
        if (!this.adjacentChestChecked)
        {
            this.adjacentChestChecked = true;
            this.adjacentChestZNeg = null;
            this.adjacentChestXPos = null;
            this.adjacentChestXNeg = null;
            this.adjacentChestZPosition = null;

            if (this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) == Remula.silvaniteChest.blockID)
            {
                this.adjacentChestXNeg = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
            }

            if (this.worldObj.getBlockId(this.xCoord + 1, this.yCoord, this.zCoord) == Remula.silvaniteChest.blockID)
            {
                this.adjacentChestXPos = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord);
            }

            if (this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord - 1) == Remula.silvaniteChest.blockID)
            {
                this.adjacentChestZNeg = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
            }

            if (this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord + 1) == Remula.silvaniteChest.blockID)
            {
                this.adjacentChestZPosition = (TileEntitySilvaniteChest)this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1);
            }

            if (this.adjacentChestZNeg != null)
            {
                this.adjacentChestZNeg.func_90009_a(this, 0);
            }

            if (this.adjacentChestZPosition != null)
            {
                this.adjacentChestZPosition.func_90009_a(this, 2);
            }

            if (this.adjacentChestXPos != null)
            {
                this.adjacentChestXPos.func_90009_a(this, 1);
            }

            if (this.adjacentChestXNeg != null)
            {
                this.adjacentChestXNeg.func_90009_a(this, 3);
            }
        }
    }

    /**
     * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
     * ticks and creates a new spawn inside its implementation.
     */
    public void updateEntity()
    {
        super.updateEntity();
        this.checkForAdjacentChests();
        ++this.ticksSinceSync;
        float var1;

        if (!this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0)
        {
            this.numUsingPlayers = 0;
            var1 = 5.0F;
            List var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double)((float)this.xCoord - var1), (double)((float)this.yCoord - var1), (double)((float)this.zCoord - var1), (double)((float)(this.xCoord + 1) + var1), (double)((float)(this.yCoord + 1) + var1), (double)((float)(this.zCoord + 1) + var1)));
            Iterator var3 = var2.iterator();

            while (var3.hasNext())
            {
                EntityPlayer var4 = (EntityPlayer)var3.next();

                if (var4.openContainer instanceof ContainerSilvaniteChest)
                {
                    IInventory var5 = ((ContainerSilvaniteChest)var4.openContainer).getSilvaniteChestInventory();

                    ++this.numUsingPlayers;
                }
            }
        }

        this.prevLidAngle = this.lidAngle;
        var1 = 0.1F;
        double var11;

        if (this.numUsingPlayers > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
        {
            double var8 = (double)this.xCoord + 0.5D;
            var11 = (double)this.zCoord + 0.5D;

            if (this.adjacentChestZPosition != null)
            {
                var11 += 0.5D;
            }

            if (this.adjacentChestXPos != null)
            {
                var8 += 0.5D;
            }

            this.worldObj.playSoundEffect(var8, (double)this.yCoord + 0.5D, var11, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
        }

        if (this.numUsingPlayers == 0 && this.lidAngle > 0.0F || this.numUsingPlayers > 0 && this.lidAngle < 1.0F)
        {
            float var9 = this.lidAngle;

            if (this.numUsingPlayers > 0)
            {
                this.lidAngle += var1;
            }
            else
            {
                this.lidAngle -= var1;
            }

            if (this.lidAngle > 1.0F)
            {
                this.lidAngle = 1.0F;
            }

            float var10 = 0.5F;

            if (this.lidAngle < var10 && var9 >= var10 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null)
            {
                var11 = (double)this.xCoord + 0.5D;
                double var6 = (double)this.zCoord + 0.5D;

                if (this.adjacentChestZPosition != null)
                {
                    var6 += 0.5D;
                }

                if (this.adjacentChestXPos != null)
                {
                    var11 += 0.5D;
                }

                this.worldObj.playSoundEffect(var11, (double)this.yCoord + 0.5D, var6, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
            }

            if (this.lidAngle < 0.0F)
            {
                this.lidAngle = 0.0F;
            }
        }
    }

    /**
     * Called when a client event is received with the event number and argument, see World.sendClientEvent
     */
    public void receiveClientEvent(int par1, int par2)
    {
        if (par1 == 1)
        {
            this.numUsingPlayers = par2;
        }
    }

    public void openChest()
    {
        ++this.numUsingPlayers;
        this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Remula.silvaniteChest.blockID, 1, this.numUsingPlayers);
    }

    public void closeChest()
    {
        --this.numUsingPlayers;
        this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Remula.silvaniteChest.blockID, 1, this.numUsingPlayers);
    }

    /**
     * invalidates a tile entity
     */
    public void invalidate()
    {
        super.invalidate();
        this.updateContainingBlockInfo();
        this.checkForAdjacentChests();
    }
}

 

 

 

[spoiler=ContainerSilvaniteChest]

package co.uk.silvania.Remula.tileentity;

import co.uk.silvania.Remula.Remula;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerSilvaniteChest extends Container {

protected TileEntitySilvaniteChest tileEntity;
private IInventory silvaniteChestInventory;

public ContainerSilvaniteChest (InventoryPlayer inventoryPlayer, TileEntitySilvaniteChest te) {
	tileEntity = te;
	//Main Storage
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 9; j++) {
			addSlotToContainer(new Slot(tileEntity, j + i * 9 + 2, -1 + j * 18, -10 + i * 18));
		}
	}
	//Upper Bucket Slot
        for (int k = 0; k < 1; k++) {
            addSlotToContainer(new Slot(tileEntity, k, 163 + k * 18, -10));
        }
        //Lower Bucket Slot
        for (int l = 0; l < 1; l++) {
            addSlotToContainer(new Slot(tileEntity, l, 163 + l * 18, 148));
        }
	bindPlayerInventory(inventoryPlayer);
}

    @Override
    public boolean canInteractWith(EntityPlayer player) {
            return tileEntity.isUseableByPlayer(player);
    }

    //Player Inventory
    protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
            for (int m = 0; m < 3; m++) {
                    for (int n = 0; n < 9; n++) {
                            addSlotToContainer(new Slot(inventoryPlayer, n + m * 9 + 9, -1 + n * 18, 112 + m * 18));
                    }
            }
            //Player's hotbar
            for (int o = 0; o < 9; o++) {
                    addSlotToContainer(new Slot(inventoryPlayer, o, -1 + o * 18, 170));
            }
    }

    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
            ItemStack stack = null;
            Slot slotObject = (Slot) inventorySlots.get(slot);

            if (slotObject != null && slotObject.getHasStack()) {
                    ItemStack stackInSlot = slotObject.getStack();
                    stack = stackInSlot.copy();

                    if (slot < 9) {
                            if (!this.mergeItemStack(stackInSlot, 9, 45, true)) {
                                    return null;
                            }
                    }

                    else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
                            return null;
                    }

                    if (stackInSlot.stackSize == 10) {
                            slotObject.putStack(null);
                    } else {
                            slotObject.onSlotChanged();
                    }

                    if (stackInSlot.stackSize == stack.stackSize) {
                            return null;
                    }
                    slotObject.onPickupFromSlot(player, stackInSlot);
            }
            return stack;
    }
    public IInventory getSilvaniteChestInventory()
    {
        return this.silvaniteChestInventory;
    }
}

 

 

 

Sorry for needing so much help, but I really appreciate you pointing me in the right direction like this. I'm doing this to learn Java, not make a cheap mod, so it's really helping me :)

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

You need to register your TileEntity with the GameRegistry.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

I also for the life of me can't figure out how to texture it. I've tried

        @Override
        public String getTextureFile () {
                return "/co/uk/silvania/Remula/resources/SilvaniteChest1.png";
        }

(Path is correct)

 

And I've also tried changing it to my model in TileEntitySilvaniteChestRenderer. I have no idea if that's taken effect or not, as it's just invisibile right now.

It's worth nothing I'm still on 1.4.7 as this is for my server.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I had the same issue. The only thing I could do is to remove parchment mappings entirely from config files and replace config files from the MDK: 1. replace build.gradle from MDK 2. restore official mapping in build.properties 3. replace src\main\resources\META-INF\mods.toml from MDK sample.
    • ---- Minecraft Crash Report ---- I sent a error report i just cant understand it, the game as been running fine intill today i loaded it https://pastebin.com/gWVFh4Fe   WARNING: coremods are present:   ForgelinPlugin (Forgelin-1.8.3.jar)   PatchingFixRtmCorePlugin (fixRtm-2.0.28.jar)   IELoadingPlugin (ImmersiveEngineering-core-0.12-98.jar)   FixRtmCorePlugin (fixRtm-2.0.28.jar)   JarInJarLoaderCoreMod (fixRtm-2.0.28.jar)   BetterFoliageLoader (BetterFoliage-MC1.12-2.3.2.jar)   SecurityCraftLoadingPlugin ([1.12.2] SecurityCraft v1.9.9.jar)   OpenModsCorePlugin (OpenModsLib-1.12.2-0.12.2.jar)   MalisisCorePlugin (MalisisCore-1.12.2.jar)   ObfuscatePlugin (obfuscate-0.4.2-1.12.2.jar)   CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)   HookingFixRtmCorePlugin (fixRtm-2.0.28.jar) Contact their authors BEFORE contacting forge // Hey, that tickles! Hehehe! Time: 4/19/24 4:05 PM Description: Updating screen events java.lang.RuntimeException: Failed to check session lock, aborting     at net.minecraft.world.storage.SaveHandler.func_75766_h(SaveHandler.java:76)     at net.minecraft.world.storage.SaveHandler.<init>(SaveHandler.java:54)     at net.minecraft.world.chunk.storage.AnvilSaveHandler.<init>(AnvilSaveHandler.java:18)     at net.minecraft.world.chunk.storage.AnvilSaveConverter.func_75804_a(SourceFile:84)     at net.minecraft.client.Minecraft.func_71371_a(Minecraft.java:2346)     at net.minecraftforge.fml.client.FMLClientHandler.tryLoadExistingWorld(FMLClientHandler.java:734)     at net.minecraft.client.gui.GuiListWorldSelectionEntry.func_186777_e(GuiListWorldSelectionEntry.java:249)     at net.minecraft.client.gui.GuiListWorldSelectionEntry.func_186774_a(GuiListWorldSelectionEntry.java:199)     at net.minecraft.client.gui.GuiListWorldSelectionEntry.func_148278_a(GuiListWorldSelectionEntry.java:163)     at net.minecraft.client.gui.GuiListExtended.func_148179_a(SourceFile:41)     at net.minecraft.client.gui.GuiWorldSelection.func_73864_a(SourceFile:117)     at net.minecraft.client.gui.GuiScreen.func_146274_d(GuiScreen.java:533)     at net.minecraft.client.gui.GuiWorldSelection.func_146274_d(SourceFile:49)     at net.minecraft.client.gui.GuiScreen.func_146269_k(GuiScreen.java:501)     at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1759)     at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098)     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)     at net.minecraft.client.main.Main.main(SourceFile:123)     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:497)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace:     at net.minecraft.world.storage.SaveHandler.func_75766_h(SaveHandler.java:76)     at net.minecraft.world.storage.SaveHandler.<init>(SaveHandler.java:54)     at net.minecraft.world.chunk.storage.AnvilSaveHandler.<init>(AnvilSaveHandler.java:18)     at net.minecraft.world.chunk.storage.AnvilSaveConverter.func_75804_a(SourceFile:84)     at net.minecraft.client.Minecraft.func_71371_a(Minecraft.java:2346)     at net.minecraftforge.fml.client.FMLClientHandler.tryLoadExistingWorld(FMLClientHandler.java:734)     at net.minecraft.client.gui.GuiListWorldSelectionEntry.func_186777_e(GuiListWorldSelectionEntry.java:249)     at net.minecraft.client.gui.GuiListWorldSelectionEntry.func_186774_a(GuiListWorldSelectionEntry.java:199)     at net.minecraft.client.gui.GuiListWorldSelectionEntry.func_148278_a(GuiListWorldSelectionEntry.java:163)     at net.minecraft.client.gui.GuiListExtended.func_148179_a(SourceFile:41)     at net.minecraft.client.gui.GuiWorldSelection.func_73864_a(SourceFile:117)     at net.minecraft.client.gui.GuiScreen.func_146274_d(GuiScreen.java:533)     at net.minecraft.client.gui.GuiWorldSelection.func_146274_d(SourceFile:49)     at net.minecraft.client.gui.GuiScreen.func_146269_k(GuiScreen.java:501) -- Affected screen -- Details:     Screen name: net.minecraft.client.gui.GuiWorldSelection Stacktrace:     at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1759)     at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098)     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)     at net.minecraft.client.main.Main.main(SourceFile:123)     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:497)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details:     Minecraft Version: 1.12.2     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 5013709368 bytes (4781 MB) / 11274289152 bytes (10752 MB) up to 12884901888 bytes (12288 MB)     JVM Flags: 8 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx12G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0     FML: MCP 9.42 Powered by Forge 14.23.5.2859 Optifine OptiFine_1.12.2_HD_U_G5 99 mods loaded, 99 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored     | State  | ID                          | Version               | Source                                            | Signature                                |     |:------ |:--------------------------- |:--------------------- |:------------------------------------------------- |:---------------------------------------- |     | LCHIJA | minecraft                   | 1.12.2                | minecraft.jar                                     | None                                     |     | LCHIJA | mcp                         | 9.42                  | minecraft.jar                                     | None                                     |     | LCHIJA | FML                         | 8.0.99.99             | forge-1.12.2-14.23.5.2859.jar                     | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCHIJA | forge                       | 14.23.5.2859          | forge-1.12.2-14.23.5.2859.jar                     | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCHIJA | openmodscore                | 0.12.2                | minecraft.jar                                     | None                                     |     | LCHIJA | obfuscate                   | 0.4.2                 | minecraft.jar                                     | None                                     |     | LCHIJA | securitycraft               | v1.9.9                | [1.12.2] SecurityCraft v1.9.9.jar                 | None                                     |     | LCHIJA | mts                         | 22.14.2               | Immersive Vehicles-1.12.2-22.14.2.jar             | None                                     |     | LCHIJA | mtsaircooled                | 1.0.1                 | Air-Cooled Pack [MTS] 1.10.2-14.0.0-1.0.1.jar     | None                                     |     | LCHIJA | codechickenlib              | 3.2.3.358             | CodeChickenLib-1.12.2-3.2.3.358-universal.jar     | f1850c39b2516232a2108a7bd84d1cb5df93b261 |     | LCHIJA | ancientwarfare              | 1.12.2-2.7.0.1038     | ancientwarfare-1.12.2-2.7.0.1038.jar              | None                                     |     | LCHIJA | redstoneflux                | 2.1.1                 | RedstoneFlux-1.12-2.1.1.1-universal.jar           | None                                     |     | LCHIJA | ancientwarfareautomation    | 1.12.2-2.7.0.1038     | ancientwarfare-1.12.2-2.7.0.1038.jar              | None                                     |     | LCHIJA | ancientwarfarenpc           | 1.12.2-2.7.0.1038     | ancientwarfare-1.12.2-2.7.0.1038.jar              | None                                     |     | LCHIJA | ancientwarfarestructure     | 1.12.2-2.7.0.1038     | ancientwarfare-1.12.2-2.7.0.1038.jar              | None                                     |     | LCHIJA | ancientwarfarevehicle       | 1.12.2-2.7.0.1038     | ancientwarfare-1.12.2-2.7.0.1038.jar              | None                                     |     | LCHIJA | craftstudioapi              | 1.0.0                 | CraftStudio-1.0.0.93-mc1.12-alpha.jar             | None                                     |     | LCHIJA | animania                    | 2.0.3.28              | animania-1.12.2-base-2.0.3.28.jar                 | None                                     |     | LCHIJA | architecturecraft           | @VERSION@             | architecturecraft-1.12-3.108.jar                  | None                                     |     | LCHIJA | betteranimationscollection2 | 1.0.2                 | BetterAnimationsCollection2-v1.0.2-1.12.2.jar     | 12d137bcc36051a1c2c8ea7211cfc1da1c6e9dea |     | LCHIJA | forgelin                    | 1.8.3                 | Forgelin-1.8.3.jar                                | None                                     |     | LCHIJA | betterfoliage               | 2.3.1                 | BetterFoliage-MC1.12-2.3.2.jar                    | None                                     |     | LCHIJA | bibliocraft                 | 2.4.6                 | BiblioCraft[v2.4.6][MC1.12.2].jar                 | None                                     |     | LCHIJA | biomestaff                  | 1.0.0                 | BiomeStaff-1.12.2-1.0.0.jar                       | None                                     |     | LCHIJA | blockcraftery               | 1.12.2-1.3.1          | blockcraftery-1.12.2-1.3.1.jar                    | None                                     |     | LCHIJA | bookshelf                   | 2.3.590               | Bookshelf-1.12.2-2.3.590.jar                      | d476d1b22b218a10d845928d1665d45fce301b27 |     | LCHIJA | bookworm                    | 1.12.2-2.5.2.1        | Bookworm-Library-Mod-1.12.2.jar                   | None                                     |     | LCHIJA | brandonscore                | 2.4.20                | BrandonsCore-1.12.2-2.4.20.162-universal.jar      | None                                     |     | LCHIJA | bspkrscore                  | 8.0.0                 | BspkrsCore-1.12.2.jar                             | None                                     |     | LCHIJA | carpentersblocks            | 3.4.0-poc.6           | Carpenters-Blocks-v3.4.0-poc.6-MC-1.12.2.jar      | None                                     |     | LCHIJA | ctm                         | MC1.12.2-1.0.2.31     | CTM-MC1.12.2-1.0.2.31.jar                         | None                                     |     | LCHIJA | jei                         | 4.16.1.1012           | jei_1.12.2-4.16.1.1012.jar                        | None                                     |     | LCHIJA | chisel                      | MC1.12.2-1.0.2.45     | Chisel-Mod-1.12.2.jar                             | None                                     |     | LCHIJA | chiselsandbits              | 14.33                 | chiselsandbits-14.33.jar                          | None                                     |     | LCHIJA | customspawner               | 3.11.4                | CustomMobSpawner-3.11.5.jar                       | None                                     |     | LCHIJA | customsignposts             | 1.0                   | customsignposts-1.12.2-1.0.1.jar                  | None                                     |     | LCHIJA | ptrmodellib                 | 1.0.5                 | PTRLib-1.0.5.jar                                  | None                                     |     | LCHIJA | props                       | 2.6.3.7               | Decocraft-2.6.3.7_1.12.2.jar                      | None                                     |     | LCHIJA | mocreatures                 | 12.0.5                | DrZharks MoCreatures Mod-12.0.5.jar               | None                                     |     | LCHIJA | engineersdecor              | 1.1.5                 | engineersdecor-1.12.2-1.1.5.jar                   | ed58ed655893ced6280650866985abcae2bf7559 |     | LCHIJA | exoticbirds                 | 1.0                   | Exotic Birds 1.12.2-3.2.0.jar                     | None                                     |     | LCHIJA | unuparts                    | 6.5.0                 | UNU Parts Pack [MTS] 1.12.2-22.13.0-6.5.0.jar     | None                                     |     | LCHIJA | unuverse                    | 2.0.0                 | ExpandedUNUversePack[MTS]1.12.2-19.15.5-2.0.0.jar | None                                     |     | LCHIJA | fairylights                 | 2.1.10                | fairylights-2.2.0-1.12.2.jar                      | None                                     |     | LCHIJA | fcl                         | 1.12.82               | FCL-1.12.82c.jar                                  | None                                     |     | LCHIJA | net/fexcraft/lib/frl        | 1.2                   | FCL-1.12.82c.jar                                  | None                                     |     | LCHIJA | net/fexcraft/lib/tmt        | 1.15                  | FCL-1.12.82c.jar                                  | None                                     |     | LCHIJA | famm                        | 3.4.0                 | Fexs-Alphabet-and-More-Mod-Forge-1.12.2.jar       | None                                     |     | LCHIJA | forgemultipartcbe           | 2.6.2.83              | ForgeMultipart-1.12.2-2.6.2.83-universal.jar      | f1850c39b2516232a2108a7bd84d1cb5df93b261 |     | LCHIJA | microblockcbe               | 2.6.2.83              | ForgeMultipart-1.12.2-2.6.2.83-universal.jar      | None                                     |     | LCHIJA | minecraftmultipartcbe       | 2.6.2.83              | ForgeMultipart-1.12.2-2.6.2.83-universal.jar      | None                                     |     | LCHIJA | funkylocomotion             | 1.0                   | funky-locomotion-1.12.2-1.1.2.jar                 | None                                     |     | LCHIJA | furenikusroads              | 1.2.5                 | Furenikus_Roads-1.2.5.jar                         | None                                     |     | LCHIJA | cfm                         | 6.3.0                 | furniture-6.3.2-1.12.2.jar                        | None                                     |     | LCHIJA | waila                       | 1.8.22                | Hwyla-1.8.22-B37_1.12.jar                         | None                                     |     | LCHIJA | trackapi                    | 1.2                   | TrackAPI-1.2.jar                                  | None                                     |     | LCHIJA | universalmodcore            | 1.2.1                 | UniversalModCore-1.12.2-forge-1.2.1.jar           | None                                     |     | LCHIJA | immersiverailroading        | 1.10.0                | ImmersiveRailroading-1.12.2-forge-1.10.0.jar      | None                                     |     | LCHIJA | journeymap                  | 1.12.2-5.7.1p2        | journeymap-1.12.2-5.7.1p2.jar                     | None                                     |     | LCHIJA | zawa                        | 1.12.2-2.1.3          | zawa-1.12.2-2.1.3.jar                             | 3ee471ded1bba54aa82f4f5ca5ca82dd67b8ef42 |     | LCHIJA | lilcritters                 | 1.12.2-1.1.0.0        | Lil-Critters-Mod-Forge-1.12.2.jar                 | None                                     |     | LCHIJA | malisiscore                 | 1.12.2-6.5.1-SNAPSHOT | MalisisCore-1.12.2.jar                            | None                                     |     | LCHIJA | malisisdoors                | 1.12.2-7.3.0          | MalisisDoors-Mod-1.12.2.jar                       | None                                     |     | LCHIJA | mcwbridges                  | 1.0.6                 | mcw-bridges-1.0.6b-mc1.12.2.jar                   | None                                     |     | LCHIJA | mcwfences                   | 1.0.0                 | mcw-fences-1.0.0-mc1.12.2.jar                     | None                                     |     | LCHIJA | mcwroofs                    | 1.0.2                 | mcw-roofs-1.0.2-mc1.12.2.jar                      | None                                     |     | LCHIJA | moon-core                   | 7.0                   | Moons-Core-Forge-1.12.2.jar                       | None                                     |     | LCHIJA | mrtjpcore                   | 2.1.4.43              | MrTJPCore-1.12.2-2.1.4.43-universal.jar           | None                                     |     | LCHIJA | railcraft                   | 12.0.0                | railcraft-12.0.0.jar                              | a0c255ac501b2749537d5824bb0f0588bf0320fa |     | LCHIJA | mtr                         | 3.0.0                 | MTR-1.12.2-alpha-test-0.0.1.jar                   | None                                     |     | LCHIJA | kadwinjpvehicles            | 2.0.0                 | MTS_Kadwin_JP_Vehicles_Pack_4.1.jar               | None                                     |     | LCHIJA | ngtlib                      | 2.4.21                | NGTLib2.4.21-38_forge-1.12.2-14.23.2.2611.jar     | None                                     |     | LCHIJA | projectintelligence         | 1.0.9                 | ProjectIntelligence-1.12.2-1.0.9.28-universal.jar | None                                     |     | LCHIJA | nei                         | 2.4.3                 | NotEnoughItems-1.12.2-2.4.3.245-universal.jar     | f1850c39b2516232a2108a7bd84d1cb5df93b261 |     | LCHIJA | oe                          | 1.0.7                 | OceanicExpanse-1.0.7.jar                          | None                                     |     | LCHIJA | openmods                    | 0.12.2                | OpenModsLib-1.12.2-0.12.2.jar                     | d2a9a8e8440196e26a268d1f3ddc01b2e9c572a5 |     | LCHIJA | openblocks                  | 1.8.1                 | OpenBlocks-1.12.2-1.8.1.jar                       | d2a9a8e8440196e26a268d1f3ddc01b2e9c572a5 |     | LCHIJA | placeableitems              | 3.3                   | placeableitems-3.3.jar                            | None                                     |     | LCHIJA | projectred-core             | 4.9.4.120             | ProjectRed-1.12.2-4.9.4.120-Base.jar              | None                                     |     | LCHIJA | projectred-integration      | 4.9.4.120             | ProjectRed-1.12.2-4.9.4.120-integration.jar       | None                                     |     | LCHIJA | projectred-transmission     | 4.9.4.120             | ProjectRed-1.12.2-4.9.4.120-integration.jar       | None                                     |     | LCHIJA | projectred-illumination     | 4.9.4.120             | ProjectRed-1.12.2-4.9.4.120-lighting.jar          | None                                     |     | LCHIJA | projectred-expansion        | 4.9.4.120             | ProjectRed-1.12.2-4.9.4.120-mechanical.jar        | None                                     |     | LCHIJA | projectred-relocation       | 4.9.4.120             | ProjectRed-1.12.2-4.9.4.120-mechanical.jar        | None                                     |     | LCHIJA | projectred-transportation   | 4.9.4.120             | ProjectRed-1.12.2-4.9.4.120-mechanical.jar        | None                                     |     | LCHIJA | rtm                         | 2.4.24                | RTM2.4.24-43_forge-1.12.2-14.23.2.2611.jar        | None                                     |     | LCHIJA | trafficcontrol              | 1.1.1                 | trafficcontrol-1.1.1.jar                          | None                                     |     | LCHIJA | travelersbackpack           | 1.0.35                | TravelersBackpack-1.12.2-1.0.35.jar               | None                                     |     | LCHIJA | iv_tpp                      | 2.22.0                | Trin Parts Pack-1.12.2-2.23.1.jar                 | None                                     |     | LCHIJA | unucivil                    | 6.3.0                 | UNU Civilian Pack [MTS] 1.12.2-22.13.0-6.3.0.jar  | None                                     |     | LCHIJA | vehicle                     | 0.44.1                | vehicle-mod-0.44.1-1.12.2.jar                     | None                                     |     | LCHIJA | wawla                       | 2.6.275               | Wawla-1.12.2-2.6.275.jar                          | d476d1b22b218a10d845928d1665d45fce301b27 |     | LCHIJA | worldedit                   | 6.1.10                | worldedit-forge-mc1.12.2-6.1.10-dist.jar          | None                                     |     | LCHIJA | worldstatecheckpoints       | 1.12.2.1.2.1          | WorldStateCheckpoints-client-1.12.2.1.2.1.jar     | None                                     |     | LCHIJA | wrcbe                       | 2.3.2                 | WR-CBE-1.12.2-2.3.2.33-universal.jar              | f1850c39b2516232a2108a7bd84d1cb5df93b261 |     | LCHIJA | zoocraftdiscoveries         | 1.0                   | Zoocraft+Discoveries+1.12.2-1.3.0.jar             | None                                     |     | LCHIJA | immersiveengineering        | 0.12-98               | ImmersiveEngineering-0.12-98.jar                  | None                                     |     | LCHIJA | fix-rtm                     | 2.0.28                | fixRtm-2.0.28.jar                                 | None                                     |     | LCHIJA | mysticallib                 | 1.12.2-1.13.0         | mysticallib-1.12.2-1.13.0.jar                     | None                                     |     Loaded coremods (and transformers): ForgelinPlugin (Forgelin-1.8.3.jar)   PatchingFixRtmCorePlugin (fixRtm-2.0.28.jar)   com.anatawa12.fixRtm.asm.patching.PatchApplier IELoadingPlugin (ImmersiveEngineering-core-0.12-98.jar)   blusunrize.immersiveengineering.common.asm.IEClassTransformer FixRtmCorePlugin (fixRtm-2.0.28.jar)   JarInJarLoaderCoreMod (fixRtm-2.0.28.jar)   com.anatawa12.fixRtm.jarInJar.JarInJarPatcher BetterFoliageLoader (BetterFoliage-MC1.12-2.3.2.jar)   mods.betterfoliage.loader.BetterFoliageTransformer SecurityCraftLoadingPlugin ([1.12.2] SecurityCraft v1.9.9.jar)   OpenModsCorePlugin (OpenModsLib-1.12.2-0.12.2.jar)   openmods.core.OpenModsClassTransformer MalisisCorePlugin (MalisisCore-1.12.2.jar)   ObfuscatePlugin (obfuscate-0.4.2-1.12.2.jar)   com.mrcrayfish.obfuscate.asm.ObfuscateTransformer CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)   team.chisel.ctm.client.asm.CTMTransformer HookingFixRtmCorePlugin (fixRtm-2.0.28.jar)   com.anatawa12.fixRtm.asm.hooking.HookingTransformer     GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 551.86' Renderer: 'NVIDIA GeForce RTX 3070/PCIe/SSE2'     OpenModsLib class transformers: [llama_null_fix:FINISHED],[horse_base_null_fix:FINISHED],[pre_world_render_hook:FINISHED],[player_render_hook:FINISHED],[horse_null_fix:FINISHED]     RTM Model Status: Initialized 1048 models, Using 0 models     I = Initialized, C = Constructed, SMP = SMP includeds     | model pack                                      | all | I | C   | SMP |     |:----------------------------------------------- |:--- |:- |:--- |:--- |     | mods\ModelPack_Nak_5_Structure_240313.zip       | 458 | 0 | 458 | 0   |     | mods\RTM2.4.24-43_forge-1.12.2-14.23.2.2611.jar | 281 | 0 | 281 | 0   |     | mods\rtm_Saracalias Pack v0.2.01.zip            | 309 | 0 | 309 | 0   |     Launched Version: 1.12.2-forge-14.23.5.2859     LWJGL: 2.9.4     OpenGL: NVIDIA GeForce RTX 3070/PCIe/SSE2 GL version 4.6.0 NVIDIA 551.86, NVIDIA Corporation     GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported.     Using VBOs: Yes     Is Modded: Definitely; Client brand changed to 'fml,forge'     Type: Client (map_client.txt)     Resource Packs: NickMiner69V2.zip, MPT-4.zip, feldbahnpackv1-3.zip, G_P_Narrow_Gauge_Texel_Pack_V1.0.3.zip     Current Language: English (US)     Profiler Position: N/A (disabled)     CPU: 8x Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz     OptiFine Version: OptiFine_1.12.2_HD_U_G5     OptiFine Build: 20210124-142939     Render Distance Chunks: 12     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 4.6.0 NVIDIA 551.86     OpenGlRenderer: NVIDIA GeForce RTX 3070/PCIe/SSE2     OpenGlVendor: NVIDIA Corporation     CpuCount: 8
    • i notice a change if i add the min and max ram in the line like this for example:    # Xmx and Xms set the maximum and minimum RAM usage, respectively. # They can take any number, followed by an M or a G. # M means Megabyte, G means Gigabyte. # For example, to set the maximum to 3GB: -Xmx3G # To set the minimum to 2.5GB: -Xms2500M # A good default for a modded server is 4GB. # Uncomment the next line to set it. -Xmx10240M -Xms8192M    i need to make more experiments but for now this apparently works.
    • This honestly might just work for you @SubscribeEvent public static void onScreenRender(ScreenEvent.Render.Post event) { final var player = Minecraft.getInstance().player; final var options = Minecraft.getInstance().options; if(!hasMyEffect(player)) return; // TODO: You provide hasMyEffect float f = Mth.lerp(event.getPartialTick(), player.oSpinningEffectIntensity, player.spinningEffectIntensity); float f1 = ((Double)options.screenEffectScale().get()).floatValue(); if(f <= 0F || f1 >= 1F) return; float p_282656_ = f * (1.0F - f1); final var p_282460_ = event.getGuiGraphics(); int i = p_282460_.guiWidth(); int j = p_282460_.guiHeight(); p_282460_.pose().pushPose(); float f5 = Mth.lerp(p_282656_, 2.0F, 1.0F); p_282460_.pose().translate((float)i / 2.0F, (float)j / 2.0F, 0.0F); p_282460_.pose().scale(f5, f5, f5); p_282460_.pose().translate((float)(-i) / 2.0F, (float)(-j) / 2.0F, 0.0F); float f4 = 0.2F * p_282656_; float f2 = 0.4F * p_282656_; float f3 = 0.2F * p_282656_; RenderSystem.disableDepthTest(); RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE); p_282460_.setColor(f4, f2, f3, 1.0F); p_282460_.blit(new ResourceLocation("textures/misc/nausea.png"), 0, 0, -90, 0.0F, 0.0F, i, j, i, j); p_282460_.setColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.defaultBlendFunc(); RenderSystem.disableBlend(); RenderSystem.depthMask(true); RenderSystem.enableDepthTest(); p_282460_.pose().popPose(); }   Note: Most of this is directly copied from GameRenderer as you pointed out you found. The only thing you'll have to likely do is update the `oSpinningEffectIntensity` + `spinningEffectIntensity` variables on the player when your effect is applied. Which values should be there? Not 100% sure, might be a game of guess and check, but `handleNetherPortalClient` in LocalPlayer has some hard coded you might be able to start with.
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
  • Topics

×
×
  • Create New...

Important Information

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