Jump to content

Recommended Posts

Posted

I am creating  a custom furnace, however i have three problems with it at the moment:

1. i cannot create recipes for the furnace, due to the fact that it is a 3 * 3 grid in which everything is being built

(for this one i just need to know how to make the recipes, but i have been unable to find an help on this matter on the internet)

 

2. whenever i open the gui, there is a line in the middle that is not in the actual image file

(http://s1273.photobucket.com/user/edy22174/library/?view=recent&page=1)

 

3. I have set my  custom furnace to store fuel, however i cannot see where the fuel is being stored

 

Here is all my code

 

GUI Handler

 

package net.mymod.Handler;

import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.mymod.mod.mymod;
import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;
import net.mymod.mod.container.ContainerAngellicInfuser;
import net.mymod.mod.gui.guiAngelicInfuser;


public class GUIHandler implements IGuiHandler {

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,	int x, int y, int z) {
	TileEntity entity = world.getTileEntity(x, y, z);

	if(entity != null) {
		switch(ID) {

		case mymod.guiIdAngelicInfuser:
			if (entity instanceof TileEntityAngellicInfuser) {
				return new ContainerAngellicInfuser(player.inventory, (TileEntityAngellicInfuser) entity);
			}

		}
	}
	return null;

}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,	int x, int y, int z) {
	TileEntity entity = world.getTileEntity(x, y, z);

	if(entity != null) {
		switch(ID) {
		case mymod.guiIdAngelicInfuser:
			if (entity instanceof TileEntityAngellicInfuser) {
				return new guiAngelicInfuser(player.inventory, (TileEntityAngellicInfuser) entity);
			}

		}
	}
	return null;

}



}		

 

Main Modding Class

 

package net.mymod.mod;


import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
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.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.EnumHelper;
import net.mymod.Handler.CraftingHandler;
import net.mymod.Handler.GUIHandler;
import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;
import net.mymod.mod.WorldGen.mymodWorldGen;
import net.mymod.mod.armor.AngelArmor;
import net.mymod.mod.armor.DemonArmor;
import net.mymod.mod.blocks.AltarCore;
import net.mymod.mod.blocks.AngellicInfuser;
import net.mymod.mod.blocks.AngellicOre;
import net.mymod.mod.blocks.DemonicCorrupter;
import net.mymod.mod.blocks.DemonicOre;
import net.mymod.mod.items.AngelBlade;
import net.mymod.mod.items.AngelicIngot;
import net.mymod.mod.items.AngellicAxe;
import net.mymod.mod.items.AngellicHoe;
import net.mymod.mod.items.AngellicPickaxe;
import net.mymod.mod.items.AngellicSpade;
import net.mymod.mod.items.ChaosDust;
import net.mymod.mod.items.DemonicAxe;
import net.mymod.mod.items.DemonicHoe;
import net.mymod.mod.items.DemonicMace;
import net.mymod.mod.items.DemonicPickaxe;
import net.mymod.mod.items.DemonicSpade;
import net.mymod.mod.items.InfusedStick;
import net.mymod.mod.items.PowderedOrder;

@Mod(modid = mymod.modid, version = mymod.version)
public class mymod {
public static final String modid = "mymod";
public static final String version = "Alpha 0.1";

mymodWorldGen eventWorldGen = new mymodWorldGen();

public static CreativeTabs SatangelicaTab;

//tool material

public static ToolMaterial AngelMaterial = EnumHelper.addToolMaterial("AngelMaterial", 3, 3000, 10.0f, 10.0f, 39); 
public static ToolMaterial DemonMaterial = EnumHelper.addToolMaterial("DemonMaterial", 3, 2000, 13.0f, 12.0f, 20);

//armor material

public static ArmorMaterial AngelArmor = EnumHelper.addArmorMaterial("AngelArmor", 10, new int[] {5, 8, 6, 5}, 40);
public static ArmorMaterial DemonArmor = EnumHelper.addArmorMaterial("DemonArmor", 10, new int[] {4, 7, 5, 4}, 27);

@Instance(modid)
public static mymod instance;

//blocks

public static Block blockAltarCore;

//ores

public static Block oreAngellicOre;
public static Block oreDemonicOre;

//items

public static Item itemInfusedStick;

//ingots

public static Item itemAngelicIngot;

//dusts

public static Item itemChaosDust;
public static Item itemPowderedOrder;

//tools

public static Item itemAngelBlade;
public static Item itemAngellicPickaxe;
public static Item itemAngellicAxe;
public static Item itemAngellicSpade;
public static Item itemAngellicHoe;

public static Item itemDemonicMace;
public static Item itemDemonicPickaxe;
public static Item itemDemonicHoe;
public static Item itemDemonicSpade;
public static Item itemDemonicAxe;

//armor

public static int armorAngelHelmId; 
public static int armorAngelChestplateId;
public static int armorAngelLeggingsId;
public static int armorAngelBootsId;

public static int armorDemonHelmId;
public static int armorDemonChestplateId;
public static int armorDemonLeggingsId;
public static int armorDemonBootsId;

//armor (items)

public static Item armorAngelHelm;
public static Item armorAngelChestplate;
public static Item armorAngelLeggings;
public static Item armorAngelBoots;

public static Item armorDemonHelm;
public static Item armorDemonChestplate;
public static Item armorDemonLeggings;
public static Item armorDemonBoots;

//Angellic Infuser

public static Block blockAngellicInfuserIdle;
public static Block blockAngellicInfuserActive;
public static final int guiIdAngelicInfuser = 1;

//Demonic Corrupter

public static Block blockDemonicCorrupterIdle;
public static Block blockDemonicCorrupterActive;
public static final int guiIdDemonicCorrupter = 2;

//Enchantments

public static final Enchantment Absorbtion = new net.mymod.Enchantments.Absorbtion(111, 5);



@EventHandler
public void PreInit(FMLPreInitializationEvent preEvent){

SatangelicaTab = new CreativeTabs("mymod") {
	@SideOnly(Side.CLIENT)
	public Item getTabIconItem() {
	return Item.getItemFromBlock(mymod.blockAltarCore);
	}
};
//blocks

blockAltarCore = new AltarCore(Material.rock).setBlockName("Altar Core");	
GameRegistry.registerBlock(blockAltarCore, "Altar Core");

//ores

oreAngellicOre = new AngellicOre(Material.rock).setBlockName("Angellic Ore");	
GameRegistry.registerBlock(oreAngellicOre, "Angellic Ore");
oreDemonicOre = new DemonicOre(Material.rock).setBlockName("Demonic Ore");	
GameRegistry.registerBlock(oreDemonicOre, "Demonic Ore");

//items	

itemInfusedStick  = new InfusedStick().setUnlocalizedName("Infused Stick"); 
GameRegistry.registerItem(itemInfusedStick, "Infused Stick");

//ingots
itemAngelicIngot = new AngelicIngot().setUnlocalizedName("Angelic Ingot");
GameRegistry.registerItem(itemAngelicIngot, "Angelic Ingot");

//dusts
itemChaosDust = new ChaosDust().setUnlocalizedName("Chaos Dust");
GameRegistry.registerItem(itemChaosDust, "Chaos Dust");
itemPowderedOrder = new PowderedOrder().setUnlocalizedName("Powdered Order");
GameRegistry.registerItem(itemPowderedOrder, "PowderedOrder");

//tools

itemAngelBlade = new AngelBlade(AngelMaterial).setUnlocalizedName("Angel Blade");
GameRegistry.registerItem(itemAngelBlade, "Angel Blade");
itemAngellicPickaxe = new AngellicPickaxe(AngelMaterial).setUnlocalizedName("Angellic Pickaxe");
GameRegistry.registerItem(itemAngellicPickaxe, "Angellic Pickaxe");
itemAngellicAxe = new AngellicAxe(AngelMaterial).setUnlocalizedName("Angellic Axe");
GameRegistry.registerItem(itemAngellicAxe, "Angellic Axe");
itemAngellicSpade = new AngellicSpade(AngelMaterial).setUnlocalizedName("Angellic Spade");
GameRegistry.registerItem(itemAngellicSpade, "Angellic Spade");
itemAngellicHoe = new AngellicHoe(AngelMaterial).setUnlocalizedName("Angellic Hoe");
GameRegistry.registerItem(itemAngellicHoe, "Angellic Hoe ");

itemDemonicMace = new DemonicMace(DemonMaterial).setUnlocalizedName("Demonic Mace");
GameRegistry.registerItem(itemDemonicMace, "Demonic Mace");
itemDemonicHoe = new DemonicHoe(DemonMaterial).setUnlocalizedName("Demonic Hoe");
GameRegistry.registerItem(itemDemonicHoe, "Demonic Hoe");
itemDemonicAxe = new DemonicAxe(DemonMaterial).setUnlocalizedName("Demonic Axe");
GameRegistry.registerItem(itemDemonicAxe, "Demonic Axe");
itemDemonicSpade = new DemonicSpade(DemonMaterial).setUnlocalizedName("Demonic Spade");
GameRegistry.registerItem(itemDemonicSpade, "Demonic Spade");
itemDemonicPickaxe = new DemonicPickaxe(DemonMaterial).setUnlocalizedName("Demonic Pickaxe");
GameRegistry.registerItem(itemDemonicPickaxe, "Demonic Pickaxe");

//armor

armorAngelHelm = new AngelArmor(AngelArmor, armorAngelHelmId, 0).setUnlocalizedName("Angel Helm"); 
GameRegistry.registerItem(armorAngelHelm, "Angel Helm");
armorAngelChestplate = new AngelArmor(AngelArmor, armorAngelChestplateId, 1).setUnlocalizedName("Angel Chestplate");
GameRegistry.registerItem(armorAngelChestplate, "Angel Chestplate");
armorAngelLeggings = new AngelArmor(AngelArmor, armorAngelLeggingsId, 2).setUnlocalizedName("Angel Leggings");
GameRegistry.registerItem(armorAngelLeggings, "Angel Leggings");
armorAngelBoots = new AngelArmor(AngelArmor, armorAngelBootsId, 3).setUnlocalizedName("Angel Boots"); 
GameRegistry.registerItem(armorAngelBoots, "Angel Boots");

armorDemonHelm = new DemonArmor(DemonArmor, armorDemonHelmId, 0).setUnlocalizedName("Demon Helm");
GameRegistry.registerItem(armorDemonHelm, "Demon Helm");
armorDemonChestplate = new DemonArmor(DemonArmor, armorDemonChestplateId, 1).setUnlocalizedName("Demon Chestplate");
GameRegistry.registerItem(armorDemonChestplate, "Demon Chestplate");
armorDemonLeggings = new DemonArmor(DemonArmor, armorDemonLeggingsId, 2).setUnlocalizedName("DemonLeggings");
GameRegistry.registerItem(armorDemonLeggings, "Demon Leggings");
armorDemonBoots = new DemonArmor(DemonArmor, armorDemonBootsId, 3).setUnlocalizedName("Demon Boots");
GameRegistry.registerItem(armorDemonBoots, "Demon Boots");

//Angelic Infuser

blockAngellicInfuserIdle = new AngellicInfuser(false).setBlockName("Angellic Infuser Idle").setCreativeTab(mymod.SatangelicaTab).setHardness(3.5F);
GameRegistry.registerBlock(blockAngellicInfuserIdle, "Angellic Infuser Idle");

blockAngellicInfuserActive = new AngellicInfuser(true).setBlockName("Angellic Infuser Active").setHardness(3.5F);
GameRegistry.registerBlock(blockAngellicInfuserActive, "Angellic Infuser Active");

//Demonic Corrupter

blockDemonicCorrupterIdle = new DemonicCorrupter(false).setBlockName("Demonic Corrupter Idle").setCreativeTab(mymod.SatangelicaTab).setHardness(3.5F);
GameRegistry.registerBlock(blockDemonicCorrupterIdle, "Demonic Corrupter Idle");

blockDemonicCorrupterActive = new DemonicCorrupter(true).setBlockName("Demonic Corrupter Active").setHardness(3.5F);
GameRegistry.registerBlock(blockDemonicCorrupterActive, "Demonic Corrupter Active");




//spawn



};

@EventHandler
public void Init(FMLInitializationEvent event){

//Gui Handler

FMLCommonHandler.instance().bus().register(new CraftingHandler());
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GUIHandler());

GameRegistry.registerTileEntity(TileEntityAngellicInfuser.class, "AngellicInfuser");


//Recipes
GameRegistry.addRecipe(new ItemStack(blockAltarCore), new Object[]{"SIS", "SIS", "SIS", 'S', Blocks.stone, 'I', mymod.itemInfusedStick});
    GameRegistry.addRecipe(new ItemStack(itemInfusedStick), new Object []{ "CSO", "OSC", "CSO", 'C', mymod.itemChaosDust, 'S', Items.stick, 'O', mymod.itemPowderedOrder});


GameRegistry.addSmelting(oreAngellicOre, new ItemStack(itemPowderedOrder, 3), 5);
GameRegistry.addSmelting(oreDemonicOre, new ItemStack(itemChaosDust, 3), 5);

GameRegistry.registerTileEntity(TileEntityAngellicInfuser.class, "TEAngellicInfuser");


}


@EventHandler
public void PostInit(FMLPostInitializationEvent postEvent){

}
}

 

Block Class

 

package net.mymod.mod.blocks;

import java.util.Random;

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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.mymod.mod.mymod;
import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

public class AngellicInfuser extends BlockContainer {

private Random rand;
private final boolean isActive;
private static boolean keepInventory = true;

@SideOnly(Side.CLIENT)
private IIcon iconFront;

public AngellicInfuser(boolean blockState) {
	super(Material.iron);
	rand = new Random();
	isActive = blockState;

}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
	this.blockIcon = iconRegister.registerIcon(mymod.modid + ":" + "Angellic Infuser Side");
	this.iconFront = iconRegister.registerIcon(mymod.modid + ":" + (this.isActive ? "Angellic Infuser Front Active" : "Angellic Infuser Front Idle"));
}

@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
	return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
}

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 block1 = world.getBlock(x, y, z - 1);
		Block block2 = world.getBlock(x, y, z + 1);
		Block block3 = world.getBlock(x - 1, y, z);
		Block block4 = world.getBlock(x + 1, y, z);

		byte b0 = 3;

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

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

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

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

		world.setBlockMetadataWithNotify(x, y, x, b0, 2);
	}
    }
    
    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityPlayer, ItemStack itemstack) {
    	int i = MathHelper.floor_double((double)(entityPlayer.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
    	
    	if (i == 0) {
    		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
    	}
    	
    	if (i == 1) {
    		world.setBlockMetadataWithNotify(x, y, z, 5, 2);
    	}
    	
    	if (i == 2) {
    		world.setBlockMetadataWithNotify(x, y, z, 3, 2);
    	}
    	
    	if (i == 3) {
    		world.setBlockMetadataWithNotify(x, y, z, 4, 2);
    	}
    	
    	if(itemstack.hasDisplayName()) {
    	}
    }
    
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
    	if (world.isRemote) {
    		return true;
    	}else if (!player.isSneaking()) {
    		TileEntityAngellicInfuser entity = (TileEntityAngellicInfuser) world.getTileEntity(x, y, z);
    		if (entity != null) {
    			FMLNetworkHandler.openGui(player, mymod.instance, mymod.guiIdAngelicInfuser, world, x, y, z);
    		}
    		return true;
    	}else{
    		return false;
    	}
    }
    
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new TileEntityAngellicInfuser();
}

public static void updateBlockState(boolean isMashing, World world, int xCoord, int yCoord, int zCoord) {

	int i = world.getBlockMetadata(xCoord, yCoord, zCoord);
	TileEntity entity = world.getTileEntity(xCoord, yCoord, zCoord);
	keepInventory = true;

	if (isMashing) {
		world.setBlock(xCoord, yCoord, zCoord, mymod.blockAngellicInfuserActive);
	}else{
		world.setBlock(xCoord, yCoord, zCoord, mymod.blockAngellicInfuserIdle);
	}

	keepInventory = false;
	world.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, i, 2);

	if (entity != null) {
		entity.validate();
		world.setTileEntity(xCoord, yCoord, zCoord, entity);
	}
}
}

 

Container Class

 

package net.mymod.mod.container;

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.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;
import net.mymod.mod.slot.SlotAngellicInfuser;
import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

public class ContainerAngellicInfuser extends Container {

private TileEntityAngellicInfuser infuser;
private int dualCookTime;
private int dualPower;
private int lastItemBurnTime;

public ContainerAngellicInfuser(InventoryPlayer invPlayer, TileEntityAngellicInfuser teAngellicInfuser) {
	dualCookTime = 0;
	dualPower = 0;
	lastItemBurnTime = 0;

	infuser = teAngellicInfuser;

	this.addSlotToContainer(new Slot(teAngellicInfuser, 0, 49, 35));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 1, 49, 17));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 2, 7, 40));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 4, 49, 53));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 5, 67, 17));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 6, 67, 40));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 7, 67, 53));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 8, 85, 17));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 9, 85, 40));
	this.addSlotToContainer(new Slot(teAngellicInfuser, 10, 85, 53));
	this.addSlotToContainer(new SlotAngellicInfuser(invPlayer.player, teAngellicInfuser, 3, 143, 34));

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

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

public void addCraftingToCrafters (ICrafting crafting) {
	super.addCraftingToCrafters(crafting);
	crafting.sendProgressBarUpdate(this, 0, this.infuser.dualCookTime);
	crafting.sendProgressBarUpdate(this, 1, this.infuser.dualPower);
}

public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, 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 (TileEntityFurnace.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(par1EntityPlayer, itemstack1);
        }

        return itemstack;
    }	

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

 

GUI Class

 

package net.mymod.mod.gui;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.mymod.mod.mymod;
import net.mymod.mod.container.ContainerAngellicInfuser;
import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

public class guiAngelicInfuser extends GuiContainer {

public ResourceLocation texture = new ResourceLocation(mymod.modid + ":" + "/textures/gui/Angelic Infuser GUI.png");
public TileEntityAngellicInfuser AngellicInfuser;

public guiAngelicInfuser(InventoryPlayer invPlayer, TileEntityAngellicInfuser teAngellicInfuser) {
	super(new ContainerAngellicInfuser(invPlayer, teAngellicInfuser));
	AngellicInfuser = teAngellicInfuser;

	this.xSize = 176;
	this.ySize = 166;
}

protected void drawGuiContainerForegroundLayer(int i, int j) {
	String name = this.AngellicInfuser.hasCustomInventoryName() ? this.AngellicInfuser.getInventoryName() : I18n.format(this.AngellicInfuser.getInventoryName());
	this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
	this.fontRendererObj.drawString(I18n.format("container.ContainerAngellicInfuser"), 8, this.ySize - 96 + 5, 4210752);
}

@Override
    protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
    {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
        drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);

        if (AngellicInfuser.hasPower())
        {
            int i1 = AngellicInfuser.getPowerRemainingScaled(45);
            drawTexturedModalRect(guiLeft + 8, guiTop + 53 - i1, 176, 62 - i1, 16, i1);
        }

        int i1 = AngellicInfuser.getMasherProgressScaled(24);
        drawTexturedModalRect(guiLeft + 79, guiTop + 34, 176, 0, i1 + 1, 16);
    }

}

 

Slot Class

 

package net.mymod.mod.slot;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

public class SlotAngellicInfuser extends Slot {

public SlotAngellicInfuser(EntityPlayer player, IInventory iiventory, int i, int j, int k) {
	super(iiventory, i, j, k);
	// TODO Auto-generated constructor stub
}



 

Tile Entity Class

 

package net.mymod.mod.TileEntity;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.mymod.mod.mymod;
import net.mymod.mod.blocks.AngellicInfuser;
import net.mymod.mod.crafting.AngellicInfuserRecipes;

public class TileEntityAngellicInfuser extends TileEntity implements ISidedInventory {

private ItemStack slots[];

public int dualPower;
public int dualCookTime;
public static final int maxPower = 10000;
public static final int infusingSpeed = 100;

private static final int[] slots_top = new int[] {0, 1};
private static final int[] slots_bottom = new int[] {3};
private static final int[] slots_side = new int[] {2};

private String customName;

public TileEntityAngellicInfuser() {
	slots = new ItemStack[11];
}

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

@Override
public ItemStack getStackInSlot(int i) {
	return slots[i];
}

@Override
public ItemStack getStackInSlotOnClosing(int i) {
	if (slots[i] != null) {
		ItemStack itemstack = slots[i];
		slots[i] = null;
		return itemstack;
	}else{
		return null;
	}
}

@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
	slots[i] = itemstack;
	if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
		itemstack.stackSize = getInventoryStackLimit();
	}
}

@Override
public int[] getAccessibleSlotsFromSide(int i) {
	return i == 0 ? slots_bottom : (i == 1 ? slots_top : slots_side);
}




@Override
public int getInventoryStackLimit() {
	return 64;
}

@Override
public boolean isUseableByPlayer(EntityPlayer player) {
	if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {
		return false;
	}else{
		return player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64;
	}
}

public void openInventory() {}
public void closeInventory() {}

@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	return i == 2 ? false : (i == 1 ? hasItemPower(itemstack) : true);
}

public boolean hasItemPower(ItemStack itemstack) {
	return getItemPower(itemstack) > 0;
}

private static int getItemPower (ItemStack itemstack) {
	if (itemstack == null) {
		return 0;
	}else{
		Item item = itemstack.getItem();

		if (item == mymod.itemPowderedOrder) return 50;

		return 0;
	}
}

public ItemStack decrStackSize(int i, int j) {
	if (slots[i] != null) {
		if (slots[i].stackSize <= j) {
			ItemStack itemstack = slots[i];
			slots[i] = null;
			return itemstack;
		}

		ItemStack itemstack1 = slots[i].splitStack(j);

		if (slots[i].stackSize == 0) {
			slots[i] = null;
		}

		return itemstack1;
	}else{
		return null;
	}
}

public void readFromNBT (NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	NBTTagList list = nbt.getTagList("Items", 10);
	slots = new ItemStack[getSizeInventory()];

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

		if (b0 >= 0 && b0 < slots.length) {
			slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
		}
	}

	dualPower = nbt.getShort("PowerTime");
	dualCookTime = nbt.getShort("CookTime");
}

public void writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	nbt.setShort("PowerTime", (short)dualPower);
	nbt.setShort("CookTime", (short)dualCookTime);
	NBTTagList list = new NBTTagList();

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

	nbt.setTag("Items", list);
}


@Override
public String getInventoryName() {
	return "container.AngellicInfuser";
}

@Override
public boolean canInsertItem(int var1, ItemStack itemstack, int var3) {
	return this.isItemValidForSlot(var1, itemstack);
}

@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
	return j != 0 || i != 1 || itemstack.getItem() == Items.bucket;
}

@Override
public boolean hasCustomInventoryName() {
	return this.customName != null && this.customName.length() > 0;
}

public int getMasherProgressScaled(int i) {
	return (dualCookTime * i) / this.infusingSpeed;
}

public int getPowerRemainingScaled(int i) {
	return (dualPower * i) / maxPower;
}

private boolean canMash() {

	if (slots[0] == null || slots[1] == null) {
		return false;
	}

	ItemStack itemstack = AngellicInfuserRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem());

	if (itemstack == null) {
		return false;
	}

	if (slots[9] == null) {
		return true;
	}

	if (!slots[9].isItemEqual(itemstack)) {
		return false;
	}

	if (slots[9].stackSize < getInventoryStackLimit() && slots[3].stackSize < slots[3].getMaxStackSize()) {
		return true;
	}else{
		return slots[9].stackSize < itemstack.getMaxStackSize();
	}
}

private void mashItem() {
	if (canMash()) {
		ItemStack itemstack = AngellicInfuserRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem());

		if (slots[9] == null) {
			slots[9] = itemstack.copy();
		}else if (slots[9].isItemEqual(itemstack)) {
			slots[9].stackSize += itemstack.stackSize;
		}

		for (int i = 0; i < 2; i++) {
			if (slots[i].stackSize <= 0) {
				slots[i] = new ItemStack(slots[i].getItem().setFull3D());
			}else{
				slots[i].stackSize--;
			}

			if (slots[i].stackSize <= 0){
				slots[i] = null;
			}
		}
	}
}

public boolean hasPower() {
	return dualPower > 0;
}

public boolean isMashing() {
	return this.dualCookTime > 0;
}

public void updateEntity() {
	boolean flag = this.hasPower();
	boolean flag1= false;

	if(hasPower() && this.isMashing()) {
		this.dualPower--;
	}

	if(!worldObj.isRemote) {
		if (this.hasItemPower(this.slots[2]) && this.dualPower < (this.maxPower - this.getItemPower(this.slots[2]))) {
			this.dualPower += getItemPower(this.slots[2]);

			if(this.slots[2] != null) {
				flag1 = true;

				this.slots[2].stackSize--;

				if(this.slots[2].stackSize == 0) {
					this.slots[2] = this.slots[2].getItem().getContainerItem(this.slots[2]);
				}
			}
		}

		if (hasPower() && canMash()) {
			dualCookTime++;

			if (this.dualCookTime == this.infusingSpeed) {
				this.dualCookTime = 0;
				this.mashItem();
				flag1 = true;
			}
		}else{
			dualCookTime = 0;
		}

		if (flag != this.isMashing()) {
			flag1 = true;
			AngellicInfuser.updateBlockState(this.isMashing(), this.worldObj, this.xCoord, this.yCoord, this.zCoord);
		}
	}

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

}

 

That is everything, but the most useful thing to know would be how to create my recipes

Posted

I am at work now, so am not able to test anything, but are you trying to put something like coal into slot 2 of your furnace to smelt items.  If no items are available to smelt, then to continue buring the coal and adding to a "battery" for later consumtion?  There is nothing in the tile entity to show what is used for fuel.  ScratchForFun tutorials on Windmill was a great help for me to adding a power progress bar to my gui.

I also tried to pull up your gui picture, but said it was private and could not access it.

 

 

 

Posted

ok thanks, i will try scratch's tutorial, and make it so that my pictures can be seen, but i dont understand the glitchy bit of texture in the middle of the gui (cant really explain it, only show it with pictures).

Posted

just found this when trying to fix it:

- I do have a fuel, it is one of my custom items, and it works (it is being stored, and before i increased how many slots it had, it was smelting off of stored fuel)

- I cannot get the power bar or progress bar to work, which is why my fuel gauge doesnt work.

- I still cant make recipes

- here are the photos

width=800 height=449http://i1273.photobucket.com/albums/y415/edy22174/Minecraft%20Modding/notworking_zpse280e6ac.png[/img]

width=256 height=256http://i1273.photobucket.com/albums/y415/edy22174/Minecraft%20Modding/AngelicInfuserGUI_zpse8a8ffdc.png[/img]

Posted

Pardon if I didn't look close enough at your code, but I do not see you creating or positioning any of your AngelicInfuserSlots in your gui container. So, I think the default slot positions (for cooking item and fuel item) are showing up instead,

Posted

The slots are fine (apart from 2 of them being slightly out of place), however i am not sure if i have done it right, here is what i have for the setting the slots

 

this.addSlotToContainer(new Slot(teAngellicInfuser, 0, 49, 35));

this.addSlotToContainer(new Slot(teAngellicInfuser, 1, 49, 17));

this.addSlotToContainer(new Slot(teAngellicInfuser, 2, 7, 40));

this.addSlotToContainer(new Slot(teAngellicInfuser, 4, 49, 53));

this.addSlotToContainer(new Slot(teAngellicInfuser, 5, 67, 17));

this.addSlotToContainer(new Slot(teAngellicInfuser, 6, 67, 40));

this.addSlotToContainer(new Slot(teAngellicInfuser, 7, 67, 53));

this.addSlotToContainer(new Slot(teAngellicInfuser, 8, 85, 17));

this.addSlotToContainer(new Slot(teAngellicInfuser, 9, 85, 40));

this.addSlotToContainer(new Slot(teAngellicInfuser, 10, 85, 53));

this.addSlotToContainer(new SlotAngellicInfuser(invPlayer.player, teAngellicInfuser, 3, 143, 34));

 

Posted
  On 8/16/2014 at 7:40 AM, edymondo said:

The slots are fine (apart from 2 of them being slightly out of place), however i am not sure if i have done it right, here is what i have for the setting the slots

 

this.addSlotToContainer(new Slot(teAngellicInfuser, 0, 49, 35));

this.addSlotToContainer(new Slot(teAngellicInfuser, 1, 49, 17));

this.addSlotToContainer(new Slot(teAngellicInfuser, 2, 7, 40));

this.addSlotToContainer(new Slot(teAngellicInfuser, 4, 49, 53));

this.addSlotToContainer(new Slot(teAngellicInfuser, 5, 67, 17));

this.addSlotToContainer(new Slot(teAngellicInfuser, 6, 67, 40));

this.addSlotToContainer(new Slot(teAngellicInfuser, 7, 67, 53));

this.addSlotToContainer(new Slot(teAngellicInfuser, 8, 85, 17));

this.addSlotToContainer(new Slot(teAngellicInfuser, 9, 85, 40));

this.addSlotToContainer(new Slot(teAngellicInfuser, 10, 85, 53));

this.addSlotToContainer(new SlotAngellicInfuser(invPlayer.player, teAngellicInfuser, 3, 143, 34));

 

Try this:

this.addSlotToContainer( new SlotAngellicInfuser( teAngellicInfuser, n, x, y) // replace n x and y with your own data.

 

by using new Slot, you are accepting vanilla slot semantics which you have no control over.

 

Also, if I understand your needs properly, 9 slots should be input/output, 1 slot needs to be fuel only, and one output only. So, one slot class will not likely suffice unless a vanilla slot type fits your needs.

Posted

i changed the adding slots part, however i am a little confused about needing multiple slot classes, can you please explain a little bit.

Also, i still have the problem with the gui image, and how to actually make recipes, if you can tell me how to do that, i would greatly appreciate it.

Posted
  On 8/17/2014 at 7:57 AM, edymondo said:

i changed the adding slots part, however i am a little confused about needing multiple slot classes, can you please explain a little bit.

Also, i still have the problem with the gui image, and how to actually make recipes, if you can tell me how to do that, i would greatly appreciate it.

mkay... first take a look at the Slot classes currently in Minercraft: Slot, BeaconSlot, CreativeSlot, Ingredient, Potion, SlotCrafting, SlotFurnace, SlotMerchantResult, and the dynamic new Slot calls. Each overrides certain slot checks, such as isItemValid(itemStack), canTakeStack(player), ... and such.

 

Each slot controls the GUI of the container it is used with. So, in most cases (unless it's a generic accept anything input/output slot), you'd want to specialize it for your gui.

 

Now, as far as recipes go, I cannot really help you with those as I have no idea how your infuser should work. If you could hash out the details on what goes in and what comes out, that would be a start.

Posted

Recipes:

 

        (Custom item)(Custom item)(Custom item) 

(fuel)(iron ingot)(diamond)(iron ingot)                      (output(custom item 2)

        (Custom item)(Custom item)(Custom item)

 

as for the needing another class, i dont believe i do, due to the fact that it is working at the moment aside from the visual parts

Posted
  On 8/18/2014 at 2:06 PM, edymondo said:

Recipes:

 

        (Custom item)(Custom item)(Custom item) 

(fuel)(iron ingot)(diamond)(iron ingot)                      (output(custom item 2)

        (Custom item)(Custom item)(Custom item)

 

as for the needing another class, i dont believe i do, due to the fact that it is working at the moment aside from the visual parts

Okay, so outside of the fuel slot, this seems similar to a crafting table. So, you can use the IRecipe interface.

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

    • 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!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
  • Topics

×
×
  • Create New...

Important Information

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