Jump to content

[FIXED] How do I get my Custom Furnace Icon to the Regular Furnace Orientation?


Recommended Posts

Posted

I have a slight problem, it's that the custom furnace icon is flipped and it should look like the default furnace, I've tried everything to fix it,

 

Picture:

Kf7wtNR.png

 

 

 

The picture is showing what it looks like in the furnace, and the regular furnace is in there for reference.

 

 

All the code that makes up my furnace is below, and the files that associate with it;

 

Code and Classes:

 

 

BlockSteelFurnace.java

package com.wd.tasermod.blocks;

import java.util.Map;
import java.util.Random;

import com.google.common.collect.Maps;
import com.wd.tasermod.TaserMain;
import com.wd.tasermod.entity.tileentity.TileEntitySteelFurnace;
import com.wd.tasermod.utils.TaserItemsAndBlocks;
import com.wd.tasermod.utils.TaserReference;

import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class BlockSteelFurnace extends BlockContainer implements ITileEntityProvider {

private final Random rand = new Random();
private final boolean isActive;
private static boolean keepInventory = false;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconFront;
private static final String __OBFID = "CL_00000248";

private Map<ModContainer, IGuiHandler> clientGuiHandlers = Maps.newHashMap();

public BlockSteelFurnace(boolean isActive){
	super(Material.rock);
	this.isActive= isActive;
}


public Item getItemDropped(int p_149650_1_, Random rand, int p_149650_3_)
{
	return Item.getItemFromBlock(TaserItemsAndBlocks.Steel_Furnace);
}


public void onBlockAdded(World world, int x, int y, int z)
{
	super.onBlockAdded(world, x, y, z);
	this.setDefaultDirection(world, x, y, z);
}

private void setDefaultDirection(World world, int x, int y, int z)
{
	if (!world.isRemote)
	{
		Block block = world.getBlock(x, y, z - 1);
		Block block1 = world.getBlock(x, y, z + 1);
		Block block2 = world.getBlock(x - 1, y, z);
		Block block3 = world.getBlock(x + 1, y, z);
		byte b0 = 3;

		if (block.func_149730_j() && !block1.func_149730_j())
		{
			b0 = 3;
		}

		if (block1.func_149730_j() && !block.func_149730_j())
		{
			b0 = 2;
		}

		if (block2.func_149730_j() && !block3.func_149730_j())
		{
			b0 = 5;
		}

		if (block3.func_149730_j() && !block2.func_149730_j())
		{
			b0 = 4;
		}

		world.setBlockMetadataWithNotify(x, y, z, b0, 2);
	}
}


@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
	return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : (side != meta ? this.blockIcon : this.iconFront));
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{
	this.blockIcon = p_149651_1_.registerIcon(TaserReference.modid + ":" + "Steel_Furnace_Side");
	this.iconFront = p_149651_1_.registerIcon(TaserReference.modid + ":" + (this.isActive ? "Steel_Furnace_FrontActive" : "Steel_Furnace_Front"));
	this.iconTop = p_149651_1_.registerIcon(TaserReference.modid + ":" + "Steel_Furnace_Top");
}

public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
	p_149727_5_.openGui(TaserMain.instance, 0, p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_);
	return true;
}


public static void updateFurnaceBlockState(boolean p_149931_0_, World p_149931_1_, int p_149931_2_, int p_149931_3_, int p_149931_4_)
{
	int l = p_149931_1_.getBlockMetadata(p_149931_2_, p_149931_3_, p_149931_4_);
	TileEntity tileentity = p_149931_1_.getTileEntity(p_149931_2_, p_149931_3_, p_149931_4_);
	keepInventory = true;

	if (p_149931_0_)
	{
		p_149931_1_.setBlock(p_149931_2_, p_149931_3_, p_149931_4_, TaserItemsAndBlocks.Steel_FurnaceActive);
	}
	else
	{
		p_149931_1_.setBlock(p_149931_2_, p_149931_3_, p_149931_4_, TaserItemsAndBlocks.Steel_Furnace);
	}

	keepInventory = false;
	p_149931_1_.setBlockMetadataWithNotify(p_149931_2_, p_149931_3_, p_149931_4_, l, 2);

	if (tileentity != null)
	{
		tileentity.validate();
		p_149931_1_.setTileEntity(p_149931_2_, p_149931_3_, p_149931_4_, tileentity);
	}
}


public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
	return new TileEntitySteelFurnace();
}


public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
{
	int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

	if (l == 0)
	{
		p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 2, 2);
	}

	if (l == 1)
	{
		p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 5, 2);
	}

	if (l == 2)
	{
		p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 3, 2);
	}

	if (l == 3)
	{
		p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 4, 2);
	}

	if (p_149689_6_.hasDisplayName())
	{
		((TileEntitySteelFurnace)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145951_a(p_149689_6_.getDisplayName());
	}
}

public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
	if (!keepInventory)
	{
		TileEntitySteelFurnace tileentityfurnace = (TileEntitySteelFurnace)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

		if (tileentityfurnace != null)
		{
			for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
			{
				ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);

				if (itemstack != null)
				{
					float f = this.rand.nextFloat() * 0.8F + 0.1F;
					float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
					float f2 = this.rand.nextFloat() * 0.8F + 0.1F;

					while (itemstack.stackSize > 0)
					{
						int j1 = this.rand.nextInt(21) + 10;

						if (j1 > itemstack.stackSize)
						{
							j1 = itemstack.stackSize;
						}

						itemstack.stackSize -= j1;
						EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));

						if (itemstack.hasTagCompound())
						{
							entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
						}

						float f3 = 0.05F;
						entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
						entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
						entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
						p_149749_1_.spawnEntityInWorld(entityitem);
					}
				}
			}

			p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
		}
	}

	super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}


@SideOnly(Side.CLIENT)
public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
{
	if (this.isActive)
	{
		int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_);
		float f = (float)p_149734_2_ + 0.5F;
		float f1 = (float)p_149734_3_ + 0.0F + p_149734_5_.nextFloat() * 6.0F / 16.0F;
		float f2 = (float)p_149734_4_ + 0.5F;
		float f3 = 0.52F;
		float f4 = p_149734_5_.nextFloat() * 0.6F - 0.3F;

		if (l == 4)
		{
			p_149734_1_.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
		}
		else if (l == 5)
		{
			p_149734_1_.spawnParticle("smoke", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
		}
		else if (l == 2)
		{
			p_149734_1_.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D);
		}
		else if (l == 3)
		{
			p_149734_1_.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D);
			p_149734_1_.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D);
		}
	}
}

/**
 * If this returns true, then comparators facing away from this block will use the value from
 * getComparatorInputOverride instead of the actual redstone signal strength.
 */
public boolean hasComparatorInputOverride()
{
	return true;
}

/**
 * If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
 * strength when this block inputs to a comparator.
 */
public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_)
{
	return Container.calcRedstoneFromInventory((IInventory)p_149736_1_.getTileEntity(p_149736_2_, p_149736_3_, p_149736_4_));
}

/**
 * Gets an item for the block being called on. Args: world, x, y, z
 */
@SideOnly(Side.CLIENT)
public Item getItem(World world, int x, int y, int z)
{
	return Item.getItemFromBlock(TaserItemsAndBlocks.Steel_Furnace);
}
}

 

 

TileEntitySteelFurnace.java

package com.wd.tasermod.entity.tileentity;

import com.wd.tasermod.blocks.BlockSteelFurnace;
import com.wd.tasermod.utils.TaserFurnaceRecipes;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFurnace;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;

public class TileEntitySteelFurnace extends TileEntity implements ISidedInventory
{
    private static final int[] slotsTop = new int[] {0};
    private static final int[] slotsBottom = new int[] {2, 1};
    private static final int[] slotsSides = new int[] {1};
    /** The ItemStacks that hold the items currently being used in the furnace */
    private ItemStack[] furnaceItemStacks = new ItemStack[3];
    /** The number of ticks that the furnace will keep burning */
    public int furnaceBurnTime;
    /** The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for */
    public int currentItemBurnTime;
    /** The number of ticks that the current item has been cooking for */
    public int furnaceCookTime;
    private String field_145958_o;
    private static final String __OBFID = "CL_00000357";

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

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

    /**
     * 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 p_70298_1_, int p_70298_2_)
    {
        if (this.furnaceItemStacks[p_70298_1_] != null)
        {
            ItemStack itemstack;

            if (this.furnaceItemStacks[p_70298_1_].stackSize <= p_70298_2_)
            {
                itemstack = this.furnaceItemStacks[p_70298_1_];
                this.furnaceItemStacks[p_70298_1_] = null;
                return itemstack;
            }
            else
            {
                itemstack = this.furnaceItemStacks[p_70298_1_].splitStack(p_70298_2_);

                if (this.furnaceItemStacks[p_70298_1_].stackSize == 0)
                {
                    this.furnaceItemStacks[p_70298_1_] = null;
                }

                return itemstack;
            }
        }
        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 p_70304_1_)
    {
        if (this.furnaceItemStacks[p_70304_1_] != null)
        {
            ItemStack itemstack = this.furnaceItemStacks[p_70304_1_];
            this.furnaceItemStacks[p_70304_1_] = null;
            return itemstack;
        }
        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 p_70299_1_, ItemStack p_70299_2_)
    {
        this.furnaceItemStacks[p_70299_1_] = p_70299_2_;

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

    /**
     * Returns the name of the inventory
     */
    public String getInventoryName()
    {
        return this.hasCustomInventoryName() ? this.field_145958_o : "Steel Furnace";
    }

    /**
     * Returns if the inventory is named
     */
    public boolean hasCustomInventoryName()
    {
        return this.field_145958_o != null && this.field_145958_o.length() > 0;
    }

    public void func_145951_a(String p_145951_1_)
    {
        this.field_145958_o = p_145951_1_;
    }

    public void readFromNBT(NBTTagCompound p_145839_1_)
    {
        super.readFromNBT(p_145839_1_);
        NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10);
        this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
            byte b0 = nbttagcompound1.getByte("Slot");

            if (b0 >= 0 && b0 < this.furnaceItemStacks.length)
            {
                this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
            }
        }

        this.furnaceBurnTime = p_145839_1_.getShort("BurnTime");
        this.furnaceCookTime = p_145839_1_.getShort("CookTime");
        this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

        if (p_145839_1_.hasKey("CustomName", )
        {
            this.field_145958_o = p_145839_1_.getString("CustomName");
        }
    }

    public void writeToNBT(NBTTagCompound p_145841_1_)
    {
        super.writeToNBT(p_145841_1_);
        p_145841_1_.setShort("BurnTime", (short)this.furnaceBurnTime);
        p_145841_1_.setShort("CookTime", (short)this.furnaceCookTime);
        NBTTagList nbttaglist = new NBTTagList();

        for (int i = 0; i < this.furnaceItemStacks.length; ++i)
        {
            if (this.furnaceItemStacks[i] != null)
            {
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setByte("Slot", (byte)i);
                this.furnaceItemStacks[i].writeToNBT(nbttagcompound1);
                nbttaglist.appendTag(nbttagcompound1);
            }
        }

        p_145841_1_.setTag("Items", nbttaglist);

        if (this.hasCustomInventoryName())
        {
            p_145841_1_.setString("CustomName", this.field_145958_o);
        }
    }

    /**
     * Returns the maximum stack size for a inventory slot.
     */
    public int getInventoryStackLimit()
    {
        return 64;
    }

    /**
     * Returns an integer between 0 and the passed value representing how close the current item is to being completely
     * cooked
     */
    @SideOnly(Side.CLIENT)
    public int getCookProgressScaled(int p_145953_1_)
    {
        return this.furnaceCookTime * p_145953_1_ / 200;
    }

    /**
     * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
     * item, where 0 means that the item is exhausted and the passed value means that the item is fresh
     */
    @SideOnly(Side.CLIENT)
    public int getBurnTimeRemainingScaled(int p_145955_1_)
    {
        if (this.currentItemBurnTime == 0)
        {
            this.currentItemBurnTime = 200;
        }

        return this.furnaceBurnTime * p_145955_1_ / this.currentItemBurnTime;
    }

    /**
     * Furnace isBurning
     */
    public boolean isBurning()
    {
        return this.furnaceBurnTime > 0;
    }

    public void updateEntity()
    {
        boolean flag = this.furnaceBurnTime > 0;
        boolean flag1 = false;

        if (this.furnaceBurnTime > 0)
        {
            --this.furnaceBurnTime;
        }

        if (!this.worldObj.isRemote)
        {
            if (this.furnaceBurnTime != 0 || this.furnaceItemStacks[1] != null && this.furnaceItemStacks[0] != null)
            {
                if (this.furnaceBurnTime == 0 && this.canSmelt())
                {
                    this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

                    if (this.furnaceBurnTime > 0)
                    {
                        flag1 = true;

                        if (this.furnaceItemStacks[1] != null)
                        {
                            --this.furnaceItemStacks[1].stackSize;

                            if (this.furnaceItemStacks[1].stackSize == 0)
                            {
                                this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(furnaceItemStacks[1]);
                            }
                        }
                    }
                }

                if (this.isBurning() && this.canSmelt())
                {
                    ++this.furnaceCookTime;

                    if (this.furnaceCookTime == 200)
                    {
                        this.furnaceCookTime = 0;
                        this.smeltItem();
                        flag1 = true;
                    }
                }
                else
                {
                    this.furnaceCookTime = 0;
                }
            }

            if (flag != this.furnaceBurnTime > 0)
            {
                flag1 = true;
                BlockSteelFurnace.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
            }
        }

        if (flag1)
        {
            this.markDirty();
        }
    }

    /**
     * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
     */
    private boolean canSmelt()
    {
        if (this.furnaceItemStacks[0] == null)
        {
            return false;
        }
        else
        {
            ItemStack itemstack = TaserFurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
            if (itemstack == null) return false;
            if (this.furnaceItemStacks[2] == null) return true;
            if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false;
            int result = furnaceItemStacks[2].stackSize + itemstack.stackSize;
            return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize(); //Forge BugFix: Make it respect stack sizes properly.
        }
    }
    

    /**
     * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
     */
    public void smeltItem()
    {
        if (this.canSmelt())
        {
            ItemStack itemstack = TaserFurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

            if (this.furnaceItemStacks[2] == null)
            {
                this.furnaceItemStacks[2] = itemstack.copy();
            }
            else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem())
            {
                this.furnaceItemStacks[2].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items
            }

            --this.furnaceItemStacks[0].stackSize;

            if (this.furnaceItemStacks[0].stackSize <= 0)
            {
                this.furnaceItemStacks[0] = null;
            }
        }
    }

    /**
     * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
     * fuel
     */
    public static int getItemBurnTime(ItemStack p_145952_0_)
    {
        if (p_145952_0_ == null)
        {
            return 0;
        }
        else
        {
            Item item = p_145952_0_.getItem();
            if (item == Items.lava_bucket) return 20000;
            if (item == Items.blaze_rod) return 2400;
            return GameRegistry.getFuelValue(p_145952_0_);
        }
    }

    public static boolean isItemFuel(ItemStack p_145954_0_)
    {
        /**
         * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
         * fuel
         */
        return getItemBurnTime(p_145954_0_) > 0;
    }

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

    public void openInventory() {}

    public void closeInventory() {}

    /**
     * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
     */
    public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_)
    {
        return p_94041_1_ == 2 ? false : (p_94041_1_ == 1 ? isItemFuel(p_94041_2_) : true);
    }

    /**
     * Returns an array containing the indices of the slots that can be accessed by automation on the given side of this
     * block.
     */
    public int[] getAccessibleSlotsFromSide(int p_94128_1_)
    {
        return p_94128_1_ == 0 ? slotsBottom : (p_94128_1_ == 1 ? slotsTop : slotsSides);
    }

    /**
     * Returns true if automation can insert the given item in the given slot from the given side. Args: Slot, item,
     * side
     */
    public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_)
    {
        return this.isItemValidForSlot(p_102007_1_, p_102007_2_);
    }

    /**
     * Returns true if automation can extract the given item in the given slot from the given side. Args: Slot, item,
     * side
     */
    public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_)
    {
        return p_102008_3_ != 0 || p_102008_1_ != 1 || p_102008_2_.getItem() == Items.bucket;
    }
}

 

 

GuiSteelFurnace.java

package com.wd.tasermod.gui;

import org.lwjgl.opengl.GL11;

import com.wd.tasermod.entity.tileentity.TileEntitySteelFurnace;
import com.wd.tasermod.utils.TaserReference;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;

public class GuiSteelFurnace extends GuiContainer {

private static final ResourceLocation steelFurnaceGuiTextures = new ResourceLocation(TaserReference.modid + ":" + "textures/gui/steelfurnace.png");

public TileEntitySteelFurnace steelFurnace;


public GuiSteelFurnace(InventoryPlayer inventoryPlayer, TileEntitySteelFurnace entity) {
	super(new ContainerSteelFurnace(inventoryPlayer, entity));
	this.steelFurnace = entity;
}

protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
	String s = this.steelFurnace.hasCustomInventoryName() ? this.steelFurnace.getInventoryName() : I18n.format(this.steelFurnace.getInventoryName(), new Object[0]);
	this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
	this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}

@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	this.mc.getTextureManager().bindTexture(steelFurnaceGuiTextures);

	this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);


	if (this.steelFurnace.isBurning())
	{
		int k = this.steelFurnace.getBurnTimeRemainingScaled(12);
		drawTexturedModalRect(guiLeft + 56,  guiTop + 36+12-k,176, 12-k, 14, k + 2);
	}

	int k = this.steelFurnace.getCookProgressScaled(24);
	drawTexturedModalRect(guiLeft + 79, guiTop + 34, 176, 14, k + 1, 16);
}

}

 

 

ContainerSteelFurnace.java

package com.wd.tasermod.gui;

import com.wd.tasermod.entity.tileentity.TileEntitySteelFurnace;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;

public class ContainerSteelFurnace extends Container {

private TileEntitySteelFurnace tileFurnace;
private int lastCookTime;
private int lastBurnTime;
private int lastItemBurnTime;

public ContainerSteelFurnace(InventoryPlayer player, TileEntitySteelFurnace tileEntityFurnace){
	this.tileFurnace = tileEntityFurnace;
	this.addSlotToContainer(new Slot(tileEntityFurnace, 0, 56, 17));
	this.addSlotToContainer(new Slot(tileEntityFurnace, 1, 56, 53));
	this.addSlotToContainer(new SlotFurnace(player.player, tileEntityFurnace, 2, 116, 35));
	int i;

	for(i = 0; i < 3; ++i){
		for(int j = 0; j < 9; ++j){
			this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
		}
	}

	for(i = 0; i < 9; ++i){
		this.addSlotToContainer(new Slot(player, i , 8 + i * 18 , 142));
	}
}

public void addCraftingToCrafters(ICrafting craft){
	super.addCraftingToCrafters(craft);
	craft.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime);
	craft.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceBurnTime);
	craft.sendProgressBarUpdate(this, 2, this.tileFurnace.currentItemBurnTime);
}

public void detectAndSendChanges(){
	super.detectAndSendChanges();
	for(int i = 0; i < this.crafters.size(); ++i){
		ICrafting craft = (ICrafting) this.crafters.get(i);

		if(this.lastCookTime != this.tileFurnace.furnaceCookTime){
			craft.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime);
		}

		if(this.lastBurnTime != this.tileFurnace.furnaceBurnTime){
			craft.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceBurnTime);
		}

		if(this.lastItemBurnTime != this.tileFurnace.currentItemBurnTime){
			craft.sendProgressBarUpdate(this, 2, this.tileFurnace.currentItemBurnTime);
		}
	}

	this.lastBurnTime = this.tileFurnace.furnaceBurnTime;
	this.lastCookTime = this.tileFurnace.furnaceCookTime;
	this.lastItemBurnTime = this.tileFurnace.currentItemBurnTime;
}

@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
	if(par1 == 0){
		this.tileFurnace.furnaceCookTime = par2;
	}

	if(par1 == 1){
		this.tileFurnace.furnaceBurnTime = par2;
	}

	if(par1 == 2){
		this.tileFurnace.currentItemBurnTime = par2;
	}
}

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

public ItemStack transferStackInSlot(EntityPlayer player, int par2){
	ItemStack itemstack = null;
	Slot slot = (Slot) this.inventorySlots.get(par2);

	if(slot != null && slot.getHasStack()){
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		if(par2 == 2){
			if(!this.mergeItemStack(itemstack1, 3, 39, true)){
				return null;
			}
			slot.onSlotChange(itemstack1, itemstack);
		}else if(par2 != 1 && par2 != 0){
			if(FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null){
				if(!this.mergeItemStack(itemstack1, 0, 1, false)){
					return null;
				}
			}else if(TileEntitySteelFurnace.isItemFuel(itemstack1)){
				if(!this.mergeItemStack(itemstack1, 1, 2, false)){
					return null;
				}
			}else if(par2 >=3 && par2 < 30){
				if(!this.mergeItemStack(itemstack1, 30, 39, false)){
					return null;
				}
			}else if(par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)){
				return null;
			}
		}else if(!this.mergeItemStack(itemstack1, 3, 39, false)){
			return null;
		}
		if(itemstack1.stackSize == 0){
			slot.putStack((ItemStack)null);
		}else{
			slot.onSlotChanged();
		}
		if(itemstack1.stackSize == itemstack.stackSize){
			return null;
		}
		slot.onPickupFromSlot(player, itemstack1);
	}
	return itemstack;
}
}

 

 

 

My assumption is that it has something to do with the "BlockSteelFurnace.java", but I tried to do as much as I could with what I know how to do and still no luck. Any help is appreciated, and thank you so much!  :)

 

-Will

-Will. PLEASE do not send me messages with your problems, instead just post a thread first, and then other people can help you too. Thanks for the consideration.

Posted

The textures are controlled by the model, which is controlled by the blockstates file. Post these.

 

What's your furnace supposed to look like?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

In your block's model JSON, inherit from block orientable and set the front texture to the one you want to face you in the inventory screen:

{
    "parent": "minecraft:block/orientable",
    "textures": {
    	"particle" : "your_mod_id:blocks/block_main",
        "top": "your_mod_id:blocks/block_top",
        "side": "your_mod_id:blocks/block_side",
        "front": "your_mod_id:blocks/block_face"
    }
}

Furthermore, your SOUTH facing in your blockstates file should be the one with no rotation applied:

{
    "variants": {
        "facing=north": { "model": "your_mod_id:your_block_model", "y": 180 },
        "facing=south": { "model": "your_mod_id:your_block_model" },
        "facing=west": { "model": "your_mod_id:your_block_model", "y": 90 },
        "facing=east": { "model": "your_mod_id:your_block_model", "y": 270 }
    }
}

 

EDIT: I should also mention that the default value for the blockstate's facing is NORTH.

Posted

This all dates back to Minecraft being an arse with the inventory render system such that the left side visible is Z-pos (south) but had facing blocks use meta:0 as default being Z-neg (north) and having to do workaround nonsense to render them correctly. Makes it a right headache for us modders (I had a block that needed an overlay based on world state to be rendered, so I created a fake block (prerendered overlay) to use as the inventory version, and had to orient the faces differently so that the front was on the visible face).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Thanks so much for all of your help guys!, it worked like a charm. changing topic to fixed. :)

 

-Will

-Will. PLEASE do not send me messages with your problems, instead just post a thread first, and then other people can help you too. Thanks for the consideration.

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

    • After some time minecraft crashes with an error. Here is the log https://drive.google.com/file/d/1o-2R6KZaC8sxjtLaw5qj0A-GkG_SuoB5/view?usp=sharing
    • The specific issue is that items in my inventory wont stack properly. For instance, if I punch a tree down to collect wood, the first block I collected goes to my hand. So when I punch the second block of wood to collect it, it drops, but instead of stacking with the piece of wood already in my hand, it goes to the second slot in my hotbar instead. Another example is that I'll get some dirt, and then when I'm placing it down later I'll accidentally place a block where I don't want it. When I harvest it again, it doesn't go back to the stack that it came from on my hotbar, where it should have gone, but rather into my inventory. That means that if my inventory is full, then the dirt wont be picked up even though there should be space available in the stack I'm holding. The forge version I'm using is 40.3.0, for java 1.18.2. I'll leave the mods I'm using here, and I'd appreciate it if anybody can point me in the right direction in regards to figuring out how to fix this. I forgot to mention that I think it only happens on my server but I&#39;m not entirely sure. PLEASE HELP ME! LIST OF THE MODS. aaa_particles Adorn AdvancementPlaques AI-Improvements AkashicTome alexsdelight alexsmobs AmbientSounds amwplushies Animalistic another_furniture AppleSkin Aquaculture aquamirae architectury artifacts Atlas-Lib AutoLeveling AutoRegLib auudio balm betterfpsdist biggerstacks biomancy BiomesOPlenty blockui blueprint Bookshelf born_in_chaos Botania braincell BrassAmberBattleTowers brutalbosses camera CasinoCraft cfm (MrCrayfish’s Furniture Mod) chat_heads citadel cloth-config Clumps CMDCam CNB cobweb collective comforts convenientcurioscontainer cookingforblockheads coroutil CosmeticArmorReworked CozyHome CrabbersDelight crashexploitfixer crashutilities Create CreativeCore creeperoverhaul cristellib crittersandcompanions Croptopia CroptopiaAdditions CullLessLeaves curios curiouslanterns curiouslights Curses' Naturals CustomNPCs CyclopsCore dannys_expansion decocraft Decoration Mod DecorationDelightRefurbished Decorative Blocks Disenchanting DistantHorizons doubledoors DramaticDoors drippyloadingscreen durabilitytooltip dynamic-fps dynamiclights DynamicTrees DynamicTreesBOP DynamicTreesPlus Easy Dungeons EasyAnvils EasyMagic easy_npc eatinganimation ecologics effective_fg elevatorid embeddium emotecraft enchantlimiter EnchantmentDescriptions EnderMail engineersdecor entityculling entity_model_features entity_texture_features epicfight EvilCraft exlinefurniture expandability explosiveenhancement factory-blocks fairylights fancymenu FancyVideo FarmersDelight fast-ip-ping FastSuite ferritecore finsandtails FixMySpawnR Forge Middle Ages fossil FpsReducer2 furnish GamingDeco geckolib goblintraders goldenfood goodall H.e.b habitat harvest-with-ease hexerei hole_filler huge-structure-blocks HunterIllager iammusicplayer Iceberg illuminations immersive_paintings incubation infinitybuttons inventoryhud InventoryProfilesNext invocore ItemBorders itemzoom Jade jei (Just Enough Items) JetAndEliasArmors journeymap JRFTL justzoom kiwiboi Kobolds konkrete kotlinforforge lazydfu LegendaryTooltips libIPN lightspeed lmft lodestone LongNbtKiller LuckPerms Lucky77 MagmaMonsters malum ManyIdeasCore ManyIdeasDoors marbledsarsenal marg mcw-furniture mcw-lights mcw-paths mcw-stairs mcw-trapdoors mcw-windows meetyourfight melody memoryleakfix Mimic minecraft-comes-alive MineTraps minibosses MmmMmmMmmMmm MOAdecor (ART, BATH, COOKERY, GARDEN, HOLIDAYS, LIGHTS, SCIENCE) MobCatcher modonomicon mods_optimizer morehitboxes mowziesmobs MutantMonsters mysticalworld naturalist NaturesAura neapolitan NekosEnchantedBooks neoncraft2 nerb nifty NightConfigFixes nightlights nocube's_villagers_sell_animals NoSeeNoTick notenoughanimations obscure_api oculus oresabovediamonds otyacraftengine Paraglider Patchouli physics-mod Pillagers Gun PizzaCraft placeableitems Placebo player-animation-lib pneumaticcraft-repressurized polymorph PrettyPipes Prism projectbrazier Psychadelic-Chemistry PuzzlesLib realmrpg_imps_and_demons RecipesLibrary reeves-furniture RegionsUnexplored restrictedportals revive-me Scary_Mobs_And_Bosses selene shetiphiancore ShoulderSurfing smoothboot
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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