Jump to content

Custom Furnace


jx759000

Recommended Posts

I'm trying to make a custom furnace using Minecraft Forge. I've followed the fml tutorial for server, but nothing works.

 

Here's some code

 

mod_DFurnace client

package net.minecraft.src;
import java.util.List;

import net.minecraft.client.Minecraft;
import net.minecraft.src.forge.*;

public class mod_DFurnace extends BaseMod /*implements IGuiHandler*/{
public static Block DFurnace;
public static Block DFurnaceOn;
public static int dFurnaceSide = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceSide.png");
public static int dFurnaceFront = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceOff.png");
public static int dFurnaceFrontOn = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceOn.png");

public mod_DFurnace(){
    ModLoader.registerBlock(DFurnace);
    ModLoader.addName(DFurnace, "Diamond Furnace");
    ModLoader.registerTileEntity(net.minecraft.src.TileEntityDFurnace.class, "DFurnace");
    ModLoader.addRecipe(new ItemStack(DFurnace, 1), new Object[]{"XXX","X X","XXX", Character.valueOf('X'), Block.blockDiamond});
    ModLoader.registerBlock(DFurnaceOn);
    ModLoader.addName(DFurnaceOn, "Diamond Furnace On");
    ModLoader.registerTileEntity(net.minecraft.src.TileEntityDFurnace.class, "DFurnaceOn");
    ModLoader.setInGUIHook(this, true, true);
ModLoader.setInGameHook(this, true, true);
//MinecraftForge.setGuiHandler(this, this);
  }

{
    DFurnace = new BlockDFurnace(246, false).setHardness(0F).setResistance(0F).setStepSound(Block.soundMetalFootstep).setBlockName("Diamond Furnace");
    DFurnaceOn = new BlockDFurnace(247, true).setHardness(0F).setResistance(0F).setStepSound(Block.soundMetalFootstep).setBlockName("Diamond Furnace On");
}

public String getVersion() {
return null;
}

public void load() {

}
@Override
public boolean onTickInGame(float f, Minecraft minecraft)
{
    if(minecraft.currentScreen == null)
    {
        lastGuiOpen = null;
    }
    return true;
}



@Override
public boolean onTickInGUI(float f, Minecraft minecraft, GuiScreen guiscreen)
{
    if((guiscreen instanceof GuiContainerCreative) && !(lastGuiOpen instanceof GuiContainerCreative) && !minecraft.theWorld.isRemote)
    {
        Container container = ((GuiContainer)guiscreen).inventorySlots;
        List list = ((ContainerCreative)container).itemList;
            int i = 0;
            list.add(new ItemStack(DFurnace, 1, i));
    }
    lastGuiOpen = guiscreen;
    return true;
}

private static GuiScreen lastGuiOpen;

/*
public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntityDFurnace tileEntity = (TileEntityDFurnace)world.getBlockTileEntity(x, y, z);

if (tileEntity != null)
    {
	return new GuiDFurnace(player.inventory, ((TileEntityDFurnace)tileEntity));
    }
return null;
}
*/
}

 

BlockDFurnace Client

// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode 



//blockIndexInTexture; = Regular/Side in the situation
//if(l == 1) = Top texture
//if(l == 0) = Bottom Texture
//if(i == 3) = Front Texture/Off
//blockIndexInTexture + 16; = Active Texture/On
//blockIndexInTexture - 1; = Off Texture/Off
//l = BlockID

package net.minecraft.src;

import java.util.Random;

public class BlockDFurnace extends BlockContainer
{

    protected BlockDFurnace(int i, boolean flag)
    {
        super(i, Material.rock);
        dFurnaceRand = new Random();
        isActive = flag;
        blockIndexInTexture = 45;
    }

    public int idDropped(int i, Random random)
    {
        return mod_DFurnace.DFurnace.blockID;
    }

    public void onBlockAdded(World world, int i, int j, int k)
    {
        super.onBlockAdded(world, i, j, k);
        setDefaultDirection(world, i, j, k);
    }
    
    private void setDefaultDirection(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            int var5 = par1World.getBlockId(par2, par3, par4 - 1);
            int var6 = par1World.getBlockId(par2, par3, par4 + 1);
            int var7 = par1World.getBlockId(par2 - 1, par3, par4);
            int var8 = par1World.getBlockId(par2 + 1, par3, par4);
            byte var9 = 3;

            if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
            {
                var9 = 3;
            }

            if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
            {
                var9 = 2;
            }

            if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
            {
                var9 = 5;
            }

            if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
            {
                var9 = 4;
            }

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

    
    public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
            return mod_DFurnace.dFurnaceSide;
        }
        else if (par5 == 0)
        {
            return mod_DFurnace.dFurnaceSide;
        }
        else
        {
            int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
            return par5 != var6 ? mod_DFurnace.dFurnaceSide : (this.isActive ? mod_DFurnace.dFurnaceFrontOn : mod_DFurnace.dFurnaceFront);
        }
    }
    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (this.isActive)
        {
            int var6 = par1World.getBlockMetadata(par2, par3, par4);
            float var7 = (float)par2 + 0.5F;
            float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
            float var9 = (float)par4 + 0.5F;
            float var10 = 0.52F;
            float var11 = par5Random.nextFloat() * 0.6F - 0.3F;

            if (var6 == 4)
            {
                par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 5)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 2)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 3)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
            }
        }
    }
    
    public int getBlockTextureFromSide(int par1)
    {
        return par1 == 1 ? mod_DFurnace.dFurnaceSide : (par1 == 0 ? mod_DFurnace.dFurnaceSide : (par1 == 3 ? mod_DFurnace.dFurnaceFront : mod_DFurnace.dFurnaceSide));
    }

   
    public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, mod_DFurnace mod, int x, int y, int z)
    {
        if (par1World.isRemote)
        {
            return true;
        }
        else
        {
            TileEntityDFurnace var6 = (TileEntityDFurnace)par1World.getBlockTileEntity(par2, par3, par4);

            if (var6 != null)
            {
            	par5EntityPlayer.openGui(mod, 123, par1World, x, y, z);
            }

            return true;
        }
    }
    
    public static void updateDFurnaceBlockState(boolean flag, World world, int i, int j, int k)
    {
        int l = world.getBlockMetadata(i, j, k);
        TileEntity tileentity = world.getBlockTileEntity(i, j, k);
        keepDFurnaceInventory = true;
        if(flag)
        {
            world.setBlockWithNotify(i, j, k, mod_DFurnace.DFurnaceOn.blockID);
        } else
        {
            world.setBlockWithNotify(i, j, k, mod_DFurnace.DFurnace.blockID);
        }
        keepDFurnaceInventory = false;
        world.setBlockMetadataWithNotify(i, j, k, l);
        if(tileentity != null)
        {
            tileentity.validate();
            world.setBlockTileEntity(i, j, k, tileentity);
        }
    }

    public TileEntity getBlockEntity()
    {
        return new TileEntityDFurnace();
    }

    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
    {
        int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
        if(l == 0)
        {
            world.setBlockMetadataWithNotify(i, j, k, 2);
        }
        if(l == 1)
        {
            world.setBlockMetadataWithNotify(i, j, k, 5);
        }
        if(l == 2)
        {
            world.setBlockMetadataWithNotify(i, j, k, 3);
        }
        if(l == 3)
        {
            world.setBlockMetadataWithNotify(i, j, k, 4);
        }
    }

    public void onBlockRemoval(World par1World, int par2, int par3, int par4)
    {
        if (!keepDFurnaceInventory)
        {
            TileEntityDFurnace var5 = (TileEntityDFurnace)par1World.getBlockTileEntity(par2, par3, par4);

            if (var5 != null)
            {
                for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6)
                {
                    ItemStack var7 = var5.getStackInSlot(var6);

                    if (var7 != null)
                    {
                        float var8 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;
                        float var9 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;
                        float var10 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;

                        while (var7.stackSize > 0)
                        {
                            int var11 = this.dFurnaceRand.nextInt(21) + 10;

                            if (var11 > var7.stackSize)
                            {
                                var11 = var7.stackSize;
                            }

                            var7.stackSize -= var11;
                            EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));

                            if (var7.hasTagCompound())
                            {
                                var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy());
                            }

                            float var13 = 0.05F;
                            var12.motionX = (double)((float)this.dFurnaceRand.nextGaussian() * var13);
                            var12.motionY = (double)((float)this.dFurnaceRand.nextGaussian() * var13 + 0.2F);
                            var12.motionZ = (double)((float)this.dFurnaceRand.nextGaussian() * var13);
                            par1World.spawnEntityInWorld(var12);
                        }
                    }
                }
            }
        }

        super.onBlockRemoval(par1World, par2, par3, par4);
    }



    private Random dFurnaceRand;
    private final boolean isActive;
    private static boolean keepDFurnaceInventory = false;

}

 

mod_DFurnace server

package net.minecraft.src;
import net.minecraft.src.forge.*;

public class mod_DFurnace extends BaseMod implements IGuiHandler{
public static IGuiHandler handler;
public static Block DFurnace;
public static Block DFurnaceOn;
public static int dFurnaceSide = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceSide.png");
public static int dFurnaceFront = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceOff.png");
public static int dFurnaceFrontOn = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceOn.png");

public mod_DFurnace(){
    ModLoader.registerBlock(DFurnace);
    ModLoader.addName(DFurnace, "Diamond Furnace");
    ModLoader.registerTileEntity(net.minecraft.src.TileEntityDFurnace.class, "DFurnace");
    ModLoader.addRecipe(new ItemStack(DFurnace, 1), new Object[]{"XXX","X X","XXX", Character.valueOf('X'), Block.blockDiamond});
    ModLoader.registerBlock(DFurnaceOn);
    ModLoader.addName(DFurnaceOn, "Diamond Furnace On");
    ModLoader.registerTileEntity(net.minecraft.src.TileEntityDFurnace.class, "DFurnaceOn");
    MinecraftForge.setGuiHandler(this, handler);
  }

{
    DFurnace = new BlockDFurnace(246, false).setHardness(0F).setResistance(0F).setStepSound(Block.soundMetalFootstep).setBlockName("Diamond Furnace");
    DFurnaceOn = new BlockDFurnace(247, true).setHardness(0F).setResistance(0F).setStepSound(Block.soundMetalFootstep).setBlockName("Diamond Furnace On");
}

public String getVersion() {
return null;
}

public void load() {

}

//public static ContainerDFurnace container;

@Override
public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);

if (tileEntity != null)
    {
	return new ContainerDFurnace(player.inventory, ((TileEntityDFurnace)tileEntity));
    }
return null;
}


}

 

BlockDFurnace Server

// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode 



//blockIndexInTexture; = Regular/Side in the situation
//if(l == 1) = Top texture
//if(l == 0) = Bottom Texture
//if(i == 3) = Front Texture/Off
//blockIndexInTexture + 16; = Active Texture/On
//blockIndexInTexture - 1; = Off Texture/Off
//l = BlockID

package net.minecraft.src;

import java.util.Random;

import net.minecraft.src.forge.IGuiHandler;
import net.minecraft.src.forge.MinecraftForge;

public class BlockDFurnace extends BlockContainer
{

    protected BlockDFurnace(int i, boolean flag)
    {
        super(i, Material.rock);
        dFurnaceRand = new Random();
        isActive = flag;
        blockIndexInTexture = 45;
    }

    public int idDropped(int i, Random random)
    {
        return mod_DFurnace.DFurnace.blockID;
    }

    public void onBlockAdded(World world, int i, int j, int k)
    {
        super.onBlockAdded(world, i, j, k);
        setDefaultDirection(world, i, j, k);
    }
    
    private void setDefaultDirection(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            int var5 = par1World.getBlockId(par2, par3, par4 - 1);
            int var6 = par1World.getBlockId(par2, par3, par4 + 1);
            int var7 = par1World.getBlockId(par2 - 1, par3, par4);
            int var8 = par1World.getBlockId(par2 + 1, par3, par4);
            byte var9 = 3;

            if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
            {
                var9 = 3;
            }

            if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
            {
                var9 = 2;
            }

            if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
            {
                var9 = 5;
            }

            if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
            {
                var9 = 4;
            }

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

    
    public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
            return mod_DFurnace.dFurnaceSide;
        }
        else if (par5 == 0)
        {
            return mod_DFurnace.dFurnaceSide;
        }
        else
        {
            int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
            return par5 != var6 ? mod_DFurnace.dFurnaceSide : (this.isActive ? mod_DFurnace.dFurnaceFrontOn : mod_DFurnace.dFurnaceFront);
        }
    }
    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (this.isActive)
        {
            int var6 = par1World.getBlockMetadata(par2, par3, par4);
            float var7 = (float)par2 + 0.5F;
            float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
            float var9 = (float)par4 + 0.5F;
            float var10 = 0.52F;
            float var11 = par5Random.nextFloat() * 0.6F - 0.3F;

            if (var6 == 4)
            {
                par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 5)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 2)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 3)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
            }
        }
    }
    
    public int getBlockTextureFromSide(int par1)
    {
        return par1 == 1 ? mod_DFurnace.dFurnaceSide : (par1 == 0 ? mod_DFurnace.dFurnaceSide : (par1 == 3 ? mod_DFurnace.dFurnaceFront : mod_DFurnace.dFurnaceSide));
    }

   
    public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer,IGuiHandler handler, mod_DFurnace mod, int x, int y, int z, TileEntityFurnace tileentityfurnace)
    {
        if (par1World.isRemote)
        {
            return true;
        }
        else
        {
            TileEntityDFurnace var6 = (TileEntityDFurnace)par1World.getBlockTileEntity(par2, par3, par4);

            if (var6 != null)
            {
            	par5EntityPlayer.openGui(mod, 123, par1World, x, y, z);
            }

            return true;
        }
    }
    
    public static void updateDFurnaceBlockState(boolean flag, World world, int i, int j, int k)
    {
        int l = world.getBlockMetadata(i, j, k);
        TileEntity tileentity = world.getBlockTileEntity(i, j, k);
        keepDFurnaceInventory = true;
        if(flag)
        {
            world.setBlockWithNotify(i, j, k, mod_DFurnace.DFurnaceOn.blockID);
        } else
        {
            world.setBlockWithNotify(i, j, k, mod_DFurnace.DFurnace.blockID);
        }
        keepDFurnaceInventory = false;
        world.setBlockMetadataWithNotify(i, j, k, l);
        if(tileentity != null)
        {
            tileentity.validate();
            world.setBlockTileEntity(i, j, k, tileentity);
        }
    }

    public TileEntity getBlockEntity()
    {
        return new TileEntityDFurnace();
    }

    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
    {
        int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
        if(l == 0)
        {
            world.setBlockMetadataWithNotify(i, j, k, 2);
        }
        if(l == 1)
        {
            world.setBlockMetadataWithNotify(i, j, k, 5);
        }
        if(l == 2)
        {
            world.setBlockMetadataWithNotify(i, j, k, 3);
        }
        if(l == 3)
        {
            world.setBlockMetadataWithNotify(i, j, k, 4);
        }
    }

    public void onBlockRemoval(World par1World, int par2, int par3, int par4)
    {
        if (!keepDFurnaceInventory)
        {
            TileEntityDFurnace var5 = (TileEntityDFurnace)par1World.getBlockTileEntity(par2, par3, par4);

            if (var5 != null)
            {
                for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6)
                {
                    ItemStack var7 = var5.getStackInSlot(var6);

                    if (var7 != null)
                    {
                        float var8 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;
                        float var9 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;
                        float var10 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;

                        while (var7.stackSize > 0)
                        {
                            int var11 = this.dFurnaceRand.nextInt(21) + 10;

                            if (var11 > var7.stackSize)
                            {
                                var11 = var7.stackSize;
                            }

                            var7.stackSize -= var11;
                            EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));

                            if (var7.hasTagCompound())
                            {
                                var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy());
                            }

                            float var13 = 0.05F;
                            var12.motionX = (double)((float)this.dFurnaceRand.nextGaussian() * var13);
                            var12.motionY = (double)((float)this.dFurnaceRand.nextGaussian() * var13 + 0.2F);
                            var12.motionZ = (double)((float)this.dFurnaceRand.nextGaussian() * var13);
                            par1World.spawnEntityInWorld(var12);
                        }
                    }
                }
            }
        }

        super.onBlockRemoval(par1World, par2, par3, par4);
    }



    private Random dFurnaceRand;
    private final boolean isActive;
    private static boolean keepDFurnaceInventory = false;

}

Link to comment
Share on other sites

Why do you have a separate block and tileEntity for on/off? You could do everything from one block and tileEntity. Anyways that not what your asking. The only thing i can see wrong is your not extending networkmod for you mod_xxxx.class. If you do ssp that would be fine but SMP needs the networkmod parts. Other than that i don't know where too looks with just "its not working" could you plz explain you issue some more.

Link to comment
Share on other sites

When I right click on the block on the client(and server), nothing happens.

 

Here's some updated code.

Block DFurnace client

// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode 



//blockIndexInTexture; = Regular/Side in the situation
//if(l == 1) = Top texture
//if(l == 0) = Bottom Texture
//if(i == 3) = Front Texture/Off
//blockIndexInTexture + 16; = Active Texture/On
//blockIndexInTexture - 1; = Off Texture/Off
//l = BlockID

package net.minecraft.src;

import java.util.Random;
import net.minecraft.src.forge.*;

public class BlockDFurnace extends BlockContainer
{

    protected BlockDFurnace(int i, boolean flag)
    {
        super(i, Material.rock);
        dFurnaceRand = new Random();
        isActive = flag;
        blockIndexInTexture = 45;
    }

    public int idDropped(int i, Random random)
    {
        return mod_DFurnace.DFurnace.blockID;
    }

    public void onBlockAdded(World world, int i, int j, int k)
    {
        super.onBlockAdded(world, i, j, k);
        setDefaultDirection(world, i, j, k);
    }
    
    private void setDefaultDirection(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            int var5 = par1World.getBlockId(par2, par3, par4 - 1);
            int var6 = par1World.getBlockId(par2, par3, par4 + 1);
            int var7 = par1World.getBlockId(par2 - 1, par3, par4);
            int var8 = par1World.getBlockId(par2 + 1, par3, par4);
            byte var9 = 3;

            if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
            {
                var9 = 3;
            }

            if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
            {
                var9 = 2;
            }

            if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
            {
                var9 = 5;
            }

            if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
            {
                var9 = 4;
            }

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

    
    public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        if (par5 == 1)
        {
            return mod_DFurnace.dFurnaceSide;
        }
        else if (par5 == 0)
        {
            return mod_DFurnace.dFurnaceSide;
        }
        else
        {
            int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
            return par5 != var6 ? mod_DFurnace.dFurnaceSide : (this.isActive ? mod_DFurnace.dFurnaceFrontOn : mod_DFurnace.dFurnaceFront);
        }
    }
    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (this.isActive)
        {
            int var6 = par1World.getBlockMetadata(par2, par3, par4);
            float var7 = (float)par2 + 0.5F;
            float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
            float var9 = (float)par4 + 0.5F;
            float var10 = 0.52F;
            float var11 = par5Random.nextFloat() * 0.6F - 0.3F;

            if (var6 == 4)
            {
                par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 5)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 2)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 3)
            {
                par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
                par1World.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
            }
        }
    }
    
    public int getBlockTextureFromSide(int par1)
    {
        return par1 == 1 ? mod_DFurnace.dFurnaceSide : (par1 == 0 ? mod_DFurnace.dFurnaceSide : (par1 == 3 ? mod_DFurnace.dFurnaceFront : mod_DFurnace.dFurnaceSide));
    }

   
    public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, mod_DFurnace mod)
    {
        if (world.isRemote)
        {
            return true;
        }
        else
        {
            entityplayer.openGui(mod, 1, world, i, j, k);
            System.out.println("Block Activated");
            
        }
        return true;
    }
    
    public static void updateDFurnaceBlockState(boolean flag, World world, int i, int j, int k)
    {
        int l = world.getBlockMetadata(i, j, k);
        TileEntity tileentity = world.getBlockTileEntity(i, j, k);
        keepDFurnaceInventory = true;
        if(flag)
        {
            world.setBlockWithNotify(i, j, k, mod_DFurnace.DFurnaceOn.blockID);
        } else
        {
            world.setBlockWithNotify(i, j, k, mod_DFurnace.DFurnace.blockID);
        }
        keepDFurnaceInventory = false;
        world.setBlockMetadataWithNotify(i, j, k, l);
        if(tileentity != null)
        {
            tileentity.validate();
            world.setBlockTileEntity(i, j, k, tileentity);
        }
    }

    public TileEntity getBlockEntity()
    {
        return new TileEntityDFurnace();
    }

    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
    {
        int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
        if(l == 0)
        {
            world.setBlockMetadataWithNotify(i, j, k, 2);
        }
        if(l == 1)
        {
            world.setBlockMetadataWithNotify(i, j, k, 5);
        }
        if(l == 2)
        {
            world.setBlockMetadataWithNotify(i, j, k, 3);
        }
        if(l == 3)
        {
            world.setBlockMetadataWithNotify(i, j, k, 4);
        }
    }

    public void onBlockRemoval(World par1World, int par2, int par3, int par4)
    {
        if (!keepDFurnaceInventory)
        {
            TileEntityDFurnace var5 = (TileEntityDFurnace)par1World.getBlockTileEntity(par2, par3, par4);

            if (var5 != null)
            {
                for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6)
                {
                    ItemStack var7 = var5.getStackInSlot(var6);

                    if (var7 != null)
                    {
                        float var8 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;
                        float var9 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;
                        float var10 = this.dFurnaceRand.nextFloat() * 0.8F + 0.1F;

                        while (var7.stackSize > 0)
                        {
                            int var11 = this.dFurnaceRand.nextInt(21) + 10;

                            if (var11 > var7.stackSize)
                            {
                                var11 = var7.stackSize;
                            }

                            var7.stackSize -= var11;
                            EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));

                            if (var7.hasTagCompound())
                            {
                                var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy());
                            }

                            float var13 = 0.05F;
                            var12.motionX = (double)((float)this.dFurnaceRand.nextGaussian() * var13);
                            var12.motionY = (double)((float)this.dFurnaceRand.nextGaussian() * var13 + 0.2F);
                            var12.motionZ = (double)((float)this.dFurnaceRand.nextGaussian() * var13);
                            par1World.spawnEntityInWorld(var12);
                        }
                    }
                }
            }
        }

        super.onBlockRemoval(par1World, par2, par3, par4);
    }



    private Random dFurnaceRand;
    private final boolean isActive;
    private static boolean keepDFurnaceInventory = false;

}

 

mod_DFurnace client

package net.minecraft.src;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.src.forge.*;



public class mod_DFurnace extends NetworkMod implements IGuiHandler{
public static Block DFurnace;
public static Block DFurnaceOn;
public static int dFurnaceSide = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceSide.png");
public static int dFurnaceFront = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceOff.png");
public static int dFurnaceFrontOn = ModLoader.addOverride("/terrain.png", "/dfurnace/DFurnaceOn.png");

public mod_DFurnace(){
    ModLoader.registerBlock(DFurnace);
    ModLoader.addName(DFurnace, "Diamond Furnace");
    ModLoader.registerTileEntity(net.minecraft.src.TileEntityDFurnace.class, "DFurnace");
    ModLoader.addRecipe(new ItemStack(DFurnace, 1), new Object[]{"XXX","X X","XXX", Character.valueOf('X'), Block.blockDiamond});
    ModLoader.registerBlock(DFurnaceOn);
    ModLoader.addName(DFurnaceOn, "Diamond Furnace On");
    ModLoader.registerTileEntity(net.minecraft.src.TileEntityDFurnace.class, "DFurnaceOn");
    ModLoader.setInGUIHook(this, true, true);
ModLoader.setInGameHook(this, true, true);
//MinecraftForge.setGuiHandler(this, this);
  }

{
    DFurnace = new BlockDFurnace(246, false).setHardness(0F).setResistance(0F).setStepSound(Block.soundMetalFootstep).setBlockName("Diamond Furnace");
    DFurnaceOn = new BlockDFurnace(247, true).setHardness(0F).setResistance(0F).setStepSound(Block.soundMetalFootstep).setBlockName("Diamond Furnace On");
}

public String getVersion() {
return null;
}

public void load() {
MinecraftForge.setGuiHandler(this, this);
}

@Override
public boolean onTickInGame(float f, Minecraft minecraft)
{
    if(minecraft.currentScreen == null)
    {
        lastGuiOpen = null;
    }
    return true;
}



@Override
public boolean onTickInGUI(float f, Minecraft minecraft, GuiScreen guiscreen)
{
    if((guiscreen instanceof GuiContainerCreative) && !(lastGuiOpen instanceof GuiContainerCreative) && !minecraft.theWorld.isRemote)
    {
        Container container = ((GuiContainer)guiscreen).inventorySlots;
        List list = ((ContainerCreative)container).itemList;
            int i = 0;
            list.add(new ItemStack(DFurnace, 1, i));
    }
    lastGuiOpen = guiscreen;
    return true;
}

private static GuiScreen lastGuiOpen;

@Override
public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z);
if (ID == 1){
	 return new GuiDFurnace(player.inventory, new TileEntityDFurnace());
}

return true;
}

}

 

EDIT: I got the gui's to work, but this returns null

    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    {
    	return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    }

Does anyone know why this happens

Link to comment
Share on other sites

  • 2 weeks later...

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.



×
×
  • Create New...

Important Information

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