Jump to content

Recommended Posts

Posted

I've been looking through the EntityItemFrame class to try to get a clue as to how MC displays an item that's stored in the frame.

I have a Shelf block that acts as a container for four item stacks and I'd like to display a single item that represents each stack on the shelf at a specific location in the cube.  I can't seem to find which methods are used to actually display the item in Item Frames, and I'm not even sure I can use the same method.

 

Does anyone know how to do this like Item Frames do, or a better way?

 

Here's my shelf title entity:



package com.rosecotton.shelvesmod;
import java.util.Arrays;

import net.minecraft.block.BlockChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
//import net.minecraft.network.INetworkManager;
import net.minecraft.network.Packet;
//import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraft.nbt.NBTTagList;

public class ShelfTitleEntity extends TileEntity implements IInventory {
final int NUMBER_OF_SLOTS = 4;
    public int numPlayersUsing;
private ItemStack[] itemStacks = new ItemStack[NUMBER_OF_SLOTS];


// will add a key for this container to the lang file so we can name it in the GUI
@Override
public String getName() {
	return "Block Shelf";
}

@Override
public boolean hasCustomName() {
return false;
}

// standard code to look up what the human-readable name is
@Override
public IChatComponent getDisplayName() {
return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName());
}

@Override
public int getSizeInventory() {
return itemStacks.length;
}

@Override
public ItemStack getStackInSlot(int slotIndex) {
return itemStacks[slotIndex];
}

@Override
public ItemStack decrStackSize(int slotIndex, int count) {
ItemStack itemStackInSlot = getStackInSlot(slotIndex);
if (itemStackInSlot == null) return null;

ItemStack itemStackRemoved;
if (itemStackInSlot.stackSize <= count) {
	itemStackRemoved = itemStackInSlot;
	setInventorySlotContents(slotIndex, null);
} else {
	itemStackRemoved = itemStackInSlot.splitStack(count);
	if (itemStackInSlot.stackSize == 0) {
		setInventorySlotContents(slotIndex, null);
	}
}
  markDirty();
return itemStackRemoved;
}

// -----------------------------------------------------------------------------------------------------------
// The following method is not needed for this example but are part of IInventory so must be implemented
/**
* This method removes the entire contents of the given slot and returns it.
* Used by containers such as crafting tables which return any items in their slots when you close the GUI
* @param slotIndex
* @return
*/
@Override
public ItemStack getStackInSlotOnClosing(int slotIndex) {
ItemStack itemStack = getStackInSlot(slotIndex);
if (itemStack != null) setInventorySlotContents(slotIndex, null);
return itemStack;
}

// overwrites the stack in the given slotIndex with the given stack
@Override
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
itemStacks[slotIndex] = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
	itemstack.stackSize = getInventoryStackLimit();
}
markDirty();
}

// This is the maximum number if items allowed in each slot
// This only affects things such as hoppers trying to insert items you need to use the container to enforce this for players
// inserting items via the gui
@Override
public int getInventoryStackLimit() {
return 64;
}

// Return true if the given player is able to use this block. In this case it checks that
// 1) the world tileentity hasn't been replaced in the meantime, and
// 2) the player isn't too far away from the centre of the block
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
if (this.worldObj.getTileEntity(this.pos) != this) return false;
final double X_CENTRE_OFFSET = 0.5;
final double Y_CENTRE_OFFSET = 0.5;
final double Z_CENTRE_OFFSET = 0.5;
final double MAXIMUM_DISTANCE_SQ = 8.0 * 8.0;
return player.getDistanceSq(pos.getX() + X_CENTRE_OFFSET, pos.getY() + Y_CENTRE_OFFSET, pos.getZ() + Z_CENTRE_OFFSET) < MAXIMUM_DISTANCE_SQ;
}

//-----------------------------------------------------------------------------------------------------------
//The following method is not needed for this example but are part of IInventory so must be implemented
@Override
public void openInventory(EntityPlayer player) {
    if (!player.isSpectator())
    {
        if (this.numPlayersUsing < 0)
        {
            this.numPlayersUsing = 0;
        }

        ++this.numPlayersUsing;
        this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
        this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
        this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
    	System.out.println("Called method: ShelfTitleEntity.openInventory");
    }
}

//-----------------------------------------------------------------------------------------------------------
//The following method is not needed for this example but are part of IInventory so must be implemented
@Override
public void closeInventory(EntityPlayer player) {
    if (!player.isSpectator() && this.getBlockType() instanceof BlockChest)
    {
        --this.numPlayersUsing;
        this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing);
        this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType());
        this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType());
    }
}

// Return true if the given stack is allowed to go in the given slot.  In this case, we can insert anything.
// This only affects things such as hoppers trying to insert items you need to use the container to enforce this for players
// inserting items via the gui
@Override
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
return true;
}


// This is where you save any data that you don't want to lose when the tile entity unloads
// In this case, it saves the itemstacks stored in the container
@Override
public void writeToNBT(NBTTagCompound parentNBTTagCompound)
{
super.writeToNBT(parentNBTTagCompound); // The super call is required to save and load the tileEntity's location

// to use an analogy with Java, this code generates an array of hashmaps
// The itemStack in each slot is converted to an NBTTagCompound, which is effectively a hashmap of key->value pairs such
//   as slot=1, id=2353, count=1, etc
// Each of these NBTTagCompound are then inserted into NBTTagList, which is similar to an array.
NBTTagList dataForAllSlots = new NBTTagList();
for (int i = 0; i < this.itemStacks.length; ++i) {
	if (this.itemStacks[i] != null)	{
		NBTTagCompound dataForThisSlot = new NBTTagCompound();
		dataForThisSlot.setByte("Slot", (byte) i);
		this.itemStacks[i].writeToNBT(dataForThisSlot);
		dataForAllSlots.appendTag(dataForThisSlot);
	}
}
// the array of hashmaps is then inserted into the parent hashmap for the container
parentNBTTagCompound.setTag("Items", dataForAllSlots);
}

// This is where you load the data that you saved in writeToNBT
@Override
public void readFromNBT(NBTTagCompound parentNBTTagCompound)
{
super.readFromNBT(parentNBTTagCompound); // The super call is required to save and load the tiles location

final byte NBT_TYPE_COMPOUND = 10;       // See NBTBase.createNewByType() for a listing
NBTTagList dataForAllSlots = parentNBTTagCompound.getTagList("Items", NBT_TYPE_COMPOUND);

Arrays.fill(itemStacks, null);           // set all slots to empty
for (int i = 0; i < dataForAllSlots.tagCount(); ++i) {
	NBTTagCompound dataForOneSlot = dataForAllSlots.getCompoundTagAt(i);
	int slotIndex = dataForOneSlot.getByte("Slot") & 255;

	if (slotIndex >= 0 && slotIndex < this.itemStacks.length) {
		this.itemStacks[slotIndex] = ItemStack.loadItemStackFromNBT(dataForOneSlot);
	}
}
}

public boolean receiveClientEvent(int id, int type)
{
    if (id == 1)
    {
        this.numPlayersUsing = type;
        return true;
    }
    else
    {
        return super.receiveClientEvent(id, type);
    }
}

@Override
public int getField(int id) {
return Item.getIdFromItem(itemStacks[id].getItem());
}

@Override
public void setField(int id, int value) {
itemStacks[id].setItem(Item.getItemById(value));
}

@Override
public int getFieldCount() {
return itemStacks.length;
}

// set all slots to empty
@Override
public void clear() {
Arrays.fill(itemStacks, null);
}
}

 

package com.rosecotton.shelvesmod;

//import BlockStairs;

import java.util.Iterator;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.ILockableContainer;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;


public class BlockShelf extends BlockContainer {

    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
    public static final PropertyEnum SECTION = PropertyEnum.create("section", BlockShelf.EnumShape.class);
    
    private final Random rand = new Random();
   // private static final String __OBFID = "CL_00000214";
private final String name = "shelfBlock";
ModelResourceLocation modelresourcelocation = new ModelResourceLocation("shelvesmod"+":"+name, "inventory");
    
    protected BlockShelf(int type)
    {
        super(Material.wood);
        //TEH FOLLOWIONG LINE MIGHT HAVE BEEN USEFUL BUT MAYBE CAUSED AN ERROR AT RUNTIME, TRY AGAIN
        this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
        //this.chestType = type;
        this.setCreativeTab(CreativeTabs.tabMisc);
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
        this.useNeighborBrightness = true;
	this.setDefaultState(this.blockState.getBaseState());
        GameRegistry.registerBlock(this, name);
    	this.setUnlocalizedName(ShelvesMod.MODID + "_" + name);
    	this.setBlockBounds(1/16.0F, 0, 1/16.0F, 15/16.0F, 8/16.0F, 15/16.0F);
    }

    public String toString()
    {
        return this.name;
    }
    public String getName()
    {
        return this.name;
    }

    // used by the renderer to control lighting and visibility of other blocks.
    // set to false because this block doesn't fill the entire 1x1x1 space
    @Override
    public boolean isOpaqueCube() {
      return false;
    }

    // used by the renderer to control lighting and visibility of other blocks, also by
    // (eg) wall or fence to control whether the fence joins itself to this block
    // set to false because this block doesn't fill the entire 1x1x1 space
    @Override
    public boolean isFullCube() {
      return false;
    }
    
    // this function returns the correct item type corresponding to the colour of our block;
    // i.e. when a sign is broken, it will drop the correct item.
    @Override
    public int damageDropped(IBlockState state)
    {
      //EnumColour enumColour = (EnumColour)state.getValue(PROPERTYCOLOUR);
      //return this.getMetadata();//enumColour.getMetadata();
    	return 0;
    }
    

    
    
    public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
    {
        if (worldIn.getBlockState(pos.north()).getBlock() == this)
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
        }
        else if (worldIn.getBlockState(pos.south()).getBlock() == this)
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
        }
        else if (worldIn.getBlockState(pos.west()).getBlock() == this)
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
        }
        else if (worldIn.getBlockState(pos.east()).getBlock() == this)
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
        }
        else
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
        }
    }

    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        //this.checkForSurroundingChests(worldIn, pos, state);
        Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();

        while (iterator.hasNext())
        {
            EnumFacing enumfacing = (EnumFacing)iterator.next();
            BlockPos blockpos1 = pos.offset(enumfacing);
            IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);

        }
    }
@Override
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase player)
    {
        return this.getDefaultState().withProperty(FACING, player.getHorizontalFacing());
    }

    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
        EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
        state = state.withProperty(FACING, enumfacing);
        BlockPos blockpos1 = pos.north();
        BlockPos blockpos2 = pos.south();
        BlockPos blockpos3 = pos.west();
        BlockPos blockpos4 = pos.east();
        boolean flag = this == worldIn.getBlockState(blockpos1).getBlock();
        boolean flag1 = this == worldIn.getBlockState(blockpos2).getBlock();
        boolean flag2 = this == worldIn.getBlockState(blockpos3).getBlock();
        boolean flag3 = this == worldIn.getBlockState(blockpos4).getBlock();

        if (!flag && !flag1 && !flag2 && !flag3)
        {
            worldIn.setBlockState(pos, state, 3);
        }
        else if (enumfacing.getAxis() == EnumFacing.Axis.X && (flag || flag1))
        {
            if (flag)
            {
                worldIn.setBlockState(blockpos1, state, 3);
            }
            else
            {
                worldIn.setBlockState(blockpos2, state, 3);
            }

            worldIn.setBlockState(pos, state, 3);
        }
        else if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3))
        {
            if (flag2)
            {
                worldIn.setBlockState(blockpos3, state, 3);
            }
            else
            {
                worldIn.setBlockState(blockpos4, state, 3);
            }

            worldIn.setBlockState(pos, state, 3);
        }

        if (stack.hasDisplayName())
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityChest)
            {
                ((TileEntityChest)tileentity).setCustomName(stack.getDisplayName());
            }
        }
    }
    
    public IBlockState correctFacing(World worldIn, BlockPos pos, IBlockState state)
    {
        EnumFacing enumfacing = null;
        Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();

        while (iterator.hasNext())
        {
            EnumFacing enumfacing1 = (EnumFacing)iterator.next();
            IBlockState iblockstate1 = worldIn.getBlockState(pos.offset(enumfacing1));

            if (iblockstate1.getBlock() == this)
            {
                return state;
            }

            if (iblockstate1.getBlock().isFullBlock())
            {
                if (enumfacing != null)
                {
                    enumfacing = null;
                    break;
                }

                enumfacing = enumfacing1;
            }
        }

        if (enumfacing != null)
        {
            return state.withProperty(FACING, enumfacing.getOpposite());
        }
        else
        {
            EnumFacing enumfacing2 = (EnumFacing)state.getValue(FACING);

            if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
            {
                enumfacing2 = enumfacing2.getOpposite();
            }

            if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
            {
                enumfacing2 = enumfacing2.rotateY();
            }

            if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
            {
                enumfacing2 = enumfacing2.getOpposite();
            }

            return state.withProperty(FACING, enumfacing2);
        }
    }





    public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof IInventory)
        {
            InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
            worldIn.updateComparatorOutputLevel(pos, this);
        }

        super.breakBlock(worldIn, pos, state);
    }
    
   /* 
// This is where you can do something when the block is broken. In this case drop the inventory's contents
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {

	IInventory inventory = worldIn.getTileEntity(pos) instanceof IInventory ? (IInventory)worldIn.getTileEntity(pos) : null;

	if (inventory != null){
		// For each slot in the inventory
		for (int i = 0; i < inventory.getSizeInventory(); i++){
			// If the slot is not empty
			if (inventory.getStackInSlot(i) != null)
			{
				// Create a new entity item with the item stack in the slot
				EntityItem item = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, inventory.getStackInSlot(i));

				// Apply some random motion to the item
				float multiplier = 0.1f;
				float motionX = worldIn.rand.nextFloat() - 0.5f;
				float motionY = worldIn.rand.nextFloat() - 0.5f;
				float motionZ = worldIn.rand.nextFloat() - 0.5f;

				item.motionX = motionX * multiplier;
				item.motionY = motionY * multiplier;
				item.motionZ = motionZ * multiplier;

				// Spawn the item in the world
				worldIn.spawnEntityInWorld(item);
			}
		}

		// Clear the inventory so nothing else (such as another mod) can do anything with the items
		inventory.clear();
	}

	// Super MUST be called last because it removes the tile entity
	super.breakBlock(worldIn, pos, state);
}*/



// Called when the block is right clicked
// In this block it is used to open the blocks gui when right clicked by a player
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
	// Uses the gui handler registered to your mod to open the gui for the given gui id
	// open on the server side only  (not sure why you shouldn't open client side too... vanilla doesn't, so we better not either)
	if (worldIn.isRemote) return true;


	playerIn.openGui(ShelvesMod.instance, GuiHandlerShelf.getGuiID(), worldIn, pos.getX(), pos.getY(), pos.getZ());
   	System.out.println("Called method: BlockShelf.onBlockActivated");
	return true;
}
@Override
   public TileEntity createNewTileEntity(World worldIn, int meta)
    {
        return new ShelfTitleEntity();
    }



    private boolean isBlocked(World worldIn, BlockPos pos)
    {
        return this.isBelowSolidBlock(worldIn, pos) || this.isOcelotSittingOnChest(worldIn, pos);
    }

    private boolean isBelowSolidBlock(World worldIn, BlockPos pos)
    {
        return worldIn.getBlockState(pos.up()).getBlock().isNormalCube();
    }




    private boolean isOcelotSittingOnChest(World worldIn, BlockPos pos)
    {
        Iterator iterator = worldIn.getEntitiesWithinAABB(EntityOcelot.class, new AxisAlignedBB((double)pos.getX(), (double)(pos.getY() + 1), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 2), (double)(pos.getZ() + 1))).iterator();
        EntityOcelot entityocelot;

        do
        {
            if (!iterator.hasNext())
            {
                return false;
            }

            Entity entity = (Entity)iterator.next();
            entityocelot = (EntityOcelot)entity;
        }
        while (!entityocelot.isSitting());

        return true;
    }

    public boolean hasComparatorInputOverride()
    {
        return true;
    }

    @Override
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return this.getDefaultState().withProperty(FACING, enumfacing);
    }

    @Override
    public int getMetaFromState(IBlockState state)
    {
      EnumFacing facing = (EnumFacing)state.getValue(FACING);

      int facingbits = facing.getHorizontalIndex();
      return facingbits;// | colourbits;
    }

    // necessary to define which properties your blocks use
    // will also affect the variants listed in the blockstates model file
    @Override
    protected BlockState createBlockState()
    {
        return new BlockState(this, new IProperty[] {FACING,SECTION});
    }

    
    @Override
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return Item.getItemFromBlock(this);
    }
    public static enum EnumShape implements IStringSerializable
    {
        TOP("top"),
        MIDDLE("middle"),
        BOTTOM("bottom");

        private final String name;

        private static final String __OBFID = "CL_00003061";

        private EnumShape(String name)
        {
            this.name = name;
        }

        public String toString()
        {
            return this.name;
        }

        public String getName()
        {
            return this.name;
        }

    }
    public TileEntity createTileEntity(World world, int metadata)
    {
       return new ShelfTitleEntity();
    }
    
    @Override
    public int getRenderType()
    {
        return 3;
    }
    
}

 

package com.rosecotton.shelvesmod;



import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

/**
* User: brandon3055
* Date: 06/01/2015
*
* The container is used to link the client side gui to the server side inventory and it is where
* you add the slots to your gui. It can also be used to sync server side data with the client but
* that will be covered in a later tutorial
*/
public class ContainerShelf extends Container {

// Stores a reference to the tile entity instance for later use
private ShelfTitleEntity ShelfTitleEntity;

// must assign a slot number to each of the slots used by the GUI.
// For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar.
// Each time we add a Slot to the container, it automatically increases the slotIndex, which means
//  0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 
//  9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35)
//  36 - 39 = TileInventory slots, which map to our TileEntity slot numbers 0 - 3)

private final int HOTBAR_SLOT_COUNT = 9;
private final int PLAYER_INVENTORY_ROW_COUNT = 3;
private final int PLAYER_INVENTORY_COLUMN_COUNT = 9;
private final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT;
private final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT;

private final int VANILLA_FIRST_SLOT_INDEX = 0;
private final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT;
private final int TE_INVENTORY_SLOT_COUNT = 4;

public ContainerShelf(InventoryPlayer invPlayer, ShelfTitleEntity ShelfTitleEntity) {
	this.ShelfTitleEntity = ShelfTitleEntity;

	final int SLOT_X_SPACING = 18;
    final int SLOT_Y_SPACING = 18;
	final int HOTBAR_XPOS = 8;
	final int HOTBAR_YPOS = 109;
	// Add the players hotbar to the gui - the [xpos, ypos] location of each item
	for (int x = 0; x < HOTBAR_SLOT_COUNT; x++) {
		int slotNumber = x;
		addSlotToContainer(new Slot(invPlayer, slotNumber, HOTBAR_XPOS + SLOT_X_SPACING * x, HOTBAR_YPOS));
	}

	final int PLAYER_INVENTORY_XPOS = 8;
	final int PLAYER_INVENTORY_YPOS = 51;
	// Add the rest of the players inventory to the gui
	for (int y = 0; y < PLAYER_INVENTORY_ROW_COUNT; y++) {
		for (int x = 0; x < PLAYER_INVENTORY_COLUMN_COUNT; x++) {
			int slotNumber = HOTBAR_SLOT_COUNT + y * PLAYER_INVENTORY_COLUMN_COUNT + x;
			int xpos = PLAYER_INVENTORY_XPOS + x * SLOT_X_SPACING;
			int ypos = PLAYER_INVENTORY_YPOS + y * SLOT_Y_SPACING;
			addSlotToContainer(new Slot(invPlayer, slotNumber,  xpos, ypos));
		}
	}

	if (TE_INVENTORY_SLOT_COUNT != ShelfTitleEntity.getSizeInventory()) {
		System.err.println("Mismatched slot count in ContainerShelf(" + TE_INVENTORY_SLOT_COUNT
											  + ") and TileInventory (" + ShelfTitleEntity.getSizeInventory()+")");
	}
	final int TILE_INVENTORY_XPOS = 8;
	final int TILE_INVENTORY_YPOS = 20;
	// Add the tile inventory container to the gui
	for (int x = 0; x < TE_INVENTORY_SLOT_COUNT; x++) {
		int slotNumber = x;
		addSlotToContainer(new Slot(ShelfTitleEntity, slotNumber, TILE_INVENTORY_XPOS + SLOT_X_SPACING * x, TILE_INVENTORY_YPOS));
	}
}

// Vanilla calls this method every tick to make sure the player is still able to access the inventory, and if not closes the gui
@Override
public boolean canInteractWith(EntityPlayer player)
{
	return ShelfTitleEntity.isUseableByPlayer(player);
}

// This is where you specify what happens when a player shift clicks a slot in the gui
//  (when you shift click a slot in the TileEntity Inventory, it moves it to the first available position in the hotbar and/or
//    player inventory.  When you you shift-click a hotbar or player inventory item, it moves it to the first available
//    position in the TileEntity inventory)
// At the very least you must override this and return null or the game will crash when the player shift clicks a slot
// returns null if the source slot is empty, or if none of the the source slot items could be moved
//   otherwise, returns a copy of the source stack
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int sourceSlotIndex)
{
	Slot sourceSlot = (Slot)inventorySlots.get(sourceSlotIndex);
	if (sourceSlot == null || !sourceSlot.getHasStack()) return null;
	ItemStack sourceStack = sourceSlot.getStack();
	ItemStack copyOfSourceStack = sourceStack.copy();

	// Check if the slot clicked is one of the vanilla container slots
	if (sourceSlotIndex >= VANILLA_FIRST_SLOT_INDEX && sourceSlotIndex < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
		// This is a vanilla container slot so merge the stack into the tile inventory
		if (!mergeItemStack(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)){
			return null;
		}
	} else if (sourceSlotIndex >= TE_INVENTORY_FIRST_SLOT_INDEX && sourceSlotIndex < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
		// This is a TE slot so merge the stack into the players inventory
		if (!mergeItemStack(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
			return null;
		}
	} else {
		System.err.print("Invalid slotIndex:" + sourceSlotIndex);
		return null;
	}

	// If stack size == 0 (the entire stack was moved) set slot contents to null
	if (sourceStack.stackSize == 0) {
		sourceSlot.putStack(null);
	} else {
		sourceSlot.onSlotChanged();
	}

	sourceSlot.onPickupFromSlot(player, sourceStack);
	return copyOfSourceStack;
}

// pass the close container message to the tileEntityInventory (not strictly needed for this example)
//  see ContainerChest and TileEntityChest
@Override
public void onContainerClosed(EntityPlayer playerIn)
{
	super.onContainerClosed(playerIn);
	this.ShelfTitleEntity.closeInventory(playerIn);
}
}

 

package com.rosecotton.shelvesmod;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
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.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.LanguageRegistry;
import net.minecraftforge.fml.relauncher.Side;

import com.rosecotton.shelvesmod.BlockShelf;
//import com.becky.testmod01.Testmod01;

@Mod(modid = ShelvesMod.MODID, name = ShelvesMod.MODNAME, version = ShelvesMod.VERSION) 

public class ShelvesMod 
{

  public static Block shelfBlock;
  //public static Item brickIngot;
  public static final String MODID = "shelvesmod";
  public static final String MODNAME = "RoseCotton's Shelves Mod for 1.8";
  public static final String VERSION = "1.0";
  public static int type;

  @Instance(value = "shelvesmod")
  public static ShelvesMod instance = new ShelvesMod();
  
  public static class MySidedProxyHolder {
	  @SidedProxy(modId="shelvesmod",clientSide="com.rosecotton.shelvesmod.ClientProxy", serverSide="com.rosecotton.shelvesmod.CommonProxy")
	  public static CommonProxy proxy;
	  }
	  
	  public class CommonProxy {
		  // Common or server stuff here that needs to be overridden on the client
	  }
	  public class ClientProxy extends CommonProxy {
		  // Override common stuff with client specific stuff here
	  }

  @EventHandler
  public void preInit(FMLPreInitializationEvent event) 
  {

  	//blocks
  	shelfBlock = new BlockShelf(type);
  	LanguageRegistry.addName(shelfBlock, "Shelf Block");
  	
  	GameRegistry.registerTileEntity(ShelfTitleEntity.class, "shelfTitleEntity");
  	//was com.rosecotton.shelvesmod.ShelfTitleEntity.class
  	
  	
  	//items
  	//brickIngot = new ItemBrickIngot();
	  //MOVE GAMEREGISTRY TO ITEM CLASS?
  	//GameRegistry.registerItem(brickIngot, ((ItemBrickIngot) brickIngot).getName());
  	//LanguageRegistry.addName(brickIngot, "Brick Ingot");
	NetworkRegistry.INSTANCE.registerGuiHandler(ShelvesMod.instance, GuiHandlerRegistry.getInstance());
	GuiHandlerRegistry.getInstance().registerGuiHandler(new GuiHandlerShelf(), GuiHandlerShelf.getGuiID());
  }

  @EventHandler
  public void init(FMLInitializationEvent event) 
  {
  	//System.out.println("Called method: init");
  
  	if(event.getSide() == Side.CLIENT)
  	{
  		
  		RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();

  		renderItem.getItemModelMesher().register(Item.getItemFromBlock(shelfBlock), 0, new ModelResourceLocation(ShelvesMod.MODID + ":" + ((BlockShelf) shelfBlock).getName(), "shelfBlock"));
  		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(shelfBlock),0, new ModelResourceLocation(ShelvesMod.MODID+":"+ "shelfBlock", "inventory"));
  	}
  	
  	//recipes
  	GameRegistry.addRecipe(new ItemStack(shelfBlock), new Object[]{
  	"   ",
  	"  A",
  	" AA",
  	'A', Items.stick //getItemFromBlock(Blocks.planks)
  	});
  }
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) 
    {
    	System.out.println("Called method: postInit");
    }
}

 

And there are a couple GUI java files to go with that, as well as my shelf block model files.

hw developer in a sw world

Posted

Ah!  no, I hadn't found that one.  I had only found EntityItemFrame, but this RenderItemFrame class is what I was looking for.  I'll go study it and find out if I can use some of it for what I want.  Thanks!  :)

hw developer in a sw world

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

    • Verified user can get a $100 off Temu   Coupon code using the code ((“aci789589”)). This Temu   $100 Off code is specifically for new and existing customers both and can be redeemed to receive a $100 discount on your purchase. Our exclusive Temu   Coupon code offers a flat $100 off your purchase, plus an additional 100% discount on top of that. You can slash prices by up to $100 as a new Temu   customer using code ((“aci789589”)). Existing users can enjoy $100 off their next haul with this code. But that’s not all! With our Temu   Coupon codes for 2025, you can get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our Temu   codes provide extra discounts tailored just for you. Save up to 100% with these current Temu   Coupons ["^"aci789589 "^"] for April 2025. The latest Temu   coupon codes at here. New users at Temu   receive a $100 discount on orders over $100 Use the code ((“aci789589”)) during checkout to get Temu   Coupon $100 Off For New Users. You can save $100 Off your first order with the coupon code available for a limited time only. Temu   90% Off promo code ((“aci789589”)) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu   offers $100 Off coupon code “aci789589” for first time users. You can get a $100 bonus plus $100 Off any purchase at Temu   with the $100 Coupon Bundle at Temu   if you sign up with the referral code ((“aci789589”)) and make a first purchase of $100 or more. Free Temu   codes $100 off — ((“aci789589”)) Temu   Coupon $100 off — ((“aci789589”)) Temu   Coupon 100% off — ((“aci789589”)) Temu   Memorial Day Sale $100 off — ((“aci789589”)) Temu   Coupon code today — ((“aci789589”)) Temu   free gift code — ["^"aci789589"^"](Without inviting friends or family member) Temu   Coupon code for  USA      - $100 Off— ((“aci789589”)) Temu   Coupon code  USA     - $100 Off— ((“aci789589”)) Temu   Coupon code USA  - $100 Off — ((“aci789589”)) Temu   Coupon code Japan - $100 Off — ((“aci789589”)) Temu   Coupon code Mexico - $100 Off — ((“aci789589”)) Temu   Coupon code Chile - $100 Off — ((“aci789589”)) Temu   Coupon code USA - $100 Off — ((“aci789589”)) Temu   Coupon code Colombia - $100 Off — ((“aci789589”)) Temu   Coupon code Malaysia - $100 Off — ((“aci789589”)) Temu   Coupon code Philippines - $100 Off — ((“aci789589”)) Temu   Coupon code South Korea - $100 Off — ((“aci789589”)) Redeem Free Temu   Coupon Code ["^"aci789589"^"] for first-time users Get a $100 discount on your Temu   order with the promo code "aci789589". You can get a discount by clicking on the item to purchase and entering this Temu   Coupon code $100 off ((“aci789589”)). Temu   New User Coupon ((“aci789589)): Up To $100 OFF For First-Time Users Our Temu   first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on Temu  . To maximize your savings, download the Temu   app and apply our Temu   new user coupon during checkout. Temu   Coupon Codes For Existing Users ((“aci789589”)): $100 Price Slash Have you been shopping on Temu   for a while? Our Temu   Coupon for existing customers is here to reward you for your continued support, offering incredible discounts on your favorite products. Temu   Coupon For $100 Off ((“aci789589”)): Get A Flat $100 Discount On Order Value Get ready to save big with our incredible Temu   Coupon for $100 off! Our amazing Temu   $100 off coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. Temu   Coupon Code For $100 Off ((“aci789589”)): For Both New And Existing Customers Our incredible Temu   Coupon code for $100 off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100 off code for Temu   will give you an additional discount! Temu   Coupon Bundle ((“aci789589”)): Flat $100 Off + Up To $100 Discount Get ready for an unbelievable deal with our Temu   Coupon bundle for 2025! Our Temu   Coupon bundles will give you a flat $100 discount and an additional $100 off on top of it. Free Temu   Coupons ((“aci789589”)): Unlock Unlimited Savings! Get ready to unlock a world of savings with our free Temu   Coupons! We’ve got you covered with a wide range of Temu   Coupon code options that will help you maximize your shopping experience. 100% Off Temu   Coupons, Promo Codes + 25% Cash Back ((“aci789589”)) Redeem Temu   Coupon Code ((“aci789589”)) Temu   Coupon $100 OFF ((“aci789589”)) Temu   Coupon $100 OFF FOR EXISTING CUSTOMERS ((“aci789589”)) Temu   Coupon $100 OFF FIRST ORDER ((“aci789589”)) Temu   Coupon $100 OFF REDDIT ((“aci789589”)) Temu   Coupon $100 OFF FOR EXISTING CUSTOMERS REDDIT ((“aci789589”)) Temu   $100 OFF CODE ((“aci789589”)) Temu   70 OFF COUPON 2025 ((“aci789589”)) DOMINOS 70 RS OFF COUPON CODE ((“aci789589”)) WHAT IS A COUPON RATE ((“aci789589”)) Temu   $100 OFF FOR EXISTING CUSTOMERS ((“aci789589”)) Temu   $100 OFF FIRST ORDER ((“aci789589”)) Temu   $100 OFF FREE SHIPPING ((“aci789589”)) You can get an exclusive $100 off discount on your Temu   purchase with the code [aci789589] Or [aci789589].This code is specially designed for new customers and offers a significant price cut on your shopping. Make your first purchase on Temu   more rewarding by using this code to get $100 off instantly. Temu   Coupon Code For $100 Off [aci789589] Or [aci789589]: Get A Flat $100 Discount On Order Value Get ready to save big with our incredible Temu   coupon for $100 off! Our coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. Exclusive Temu   Discount Code [aci789589] Or [aci789589]: Flat $200 OFF for New and Existing Customers Using our Temu   promo code you can get A$ 200 off your order and 100% off using our Temu   promo code [aci789589] Or [aci789589]. As a new Temu   customer, you can save up to $100 using this promo code. For returning users, our Temu   promo code offers a $100 price slash on your next shopping spree. This is our way of saying thank you for shopping with us! Best Temu   Deals and Coupons [aci789589] Or [aci789589]: During 2025, Temu   coupon codes offer discounts of up to 90% on select items, making it possible for both new and existing users to get incredible deals. From $100 off deals to 100% discounts, our Temu   promo codes make shopping more affordable than ever. Temu   Coupon Code For $100% Off [aci789589] Or [aci789589]: For Both New And Existing Customers Free Temu   $100 Off Code — [aci789589] Or [aci789589] Temu   Coupon 100% Off — [aci789589] Or [aci789589] Temu   Memorial Day Sale - $100 Off — [aci789589] Or [aci789589] Temu   Free Gift Code — [aci789589] Or [aci789589] Temu   $500 Off Code — [aci789589 ] Or [aci789589] Best Temu   $200 Off Code — [aci789589 ] Or [aci789589] Temu   Coupon Code first order — [aci789589] Or [aci789589] Temu   Coupon Code for New user — [aci789589] Or [aci789589] Temu   Coupon Code A$100 off — [aci789589] Or [aci789589] Temu   Coupon Code $50 off — [aci789589] Or [aci789589] Temu   Coupon Code $100 off — [aci789589] Or [aci789589] Temu   Promo Code 2025 — [aci789589] Or [aci789589] Temu   Coupon Code $200 off — [aci789589] Or [aci789589] Temu   Coupon Code $90 off — [aci789589] Or [aci789589] Temu   Sign up Bonus Code — [aci789589] Or [aci789589] Temu   Coupon Code A$120 off — [aci789589] Or [aci789589] Our exclusive Temu   coupon code allows you to take a flat $200 off your purchase with an added 100% discount on top. As a new Temu   shopper, you can save up to $100 using code [aci789589] Or [aci789589]. Returning customers can also enjoy a $100 discount on their next purchases with this code. Temu   Coupon Code for Your Country Sign-up Bonus Temu   $100 Off Code  USA      [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA     [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code USA  [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Japan [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Mexico [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Chile [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code USA [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Colombia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Malaysia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Philippines [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code South Korea [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA      [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Pakistan [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Finland [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Saudi Arabia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Qatar [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code France [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Germany [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA   [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Israel [aci789589] Or [aci789589] - 100% off Get a $100 discount on your Temu   order with the promo code [aci789589] Or [aci789589]. You can get a discount by clicking on the item to purchase and entering this Temu   coupon code $100 off [aci789589] Or [aci789589]. Temu   Coupon Code [aci789589] Or [aci789589]: Get Up To 90% OFF In NOV 2025 Are you looking for the best Temu   coupon codes to get amazing discounts? Our Temu   coupons are perfect for getting those extra savings you crave. We regularly test our coupon codes for Temu   to ensure they work flawlessly, giving you a guaranteed discount every time. Temu   New User Coupon [aci789589] Or [aci789589]: Up To $100 OFF For First-Time Users Our Temu   first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on Temu  . To maximize your savings, download the Temu   app and apply our Temu   new user coupon during checkout.
    • Verified user can get a $100 off Temu   Coupon code using the code ((“aci789589”)). This Temu   $100 Off code is specifically for new and existing customers both and can be redeemed to receive a $100 discount on your purchase. Our exclusive Temu   Coupon code offers a flat $100 off your purchase, plus an additional 100% discount on top of that. You can slash prices by up to $100 as a new Temu   customer using code ((“aci789589”)). Existing users can enjoy $100 off their next haul with this code. But that’s not all! With our Temu   Coupon codes for 2025, you can get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our Temu   codes provide extra discounts tailored just for you. Save up to 100% with these current Temu   Coupons ["^"aci789589 "^"] for April 2025. The latest Temu   coupon codes at here. New users at Temu   receive a $100 discount on orders over $100 Use the code ((“aci789589”)) during checkout to get Temu   Coupon $100 Off For New Users. You can save $100 Off your first order with the coupon code available for a limited time only. Temu   90% Off promo code ((“aci789589”)) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu   offers $100 Off coupon code “aci789589” for first time users. You can get a $100 bonus plus $100 Off any purchase at Temu   with the $100 Coupon Bundle at Temu   if you sign up with the referral code ((“aci789589”)) and make a first purchase of $100 or more. Free Temu   codes $100 off — ((“aci789589”)) Temu   Coupon $100 off — ((“aci789589”)) Temu   Coupon 100% off — ((“aci789589”)) Temu   Memorial Day Sale $100 off — ((“aci789589”)) Temu   Coupon code today — ((“aci789589”)) Temu   free gift code — ["^"aci789589"^"](Without inviting friends or family member) Temu   Coupon code for  USA      - $100 Off— ((“aci789589”)) Temu   Coupon code  USA     - $100 Off— ((“aci789589”)) Temu   Coupon code USA  - $100 Off — ((“aci789589”)) Temu   Coupon code Japan - $100 Off — ((“aci789589”)) Temu   Coupon code Mexico - $100 Off — ((“aci789589”)) Temu   Coupon code Chile - $100 Off — ((“aci789589”)) Temu   Coupon code USA - $100 Off — ((“aci789589”)) Temu   Coupon code Colombia - $100 Off — ((“aci789589”)) Temu   Coupon code Malaysia - $100 Off — ((“aci789589”)) Temu   Coupon code Philippines - $100 Off — ((“aci789589”)) Temu   Coupon code South Korea - $100 Off — ((“aci789589”)) Redeem Free Temu   Coupon Code ["^"aci789589"^"] for first-time users Get a $100 discount on your Temu   order with the promo code "aci789589". You can get a discount by clicking on the item to purchase and entering this Temu   Coupon code $100 off ((“aci789589”)). Temu   New User Coupon ((“aci789589)): Up To $100 OFF For First-Time Users Our Temu   first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on Temu  . To maximize your savings, download the Temu   app and apply our Temu   new user coupon during checkout. Temu   Coupon Codes For Existing Users ((“aci789589”)): $100 Price Slash Have you been shopping on Temu   for a while? Our Temu   Coupon for existing customers is here to reward you for your continued support, offering incredible discounts on your favorite products. Temu   Coupon For $100 Off ((“aci789589”)): Get A Flat $100 Discount On Order Value Get ready to save big with our incredible Temu   Coupon for $100 off! Our amazing Temu   $100 off coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. Temu   Coupon Code For $100 Off ((“aci789589”)): For Both New And Existing Customers Our incredible Temu   Coupon code for $100 off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100 off code for Temu   will give you an additional discount! Temu   Coupon Bundle ((“aci789589”)): Flat $100 Off + Up To $100 Discount Get ready for an unbelievable deal with our Temu   Coupon bundle for 2025! Our Temu   Coupon bundles will give you a flat $100 discount and an additional $100 off on top of it. Free Temu   Coupons ((“aci789589”)): Unlock Unlimited Savings! Get ready to unlock a world of savings with our free Temu   Coupons! We’ve got you covered with a wide range of Temu   Coupon code options that will help you maximize your shopping experience. 100% Off Temu   Coupons, Promo Codes + 25% Cash Back ((“aci789589”)) Redeem Temu   Coupon Code ((“aci789589”)) Temu   Coupon $100 OFF ((“aci789589”)) Temu   Coupon $100 OFF FOR EXISTING CUSTOMERS ((“aci789589”)) Temu   Coupon $100 OFF FIRST ORDER ((“aci789589”)) Temu   Coupon $100 OFF REDDIT ((“aci789589”)) Temu   Coupon $100 OFF FOR EXISTING CUSTOMERS REDDIT ((“aci789589”)) Temu   $100 OFF CODE ((“aci789589”)) Temu   70 OFF COUPON 2025 ((“aci789589”)) DOMINOS 70 RS OFF COUPON CODE ((“aci789589”)) WHAT IS A COUPON RATE ((“aci789589”)) Temu   $100 OFF FOR EXISTING CUSTOMERS ((“aci789589”)) Temu   $100 OFF FIRST ORDER ((“aci789589”)) Temu   $100 OFF FREE SHIPPING ((“aci789589”)) You can get an exclusive $100 off discount on your Temu   purchase with the code [aci789589] Or [aci789589].This code is specially designed for new customers and offers a significant price cut on your shopping. Make your first purchase on Temu   more rewarding by using this code to get $100 off instantly. Temu   Coupon Code For $100 Off [aci789589] Or [aci789589]: Get A Flat $100 Discount On Order Value Get ready to save big with our incredible Temu   coupon for $100 off! Our coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. Exclusive Temu   Discount Code [aci789589] Or [aci789589]: Flat $200 OFF for New and Existing Customers Using our Temu   promo code you can get A$ 200 off your order and 100% off using our Temu   promo code [aci789589] Or [aci789589]. As a new Temu   customer, you can save up to $100 using this promo code. For returning users, our Temu   promo code offers a $100 price slash on your next shopping spree. This is our way of saying thank you for shopping with us! Best Temu   Deals and Coupons [aci789589] Or [aci789589]: During 2025, Temu   coupon codes offer discounts of up to 90% on select items, making it possible for both new and existing users to get incredible deals. From $100 off deals to 100% discounts, our Temu   promo codes make shopping more affordable than ever. Temu   Coupon Code For $100% Off [aci789589] Or [aci789589]: For Both New And Existing Customers Free Temu   $100 Off Code — [aci789589] Or [aci789589] Temu   Coupon 100% Off — [aci789589] Or [aci789589] Temu   Memorial Day Sale - $100 Off — [aci789589] Or [aci789589] Temu   Free Gift Code — [aci789589] Or [aci789589] Temu   $500 Off Code — [aci789589 ] Or [aci789589] Best Temu   $200 Off Code — [aci789589 ] Or [aci789589] Temu   Coupon Code first order — [aci789589] Or [aci789589] Temu   Coupon Code for New user — [aci789589] Or [aci789589] Temu   Coupon Code A$100 off — [aci789589] Or [aci789589] Temu   Coupon Code $50 off — [aci789589] Or [aci789589] Temu   Coupon Code $100 off — [aci789589] Or [aci789589] Temu   Promo Code 2025 — [aci789589] Or [aci789589] Temu   Coupon Code $200 off — [aci789589] Or [aci789589] Temu   Coupon Code $90 off — [aci789589] Or [aci789589] Temu   Sign up Bonus Code — [aci789589] Or [aci789589] Temu   Coupon Code A$120 off — [aci789589] Or [aci789589] Our exclusive Temu   coupon code allows you to take a flat $200 off your purchase with an added 100% discount on top. As a new Temu   shopper, you can save up to $100 using code [aci789589] Or [aci789589]. Returning customers can also enjoy a $100 discount on their next purchases with this code. Temu   Coupon Code for Your Country Sign-up Bonus Temu   $100 Off Code  USA      [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA     [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code USA  [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Japan [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Mexico [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Chile [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code USA [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Colombia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Malaysia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Philippines [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code South Korea [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA      [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Pakistan [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Finland [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Saudi Arabia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Qatar [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code France [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Germany [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA   [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Israel [aci789589] Or [aci789589] - 100% off Get a $100 discount on your Temu   order with the promo code [aci789589] Or [aci789589]. You can get a discount by clicking on the item to purchase and entering this Temu   coupon code $100 off [aci789589] Or [aci789589]. Temu   Coupon Code [aci789589] Or [aci789589]: Get Up To 90% OFF In NOV 2025 Are you looking for the best Temu   coupon codes to get amazing discounts? Our Temu   coupons are perfect for getting those extra savings you crave. We regularly test our coupon codes for Temu   to ensure they work flawlessly, giving you a guaranteed discount every time. Temu   New User Coupon [aci789589] Or [aci789589]: Up To $100 OFF For First-Time Users Our Temu   first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on Temu  . To maximize your savings, download the Temu   app and apply our Temu   new user coupon during checkout.
    • Verified user can get a $100 off Temu   Coupon code using the code ((“aci789589”)). This Temu   $100 Off code is specifically for new and existing customers both and can be redeemed to receive a $100 discount on your purchase. Our exclusive Temu   Coupon code offers a flat $100 off your purchase, plus an additional 100% discount on top of that. You can slash prices by up to $100 as a new Temu   customer using code ((“aci789589”)). Existing users can enjoy $100 off their next haul with this code. But that’s not all! With our Temu   Coupon codes for 2025, you can get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our Temu   codes provide extra discounts tailored just for you. Save up to 100% with these current Temu   Coupons ["^"aci789589 "^"] for April 2025. The latest Temu   coupon codes at here. New users at Temu   receive a $100 discount on orders over $100 Use the code ((“aci789589”)) during checkout to get Temu   Coupon $100 Off For New Users. You can save $100 Off your first order with the coupon code available for a limited time only. Temu   90% Off promo code ((“aci789589”)) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu   offers $100 Off coupon code “aci789589” for first time users. You can get a $100 bonus plus $100 Off any purchase at Temu   with the $100 Coupon Bundle at Temu   if you sign up with the referral code ((“aci789589”)) and make a first purchase of $100 or more. Free Temu   codes $100 off — ((“aci789589”)) Temu   Coupon $100 off — ((“aci789589”)) Temu   Coupon 100% off — ((“aci789589”)) Temu   Memorial Day Sale $100 off — ((“aci789589”)) Temu   Coupon code today — ((“aci789589”)) Temu   free gift code — ["^"aci789589"^"](Without inviting friends or family member) Temu   Coupon code for  USA      - $100 Off— ((“aci789589”)) Temu   Coupon code  USA     - $100 Off— ((“aci789589”)) Temu   Coupon code USA  - $100 Off — ((“aci789589”)) Temu   Coupon code Japan - $100 Off — ((“aci789589”)) Temu   Coupon code Mexico - $100 Off — ((“aci789589”)) Temu   Coupon code Chile - $100 Off — ((“aci789589”)) Temu   Coupon code USA - $100 Off — ((“aci789589”)) Temu   Coupon code Colombia - $100 Off — ((“aci789589”)) Temu   Coupon code Malaysia - $100 Off — ((“aci789589”)) Temu   Coupon code Philippines - $100 Off — ((“aci789589”)) Temu   Coupon code South Korea - $100 Off — ((“aci789589”)) Redeem Free Temu   Coupon Code ["^"aci789589"^"] for first-time users Get a $100 discount on your Temu   order with the promo code "aci789589". You can get a discount by clicking on the item to purchase and entering this Temu   Coupon code $100 off ((“aci789589”)). Temu   New User Coupon ((“aci789589)): Up To $100 OFF For First-Time Users Our Temu   first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on Temu  . To maximize your savings, download the Temu   app and apply our Temu   new user coupon during checkout. Temu   Coupon Codes For Existing Users ((“aci789589”)): $100 Price Slash Have you been shopping on Temu   for a while? Our Temu   Coupon for existing customers is here to reward you for your continued support, offering incredible discounts on your favorite products. Temu   Coupon For $100 Off ((“aci789589”)): Get A Flat $100 Discount On Order Value Get ready to save big with our incredible Temu   Coupon for $100 off! Our amazing Temu   $100 off coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. Temu   Coupon Code For $100 Off ((“aci789589”)): For Both New And Existing Customers Our incredible Temu   Coupon code for $100 off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100 off code for Temu   will give you an additional discount! Temu   Coupon Bundle ((“aci789589”)): Flat $100 Off + Up To $100 Discount Get ready for an unbelievable deal with our Temu   Coupon bundle for 2025! Our Temu   Coupon bundles will give you a flat $100 discount and an additional $100 off on top of it. Free Temu   Coupons ((“aci789589”)): Unlock Unlimited Savings! Get ready to unlock a world of savings with our free Temu   Coupons! We’ve got you covered with a wide range of Temu   Coupon code options that will help you maximize your shopping experience. 100% Off Temu   Coupons, Promo Codes + 25% Cash Back ((“aci789589”)) Redeem Temu   Coupon Code ((“aci789589”)) Temu   Coupon $100 OFF ((“aci789589”)) Temu   Coupon $100 OFF FOR EXISTING CUSTOMERS ((“aci789589”)) Temu   Coupon $100 OFF FIRST ORDER ((“aci789589”)) Temu   Coupon $100 OFF REDDIT ((“aci789589”)) Temu   Coupon $100 OFF FOR EXISTING CUSTOMERS REDDIT ((“aci789589”)) Temu   $100 OFF CODE ((“aci789589”)) Temu   70 OFF COUPON 2025 ((“aci789589”)) DOMINOS 70 RS OFF COUPON CODE ((“aci789589”)) WHAT IS A COUPON RATE ((“aci789589”)) Temu   $100 OFF FOR EXISTING CUSTOMERS ((“aci789589”)) Temu   $100 OFF FIRST ORDER ((“aci789589”)) Temu   $100 OFF FREE SHIPPING ((“aci789589”)) You can get an exclusive $100 off discount on your Temu   purchase with the code [aci789589] Or [aci789589].This code is specially designed for new customers and offers a significant price cut on your shopping. Make your first purchase on Temu   more rewarding by using this code to get $100 off instantly. Temu   Coupon Code For $100 Off [aci789589] Or [aci789589]: Get A Flat $100 Discount On Order Value Get ready to save big with our incredible Temu   coupon for $100 off! Our coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. Exclusive Temu   Discount Code [aci789589] Or [aci789589]: Flat $200 OFF for New and Existing Customers Using our Temu   promo code you can get A$ 200 off your order and 100% off using our Temu   promo code [aci789589] Or [aci789589]. As a new Temu   customer, you can save up to $100 using this promo code. For returning users, our Temu   promo code offers a $100 price slash on your next shopping spree. This is our way of saying thank you for shopping with us! Best Temu   Deals and Coupons [aci789589] Or [aci789589]: During 2025, Temu   coupon codes offer discounts of up to 90% on select items, making it possible for both new and existing users to get incredible deals. From $100 off deals to 100% discounts, our Temu   promo codes make shopping more affordable than ever. Temu   Coupon Code For $100% Off [aci789589] Or [aci789589]: For Both New And Existing Customers Free Temu   $100 Off Code — [aci789589] Or [aci789589] Temu   Coupon 100% Off — [aci789589] Or [aci789589] Temu   Memorial Day Sale - $100 Off — [aci789589] Or [aci789589] Temu   Free Gift Code — [aci789589] Or [aci789589] Temu   $500 Off Code — [aci789589 ] Or [aci789589] Best Temu   $200 Off Code — [aci789589 ] Or [aci789589] Temu   Coupon Code first order — [aci789589] Or [aci789589] Temu   Coupon Code for New user — [aci789589] Or [aci789589] Temu   Coupon Code A$100 off — [aci789589] Or [aci789589] Temu   Coupon Code $50 off — [aci789589] Or [aci789589] Temu   Coupon Code $100 off — [aci789589] Or [aci789589] Temu   Promo Code 2025 — [aci789589] Or [aci789589] Temu   Coupon Code $200 off — [aci789589] Or [aci789589] Temu   Coupon Code $90 off — [aci789589] Or [aci789589] Temu   Sign up Bonus Code — [aci789589] Or [aci789589] Temu   Coupon Code A$120 off — [aci789589] Or [aci789589] Our exclusive Temu   coupon code allows you to take a flat $200 off your purchase with an added 100% discount on top. As a new Temu   shopper, you can save up to $100 using code [aci789589] Or [aci789589]. Returning customers can also enjoy a $100 discount on their next purchases with this code. Temu   Coupon Code for Your Country Sign-up Bonus Temu   $100 Off Code  USA      [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA     [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code USA  [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Japan [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Mexico [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Chile [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code USA [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Colombia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Malaysia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Philippines [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code South Korea [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA      [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Pakistan [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Finland [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Saudi Arabia [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Qatar [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code France [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Germany [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code  USA   [aci789589] Or [aci789589] - 100% off Temu   $100 Off Code Israel [aci789589] Or [aci789589] - 100% off Get a $100 discount on your Temu   order with the promo code [aci789589] Or [aci789589]. You can get a discount by clicking on the item to purchase and entering this Temu   coupon code $100 off [aci789589] Or [aci789589]. Temu   Coupon Code [aci789589] Or [aci789589]: Get Up To 90% OFF In NOV 2025 Are you looking for the best Temu   coupon codes to get amazing discounts? Our Temu   coupons are perfect for getting those extra savings you crave. We regularly test our coupon codes for Temu   to ensure they work flawlessly, giving you a guaranteed discount every time. Temu   New User Coupon [aci789589] Or [aci789589]: Up To $100 OFF For First-Time Users Our Temu   first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on Temu  . To maximize your savings, download the Temu   app and apply our Temu   new user coupon during checkout.
    • Looking to score big savings on your favorite products? The acr639380 Temu coupon code is your ticket to maximum benefits — whether you’re in the USA, Canada, or Europe. This powerful discount code is perfect for both new and existing customers, unlocking exclusive discounts, special offers, free gifts, and unique bundles. So, whether you’re searching for a Temu 40% off coupon for new customers or a Temu coupon code for existing users in 2025, this guide has got you covered. Let’s dive into how you can make the most out of this amazing discount.  What Is the Temu 40% Off Coupon Code? The Temu 40% off coupon code is an exclusive promotional offer designed to help shoppers save big across a wide variety of products. Best of all — it works for both first-time users and returning shoppers.  Key Benefits of Using Code acr639380: 40% off your first order for new customers.   $100 coupon bundle for new users, redeemable across multiple purchases.   40% discount for existing customers on select items.   Additional $100 off promo code for loyal customers in the USA and Canada.   Free shipping to over 68 countries, including the USA, Canada, and Europe.   Extra 30% off on any item, stacking with ongoing promotions.   Free gifts with express shipping for loyal customers.   This makes it one of the most versatile and rewarding discount codes available on Temu right now.  Temu Coupon Code 40% Off for New Users If you’re new to Temu, you’re in luck! The acr639380 code brings new users unmatched benefits: Flat 40% off your first purchase — making it the ideal chance to grab your wishlist items.   $100 coupon bundle available immediately after signup.   Up to $100 in bonus coupon packs for future purchases.   Free shipping to over 68 countries.   An additional 30% discount on select products for first-time customers.   New shoppers should definitely take advantage of this code to experience Temu’s massive catalog without overspending.  How to Redeem the Temu 40% Off Coupon Code (For New Customers) Redeeming the code is easy — just follow these steps: Visit the Temu website or open the app.   Sign up for a new account.   Browse and add items to your shopping cart.   At checkout, enter the code acr639380 in the promo code box.   Click ‘Apply’ — your total will instantly reduce by 40%.   Complete your order and enjoy your savings!    Temu Coupon Code 40% Off for Existing Customers Good news — it’s not just new users who get to save. Existing Temu shoppers can also use the acr639380 code to access great discounts: 40% off select items.   $100 coupon bundle for multiple purchases.   Free express shipping and gifts for loyal customers in the USA and Canada.   An additional 30% discount on top of other ongoing deals.   Free shipping to 68+ countries.   It’s an excellent way to continue enjoying deals even after your first order.  How to Use the Temu 40% Off Coupon Code (For Existing Users) If you already have a Temu account: Log into your Temu account.   Add your favorite products to your cart.   Proceed to checkout and enter acr639380 in the “Apply Coupon” section.   Click ‘Apply’ and watch your total drop by 40%.   Complete your purchase and enjoy those savings.    Where to Find the Latest Temu 40% Off Coupon Codes Want to stay ahead with fresh discounts? Here’s where to find verified, up-to-date Temu coupons: Sign up for Temu’s newsletter to receive promo codes directly to your inbox.   Follow Temu’s official social media pages for exclusive discount announcements.   Check reputable coupon websites that regularly update new Temu promo codes.   Visit Temu’s in-app promotions section for seasonal offers and flash sales.    How Temu 40% Off Coupons Work The Temu 40% off coupons apply directly at checkout, reducing your order total by 40%. These codes often don’t have expiration dates and can be combined with other promotions in select cases. Simply enter the code before finalizing payment to enjoy instant savings.  How to Earn 40% Off Coupons as a New Customer New customers can unlock this special offer easily: Sign up for the Temu app or website.   Receive a welcome package of promo codes and discounts via email.   Apply the acr639380 code during your first purchase for instant 40% off.    Advantages of Using Temu 40% Off Coupons Why use this code? Here’s what makes it worth it: Massive 40% discount on your first order.   $100 coupon bundle for new shoppers.   70% off popular products on top of existing deals.   Additional 30% off for existing customers.   Free international shipping to 68 countries.   No expiration date for ongoing savings.    Temu Free Gifts and Special Deals (2025) More than just discounts — using acr639380 gives you access to these exclusive perks: Free gift for new customers with your first order.   40% off first and existing customer purchases.   Extra 30% off storewide.   Up to 70% off select trending products.   Free express shipping to the USA, Canada, and Europe.    Pros and Cons of Using Temu 40% Off Coupon Code Pros Cons 40% off for both new and existing customers Some items may not be eligible for discounts $100 coupon bundle for new customers Limited regional availability for certain coupons Additional 30% discounts on selected products May only apply to specific product categories Free shipping to 68+ countries Occasional limited stock on high-demand items No expiration date on most promo codes Not all promotions can be stacked together  Temu 40% Off Coupon Terms & Conditions (2025) Valid for both new and existing users.   Available in USA, Canada, Europe, and 68 other countries.   No minimum purchase required.   Multiple uses permitted as per promo eligibility.   Most codes, including acr639380, have no set expiration date.   Cannot be combined with select limited-time sitewide promotions.    Final Thoughts The Temu coupon code 40% off (acr639380) is one of the best ways to save big on your favorite products in 2025. Whether you’re a new shopper looking for your first big discount or a loyal customer hunting for the next great deal, this code delivers value every time. Don’t miss out — apply the acr639380 code at checkout and start saving today!  FAQs About Temu 40% Off Coupon Code Q: Is the Temu 40% off coupon for first-time users only? No — it’s available for both new and existing customers. Q: How do I redeem the Temu coupon code 40% off? Enter acr639380 in the promo code box at checkout and click ‘Apply’. Q: Can I use this code for multiple purchases? Yes — depending on promo rules and item eligibility. Q: Does the Temu 40% off coupon have an expiration date? No — most Temu codes, including this one, don’t expire. Q: Can I share the Temu coupon code with my friends? Absolutely! Share the acr639380 code and let them enjoy the savings too.
    • Thank you so much! I didnt see it in the log😭😭  
  • Topics

×
×
  • Create New...

Important Information

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