Jump to content

Recommended Posts

Posted

Hi, I have just made myself a furnace that takes to inputs (plus the fuel) to make one output.

 

All this works just fine, but the moment I exit the game, if it is any items in the machine, the items disappear. How am I supposed to get rid of this error?

 

CustomFurnaceBlock Class

package net.blazecoding.magicpowders.block;

import java.util.Random;

import net.blazecoding.magicpowders.MagicPowders;
import net.blazecoding.magicpowders.lib.Strings;
import net.blazecoding.magicpowders.tileentity.TileEntityMagicInfuser;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockMagicInfuser extends BlockContainer {

private final Random furnaceRand = new Random();

private final boolean isActive;

private static boolean keepFurnaceInventory = false;

@SideOnly(Side.CLIENT)
private Icon magicInfuserTop;
@SideOnly(Side.CLIENT)
private Icon magicInfuserFront;

protected BlockMagicInfuser(int id, boolean active) {
	super(id, Material.rock);
	setUnlocalizedName(Strings.MAGICINFUSERACTIVE_NAME);

	if (!active) {
		setUnlocalizedName(Strings.MAGICINFUSER_NAME);
		setCreativeTab(MagicPowders.tabMP);
	}

	this.isActive = active;
	setHardness(3.0F);
	setResistance(8.0F);
}

public int idDropped(int id, Random random, int meta) {
	return ModBlocks.magicInfuserIdle.blockID;
}

public void onBlockAdded(World par1World, int par2, int par3, int par4) {
	super.onBlockAdded(par1World, par2, par3, par4);
	this.setDefaultDirection(par1World, par2, par3, par4);
}

private void setDefaultDirection(World par1World, int par2, int par3, int par4) {

	if (!par1World.isRemote) {

		int l = par1World.getBlockId(par2, par3, par4 - 1);

		int i1 = par1World.getBlockId(par2, par3, par4 + 1);
		int j1 = par1World.getBlockId(par2 - 1, par3, par4);
		int k1 = par1World.getBlockId(par2 + 1, par3, par4);

		byte b0 = 3;

		if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1]) {
			b0 = 3;
		}

		if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l]) {
			b0 = 2;
		}

		if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1]) {
			b0 = 5;
		}

		if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1]) {
			b0 = 4;
		}

		par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);

	}

}

@SideOnly(Side.CLIENT)
public Icon getIcon(int par1, int par2) {
	return par1 == 1 ? this.magicInfuserTop : (par1 == 0 ? this.magicInfuserTop : (par1 != par2 ? this.blockIcon : this.magicInfuserFront));
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {

	this.blockIcon = par1IconRegister.registerIcon("furnace_side");
	this.magicInfuserFront = par1IconRegister.registerIcon(this.isActive ? "furnace_front_on" : "furnace_front_off");
	this.magicInfuserTop = par1IconRegister.registerIcon("furnace_top");

}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t) {

	TileEntity tile_entity = world.getBlockTileEntity(x, y, z);

	if (tile_entity == null || player.isSneaking()) {
		return false;
	}

	player.openGui(MagicPowders.instance, 0, world, x, y, z);

	return true;

}

public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4) {

	int l = par1World.getBlockMetadata(par2, par3, par4);
	TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
	keepFurnaceInventory = true;

	if (par0) {
		par1World.setBlock(par2, par3, par4, ModBlocks.magicInfuserActive.blockID);
	} else {
		par1World.setBlock(par2, par3, par4, ModBlocks.magicInfuserIdle.blockID);
	}

	keepFurnaceInventory = false;
	par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);

	if (tileentity != null) {
		tileentity.validate();
		par1World.setBlockTileEntity(par2, par3, par4, tileentity);
	}

}

@SideOnly(Side.CLIENT)
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {

}

public TileEntity createNewTileEntity(World world) {
	return new TileEntityMagicInfuser();
}

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {

	int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

	if (l == 0) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2);
	}

	if (l == 1) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2);
	}

	if (l == 2) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);
	}

	if (l == 3) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2);
	}

	if (par6ItemStack.hasDisplayName()) {
		((TileEntityFurnace) par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName());
	}

}

public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {

	if (!keepFurnaceInventory) {

		TileEntityMagicInfuser tileentityfurnace = (TileEntityMagicInfuser) par1World.getBlockTileEntity(par2, par3, par4);

		if (tileentityfurnace != null) {

			for (int j1 = 0; j1 < tileentityfurnace.getSizeInventory(); ++j1) {

				ItemStack itemstack = tileentityfurnace.getStackInSlot(j1);

				if (itemstack != null) {

					float f = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
					float f1 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
					float f2 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;

					while (itemstack.stackSize > 0) {

						int k1 = this.furnaceRand.nextInt(21) + 10;

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

						itemstack.stackSize -= k1;
						EntityItem entityitem = new EntityItem(par1World, (double) ((float) par2 + f), (double) ((float) par3 + f1), (double) ((float) par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));

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

						float f3 = 0.05F;

						entityitem.motionX = (double) ((float) this.furnaceRand.nextGaussian() * f3);
						entityitem.motionY = (double) ((float) this.furnaceRand.nextGaussian() * f3 + 0.2F);
						entityitem.motionZ = (double) ((float) this.furnaceRand.nextGaussian() * f3);

						par1World.spawnEntityInWorld(entityitem);

					}

				}

			}
			par1World.func_96440_m(par2, par3, par4, par5);
		}

	}
	super.breakBlock(par1World, par2, par3, par4, par5, par6);
}

public boolean hasComparatorInputOverride() {
	return true;
}

public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) {
	return Container.calcRedstoneFromInventory((IInventory) par1World.getBlockTileEntity(par2, par3, par4));
}

}

 

Custom TileEntityFurnace class

package net.blazecoding.magicpowders.tileentity;

import net.blazecoding.magicpowders.item.ModItems;
import net.blazecoding.magicpowders.recipe.MagicInfuserRecipes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.registry.GameRegistry;

public class TileEntityMagicInfuser extends TileEntity implements IInventory {

private ItemStack infuserItemStacks[];

public int dualBurnTime;
public int currentItemBurnTime;
public int dualCookTime;

private String magicInfuserName;

public TileEntityMagicInfuser() {
	infuserItemStacks = new ItemStack[4];
	dualBurnTime = 0;
	currentItemBurnTime = 0;
	dualCookTime = 0;
}

public int getSizeInventory() {
	return infuserItemStacks.length;
}

public ItemStack getStackInSlot(int i) {
	return infuserItemStacks[i];
}

public void setInventorySlotConatainers(int i, ItemStack itemstack) {

	infuserItemStacks[i] = itemstack;

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

}

public void readFromNBT(NBTTagCompound nbttagcompound) {

	super.readFromNBT(nbttagcompound);
	NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
	infuserItemStacks = new ItemStack[getSizeInventory()];

	for (int i = 0; i < nbttaglist.tagCount(); i++) {

		NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
		byte byte0 = nbttagcompound1.getByte("Slot");

		if (byte0 >= 0 && byte0 < infuserItemStacks.length) {
			infuserItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
		}

	}

	dualBurnTime = nbttagcompound.getShort("BurnTime");
	dualCookTime = nbttagcompound.getShort("CookTime");
	currentItemBurnTime = getItemBurnTime(infuserItemStacks[1]);

}

public void writeToNBT(NBTTagCompound nbttagcompound) {
	super.writeToNBT(nbttagcompound);
	nbttagcompound.setShort("BurnTime", (short) dualBurnTime);
	nbttagcompound.setShort("CookTime", (short) dualCookTime);
	NBTTagList nbttaglist = new NBTTagList();

	for (int i = 0; i < infuserItemStacks.length; i++) {

		if (infuserItemStacks[i] != null) {

			NBTTagCompound nbttagcompound1 = new NBTTagCompound();
			nbttagcompound1.setByte("Slot", (byte) i);
			infuserItemStacks[i].writeToNBT(nbttagcompound1);
			nbttaglist.appendTag(nbttagcompound1);

		}

	}
	nbttagcompound.setTag("Items", nbttaglist);
}

public int getInventoryStackLimit() {
	return 64;
}

public int getCookProgressScaled(int i) {
	return (dualCookTime * i) / 200;
}

public int getBurnTimeRemainingScaled(int i) {

	if (currentItemBurnTime == 0) {
		currentItemBurnTime = 200;
	}

	return (dualBurnTime * i) / currentItemBurnTime;

}

public boolean isBurning() {
	return dualBurnTime > 0;
}

public void updateEntity() {

	boolean flag = dualBurnTime > 0;
	boolean flag1 = false;

	if (dualBurnTime > 0) {
		dualBurnTime--;
	}

	if (!worldObj.isRemote) {

		if (dualBurnTime == 0 && canSmelt()) {

			currentItemBurnTime = dualBurnTime = getItemBurnTime(infuserItemStacks[2]);

			if (dualBurnTime > 0) {

				flag1 = true;

				if (infuserItemStacks[2] != null) {

					if (infuserItemStacks[2].stackSize == 0) {

						infuserItemStacks[2] = new ItemStack(infuserItemStacks[2].getItem().setFull3D());

					} else {

						infuserItemStacks[2].stackSize--;

					}

					if (infuserItemStacks[2].stackSize == 0) {
						infuserItemStacks[2] = null;
					}

				}

			}

		}

		if (isBurning() && canSmelt()) {

			dualCookTime++;

			if (dualCookTime == 200) {

				dualCookTime = 0;
				smeltItem();
				flag1 = true;

			}

		} else {

			dualCookTime = 0;

		}

		if (flag != (dualBurnTime > 0)) {
			flag1 = true;
		}

	}

	if (flag1) {
		onInventoryChanged();
	}

}

private boolean canSmelt() {

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

	ItemStack itemstack = MagicInfuserRecipes.getSmeltingResult(infuserItemStacks[0].getItem().itemID, infuserItemStacks[1].getItem().itemID);

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

	if (infuserItemStacks[3] == null) {
		return true;
	}

	if (!infuserItemStacks[3].isItemEqual(itemstack)) {
		return false;
	}

	if (infuserItemStacks[3].stackSize < getInventoryStackLimit() && infuserItemStacks[3].stackSize < infuserItemStacks[3].getMaxStackSize()) {
		return true;

	} else {
		return infuserItemStacks[3].stackSize < itemstack.getMaxStackSize();
	}

}

public void smeltItem() {

	if (!canSmelt()) {
		return;
	}

	ItemStack itemstack = MagicInfuserRecipes.getSmeltingResult(infuserItemStacks[0].getItem().itemID, infuserItemStacks[1].getItem().itemID);

	if (infuserItemStacks[3] == null) {

		infuserItemStacks[3] = itemstack.copy();

	} else if (infuserItemStacks[3].itemID == itemstack.itemID) {
		infuserItemStacks[3].stackSize++;
	}

	for (int i = 0; i < 2; i++) {

		if (infuserItemStacks[i].stackSize <= 0) {
			infuserItemStacks[i] = new ItemStack(infuserItemStacks[i].getItem().setFull3D());

		} else {

			infuserItemStacks[i].stackSize--;
		}

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

	}

}

private int getItemBurnTime(ItemStack itemstack) {

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

	int i = itemstack.getItem().itemID;

	if (i == ModItems.magicDust.itemID) {

		return 2000;

	} else {
		return GameRegistry.getFuelValue(itemstack);
	}

}

public boolean isUseableByPlayer(EntityPlayer entityplayer) {

	if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) {
		return false;
	} else {
		return entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
	}

}

public ItemStack decrStackSize(int i, int j) {

	if (infuserItemStacks[i] != null) {

		if (infuserItemStacks[i].stackSize <= j) {

			ItemStack itemstack = infuserItemStacks[i];
			infuserItemStacks[i] = null;
			return itemstack;

		}

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

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

		return itemstack1;

	} else {
		return null;
	}

}

public void setInventorySlotContents(int i, ItemStack itemstack) {

	infuserItemStacks[i] = itemstack;

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

}

public String getInvName() {
	return "container.infuser";
}

public void openChest() {
}

public void closeChest() {
}

public ItemStack getStackInSlotOnClosing(int i) {

	if (infuserItemStacks[i] != null) {

		ItemStack itemstack = infuserItemStacks[i];
		infuserItemStacks[i] = null;
		return itemstack;

	} else {

		return null;

	}

}

public boolean isInvNameLocalized() {
	return (this.magicInfuserName != null) && (this.magicInfuserName.length() > 0);
}

public void setCustomName(String name) {
	this.magicInfuserName = name;
}

public boolean isItemValidForSlot(int i, ItemStack itemstack) {
	return false;
}

}

 

Custom Container Class

package net.blazecoding.magicpowders.inventory;

import net.blazecoding.magicpowders.inventory.slot.SlotMagicInfuser;
import net.blazecoding.magicpowders.tileentity.TileEntityMagicInfuser;
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;

public class ContainerMagicInfuser extends Container {

private TileEntityMagicInfuser infuser;

private int dualCookTime;
private int dualBurnTime;
private int lastItemBurnTime;

public ContainerMagicInfuser(InventoryPlayer inventoryplayer, TileEntityMagicInfuser tileentityInputFurnace) {

	dualCookTime = 0;
	dualBurnTime = 0;
	lastItemBurnTime = 0;

	infuser = tileentityInputFurnace;

	this.addSlotToContainer(new Slot(tileentityInputFurnace, 0, 38, 17));
	this.addSlotToContainer(new Slot(tileentityInputFurnace, 1, 74, 17));
	this.addSlotToContainer(new Slot(tileentityInputFurnace, 2, 56, 53));
	this.addSlotToContainer(new SlotMagicInfuser(inventoryplayer.player, tileentityInputFurnace, 3, 116, 35));

	for (int i = 0; i < 3; i++) {

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

	}

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

}

public void addCraftingToCrafters(ICrafting par1ICrafting) {
	super.addCraftingToCrafters(par1ICrafting);
	par1ICrafting.sendProgressBarUpdate(this, 0, this.infuser.dualCookTime);
	par1ICrafting.sendProgressBarUpdate(this, 1, this.infuser.dualBurnTime);
	par1ICrafting.sendProgressBarUpdate(this, 2, this.infuser.currentItemBurnTime);
}

public void detectAndSendChanges() {
	super.detectAndSendChanges();

	for (int var1 = 0; var1 < this.crafters.size(); ++var1) {

		ICrafting var2 = (ICrafting) this.crafters.get(var1);

		if (this.dualCookTime != this.infuser.dualCookTime) {
			var2.sendProgressBarUpdate(this, 0, this.infuser.dualCookTime);
		}

		if (this.dualBurnTime != this.infuser.dualBurnTime) {
			var2.sendProgressBarUpdate(this, 1, this.infuser.dualBurnTime);
		}

		if (this.lastItemBurnTime != this.infuser.currentItemBurnTime) {
			var2.sendProgressBarUpdate(this, 2, this.infuser.currentItemBurnTime);
		}

	}

	this.dualCookTime = this.infuser.dualCookTime;
	this.dualBurnTime = this.infuser.dualBurnTime;
	this.lastItemBurnTime = this.infuser.currentItemBurnTime;

}

public void updateProgressBar(int i, int j) {

	if (i == 0) {
		infuser.dualCookTime = j;
	}

	if (i == 1) {
		infuser.dualBurnTime = j;
	}

	if (i == 2) {
		infuser.currentItemBurnTime = j;
	}

}

public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {

	ItemStack itemstack = null;
	Slot slot = (Slot) inventorySlots.get(par2);

	if (slot != null && slot.getHasStack()) {

		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		if (par2 == 2) {

			if (!mergeItemStack(itemstack1, 3, 39, true)) {
				return null;
			}

		} else if (par2 >= 3 && par2 < 30) {

			if (!mergeItemStack(itemstack1, 30, 39, false)) {
				return null;
			}

		} else if (par2 >= 30 && par2 < 39) {

			if (!mergeItemStack(itemstack1, 3, 30, false)) {
				return null;
			}

		} else if (!mergeItemStack(itemstack1, 3, 39, false)) {
			return null;
		}

		if (itemstack1.stackSize == 0) {

			slot.putStack(null);

		} else {

			slot.onSlotChanged();

		}

		if (itemstack1.stackSize != itemstack.stackSize) {
			slot.onPickupFromSlot(par1EntityPlayer, itemstack1);

		} else {

			return null;

		}

	}
	return itemstack;
}

public boolean canInteractWith(EntityPlayer entityplayer) {
	return infuser.isUseableByPlayer(entityplayer);
}
}

 

Custom FurnaceSlot class

package net.blazecoding.magicpowders.inventory.slot;

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

public class SlotMagicInfuser extends Slot {

public SlotMagicInfuser(EntityPlayer entityplayer, IInventory iinventory, int i, int j, int k) {
	super(iinventory, i, j, k);
}

public boolean isItemValid(ItemStack itemstack) {
	return false;
}

public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {

	this.onCrafting(par2ItemStack);
	super.onPickupFromSlot(par1EntityPlayer, par2ItemStack);

}
}

Posted

Now that I look at it I also get this error in the Console:

 

  Reveal hidden contents

 

 

Don't care about the missing textures, that is a mod that someone else is working on.

Posted

I want a "furnace" with two input and a fuel input.

 

And here is where I get the recipes:

 

package net.blazecoding.magicpowders.recipe;

import net.blazecoding.magicpowders.item.ModItems;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class MagicInfuserRecipes {

public MagicInfuserRecipes() {
}

public static ItemStack getInfusingResult(int i, int j, int k, int l) {
	return getOutput(i, j, k, l);
}

private static ItemStack getOutput(int i, int j, int k, int l) {

	if (i == ModItems.magicDust.itemID && k == 0 && j == Item.ingotIron.itemID && l == 0 || i == Item.ingotIron.itemID && k == 0 && j == ModItems.magicDust.itemID && l == 0) {
		return new ItemStack(ModItems.magicIngot, 1, 0);
	}

	if (i == ModItems.magicDust.itemID && k == 1 && j == Item.ingotIron.itemID && l == 0 || i == Item.ingotIron.itemID && k == 0 && j == ModItems.magicDust.itemID && l == 1) {
		return new ItemStack(ModItems.magicIngot, 1, 1);
	}

	if (i == ModItems.magicDust.itemID && k == 2 && j == Item.ingotIron.itemID && l == 0 || i == Item.ingotIron.itemID && k == 0 && j == ModItems.magicDust.itemID && l == 2) {
		return new ItemStack(ModItems.magicIngot, 1, 2);
	}

	return null;

}

}

Posted

I can think of two possible reasons for this:

 

1) Items are only getting put into your tile entity on the client side, not the server side.

2) Your tile entity's onInventoryChanged() method is not getting called when it should be.

Posted

The most obvious problem I saw by skim reading is that you are saving the itemstacks in the slots to "Items" and "Slots". The Vanilla furnace code uses these names and, since the Vanilla furnace has nothing in them, they are returning null. Try changing these names to make them unique (perhaps add your mod ID or just change the names).

Posted
  On 8/26/2013 at 8:27 AM, MrrGingerNinja said:

The most obvious problem I saw by skim reading is that you are saving the itemstacks in the slots to "Items" and "Slots". The Vanilla furnace code uses these names and, since the Vanilla furnace has nothing in them, they are returning null. Try changing these names to make them unique (perhaps add your mod ID or just change the names).

 

I would be inclined to agree with you on this one.

 

@OP: Try changing them to "MagicInfuserItems" and "MagicInfuserSlots". Or you could do as MrrGingerNinja says and use your modid. But i would personally would do something more like: "*Modid*MagicInfuserItems" and "*Modid*MagicInfuserSlots" ( where *Modid* is your mod's modid ).

 

But really, it is up to you.

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Posted
  On 8/26/2013 at 9:14 AM, Mew said:

  Quote

The most obvious problem I saw by skim reading is that you are saving the itemstacks in the slots to "Items" and "Slots". The Vanilla furnace code uses these names and, since the Vanilla furnace has nothing in them, they are returning null. Try changing these names to make them unique (perhaps add your mod ID or just change the names).

 

I would be inclined to agree with you on this one.

 

@OP: Try changing them to "MagicInfuserItems" and "MagicInfuserSlots". Or you could do as MrrGingerNinja says and use your modid. But i would personally would do something more like: "*Modid*MagicInfuserItems" and "*Modid*MagicInfuserSlots" ( where *Modid* is your mod's modid ).

 

But really, it is up to you.

 

i donot agree lol ...

 

iv made a 2 input furnace  awhile back .. and i dotn see this working at all .. your recipes..

in my eyes wont work in this way you need to make the recipes for 2 inputs also..

 

and as for the rest the tile entity is n your own styl not perfectly sure if that is perfectly working or not i think it might when you got the recipe set up correctly ..

Posted

The recipes works without any problems, it takes information from both slots and checks if they are the item they need to be. The only thing that is not working is the writing to NBT, it gives an error on the super.writeToNBT(nbttagcompound); line in the TileEntity.

 

BTW: Changing the names did nothing.

Posted

this is what i use in my tile entity:

 

 

  Reveal hidden contents

 

 

this worked for mine :) ..

  • 2 months later...
Posted

Sorry if Im late, but I had a very similar problem. In your log file it says this:

  Quote
java.lang.RuntimeException: class net.blazecoding.magicpowders.tileentity.TileEntityMagicInfuser is missing a mapping! This is a bug!

This means Minecraft doesn't know the save id of the Tile Entity. You need to assign it. Idk if Forge has a different way of doing it, but I added this line to the mod initiator:

TileEntity.addMapping(TileEntityFoo.class, "Foo");

The first parameter is your TileEntityClass, and the second parameter is the save game id.

 

Note: I actually didn't have a problem, but when I see a stack trace in the Eclipse console, I know somethings wrong

Posted

Yeah Forge has a 'different' way of doing it:

GameRegistry.registerTileEntity(Class<? extends TileEntity>, String id);

 

Which calls in the end the same method you mentioned PisuCat.

public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id)
{
     TileEntity.addMapping(tileEntityClass, id);
}

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

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



×
×
  • Create New...

Important Information

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