Jump to content

Recommended Posts

Posted

Hi guys,

When i put @Override above a method the retrun an error .

My code :

package fr.darkprod.archymod.blocks;

import javax.annotation.Nullable;

import fr.darkprod.archymod.ArchyMod;
import fr.darkprod.archymod.tiles.TileInventoryFurnace;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;


public class BlockInventoryFurnace extends BlockContainer
{
	public BlockInventoryFurnace(String name,float resistance, float hardness)
	{
		super(Material.ROCK);
		this.setCreativeTab(ArchyMod.ArchyMod);
		setRegistryName(name);
		setUnlocalizedName(name);
		setResistance(resistance);
		setHardness(hardness);
	}

	// Called when the block is placed or loaded client side to get the tile entity for the block
	// Should return a new instance of the tile entity for the block
	@Override
	public TileEntity createNewTileEntity(World worldIn, int meta) {
		return new TileInventoryFurnace();
	}

	@Override
	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
		// Uses the gui handler registered to your mod to open the gui for the given gui id
		// open on the server side only  (not sure why you shouldn't open client side too... vanilla doesn't, so we better not either)
		if (worldIn.isRemote) return true;

		playerIn.openGui(ArchyMod.instance, ArchyMod.GUI_FURNACE, worldIn, pos.getX(), pos.getY(), pos.getZ());
		return true;
	}


	// This is where you can do something when the block is broken. In this case drop the inventory's contents
	@Override
	public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
		TileEntity tileEntity = worldIn.getTileEntity(pos);
		if (tileEntity instanceof IInventory) {
			InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileEntity);
		}

//		if (inventory != null){
//			// For each slot in the inventory
//			for (int i = 0; i < inventory.getSizeInventory(); i++){
//				// If the slot is not empty
//				if (inventory.getStackInSlot(i) != null)
//				{
//					// Create a new entity item with the item stack in the slot
//					EntityItem item = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, inventory.getStackInSlot(i));
//
//					// Apply some random motion to the item
//					float multiplier = 0.1f;
//					float motionX = worldIn.rand.nextFloat() - 0.5f;
//					float motionY = worldIn.rand.nextFloat() - 0.5f;
//					float motionZ = worldIn.rand.nextFloat() - 0.5f;
//
//					item.motionX = motionX * multiplier;
//					item.motionY = motionY * multiplier;
//					item.motionZ = motionZ * multiplier;
//
//					// Spawn the item in the world
//					worldIn.spawnEntityInWorld(item);
//				}
//			}
//
//			// Clear the inventory so nothing else (such as another mod) can do anything with the items
//			inventory.clear();
//		}

		// Super MUST be called last because it removes the tile entity
		super.breakBlock(worldIn, pos, state);
	}

	@Override
	public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
	{
		TileEntity tileEntity = worldIn.getTileEntity(pos);
		if (tileEntity instanceof TileInventoryFurnace) {
			TileInventoryFurnace tileInventoryFurnace = (TileInventoryFurnace)tileEntity;
			int burningSlots = tileInventoryFurnace.numberOfBurningFuelSlots();
			burningSlots = MathHelper.clamp(burningSlots, 0, 4);
			return getDefaultState().withProperty(BURNING_SIDES_COUNT, burningSlots);
		}
		return state;
	}

	@Override
	public IBlockState getStateFromMeta(int meta)
	{
		return this.getDefaultState();
//		return this.getDefaultState().withProperty(BURNING_SIDES_COUNT, Integer.valueOf(meta));
	}

	@Override
	public int getMetaFromState(IBlockState state)
	{
		return 0;
//		return ((Integer)state.getValue(BURNING_SIDES_COUNT)).intValue();
	}

	// necessary to define which properties your blocks use
	// will also affect the variants listed in the blockstates model file.  See MBE03 for more info.
	@Override
	protected BlockStateContainer createBlockState()
	{
		return new BlockStateContainer(this, new IProperty[] {BURNING_SIDES_COUNT});
	}

	public static final PropertyInteger BURNING_SIDES_COUNT = PropertyInteger.create("burning_sides_count", 0, 4);

					// change the furnace emitted light ("block light") depending on how many slots are burning
	private static final int FOUR_SIDE_LIGHT_VALUE = 15; // light value for four sides burning
	private static final int ONE_SIDE_LIGHT_VALUE = 8;  // light value for a single side burning

  @Override
	public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
		int lightValue = 0;
		IBlockState blockState = getActualState(getDefaultState(), world, pos);
		int burningSides = (Integer)blockState.getValue(BURNING_SIDES_COUNT);

   	if (burningSides == 0) {
			lightValue = 0;
		} else {
			// linearly interpolate the light value depending on how many slots are burning
			lightValue = ONE_SIDE_LIGHT_VALUE + (int)((FOUR_SIDE_LIGHT_VALUE - ONE_SIDE_LIGHT_VALUE) / (4.0 - 1.0) * burningSides);
		}
		lightValue = MathHelper.clamp(lightValue, 0, FOUR_SIDE_LIGHT_VALUE);
		return lightValue;
	}

	// the block will render in the SOLID layer.  See http://greyminecraftcoder.blogspot.co.at/2014/12/block-rendering-18.html for more information.
	@SideOnly(Side.CLIENT)
	public BlockRenderLayer getBlockLayer()
	{
		return BlockRenderLayer.SOLID;
	}

	// used by the renderer to control lighting and visibility of other blocks.
	// set to false because this block doesn't fill the entire 1x1x1 space
	@Override
	public boolean isOpaqueCube(IBlockState iBlockState) {
		return false;
	}

	// used by the renderer to control lighting and visibility of other blocks, also by
	// (eg) wall or fence to control whether the fence joins itself to this block
	// set to false because this block doesn't fill the entire 1x1x1 space
	@Override
	public boolean isFullCube(IBlockState iBlockState) {
		return false;
	}

	// render using a BakedModel
  // required because the default (super method) is INVISIBLE for BlockContainers.
	@Override
	public EnumBlockRenderType getRenderType(IBlockState iBlockState) {
		return EnumBlockRenderType.MODEL;
	}
}

and the screenshot :

Capture.PNG

Posted

Go look at the block class and find what the new signature is for that method.

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

 

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

 

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

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.