Jump to content

createNewTileEntity issue


INTENSS

Recommended Posts

I'm working on a new machine and when I go to create the createNewTileEntity() method its keeps giving me and error

must override or implement a supertype method

 

I've never had this happen with any other machine I've built in the past and I'm plugging along in the same order of writing as I do with  every machine. I'll post my block class and my Tileentity class below. Now neither one of them are finished all the methods needed to get this Gui to work should be completed. I can post the gui, handler, and container classes if needed but this error has to do with calling the tile entity. and YES everything is registered.

and help would be appreciated

 

block class:

import java.util.Random;

import AdvancedEnergy.Main;
import AdvancedEnergy.tileentities.MetallicInfuserTE;
import AdvancedEnergy.tileentities.OreProTE;
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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class MetallicInfuser extends Block {

private final Random ran = new Random();
private final boolean isActive;
private static boolean keepInventory = false;

@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconFront;

public MetallicInfuser(boolean state) {
	super(Material.iron);

	this.isActive = state;
}

@SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister register)
    {
        this.blockIcon = register.registerIcon("ae:infuser_side");
        this.iconFront = register.registerIcon(this.isActive ? "ae:infuser_on" : "ae:infuser_off");
        this.iconTop = register.registerIcon("ae:infuser_side");
    }

@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.placeBlock(world, x, y, z);
}

private void placeBlock(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 i = 3;
		if (block1.func_149730_j() && !block2.func_149730_j()) {
			i = 3;
		}

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

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

		if (block4.func_149730_j() && !block3.func_149730_j()) {
			i = 4;
		}
		world.setBlockMetadataWithNotify(x, y, z, i, 2);
	}
}

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack) {
	int i = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 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()) {
		((MetallicInfuserTE)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName());
	}
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
	if (!world.isRemote) {
		FMLNetworkHandler.openGui(player, Main.instance, Main.guiIDMetallicInfuser, world, x, y, z);
	} 
	return true;
}

@Override
public TileEntity createNewTileEntity(World world, int i) { // < --------- ERROR HAPPENS HERE
	return new MetallicInfuserTE();
}
}

 

this is the TileEntity class so far. All tha6ts needed should be completed

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import AdvancedEnergy.machines.OrePro;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class MetallicInfuserTE extends TileEntity implements ISidedInventory {

private ItemStack slots[];

private int infuserPower;
private int infuserCookTime;
private String customName;

public MetallicInfuserTE() {
	slots = new ItemStack[10];
}

@Override
public int getSizeInventory() {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public ItemStack getStackInSlot(int p_70301_1_) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
	// TODO Auto-generated method stub

}

public void setGuiDisplayName(String name) {
	customName = name;
}

@Override
public String getInventoryName() {
	return hasCustomInventoryName() ? customName : "container.Metallic Infuser";
}

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

@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.0D;
	}
}

@Override
public void openInventory() {
	// TODO Auto-generated method stub

}

@Override
public void closeInventory() {
	// TODO Auto-generated method stub

}

@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
	// TODO Auto-generated method stub
	return false;
}

@Override
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
	// TODO Auto-generated method stub
	return false;
}

@Override
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
	// TODO Auto-generated method stub
	return false;
}
}

 

Hope someone can maybe see something I missed.

 

Link to comment
Share on other sites

public class MetallicInfuser extends Block {

This needs to extend BlockContainer.

Not true.

 

The issue is that the method is called createTileEntity, not createNewTileEntity. Also note that you will need hasTileEntity as well.

 

There might be multiple ways to achieve this but I have already done this in my Realistic Deaths mod and the code uses createNewTileEntity instead of createTileEntity.

Link to comment
Share on other sites

thank you deadrecon98 I COMPLETELY overlooked that and it fixed my issue. I went over the code, heck I don't know how many times and simply missed it.

 

I tried creatTileEntity just to test it and that did not work just wanted to let you all know, at least not the with the way I have things configured.

 

Thanks for all those who replied.

Link to comment
Share on other sites

I am not wrong.

People just don't read what I say. If you don't implement ITileEntityProvider or extend BlockContainer (which comes down to the same thing) you need hasTileEntity to tell Minecraft that your block, well, has a TileEntity.

 

Lol, I had no idea they were (for this reason) the same thing.

Link to comment
Share on other sites

I am not wrong.

People just don't read what I say. If you don't implement ITileEntityProvider or extend BlockContainer (which comes down to the same thing) you need hasTileEntity to tell Minecraft that your block, well, has a TileEntity.

Well that means I was proved wrong. shocked.gif

I told you it happens a lot.cheesy.gif

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

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.