Jump to content

Recommended Posts

Posted

I was goign to export my mod, but when doing the gradlew build command this error comes out

Ka3se7j.png

 

This is the class referenced by the error, in eclipse and in the game it gives me no error

package com.mineworld.blocks.ores;

import java.util.List;
import java.util.Random;

import com.mineworld.core.MWMetadataBlocks;
import com.mineworld.core.MWTabs;

import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public abstract class BlockOreSlab extends BlockSlab {
public static final PropertyBool SEAMLESS = PropertyBool.create("seamless");
public static final PropertyEnum<BlockOreSlab.EnumType> VARIANT = PropertyEnum.<BlockOreSlab
		.EnumType> create("variant", BlockOreSlab.EnumType.class);

public BlockOreSlab() {
	super(Material.rock);
	IBlockState iblockstate = this.blockState.getBaseState();

	if (this.isDouble()) {
		iblockstate = iblockstate.withProperty(SEAMLESS, Boolean.valueOf(false));
	} else {
		iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
	}

	this.setDefaultState(iblockstate.withProperty(VARIANT, BlockOreSlab.EnumType.RUBY));
	this.setCreativeTab(MWTabs.tabBlock);
	this.setHardness(2.0F);
	this.setResistance(15.0F);
	this.useNeighborBrightness = !this.isDouble();
}

/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
	return Item.getItemFromBlock(MWMetadataBlocks.ore_slab);
}

public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
	return new ItemStack(MWMetadataBlocks.ore_slab, 1,
			((BlockOreSlab.EnumType) state.getValue(VARIANT)).getMetadata());
}

/**
 * Returns the slab block name with the type associated with it
 */
public String getUnlocalizedName(int meta) {
	return "tile." + BlockOreSlab.EnumType.byMetadata(meta).getName() + "_slab";
}

public IProperty<?> getVariantProperty() {
	return VARIANT;
}

public Comparable<?> getTypeForItem(ItemStack stack) {
	return BlockOreSlab.EnumType.byMetadata(stack.getMetadata() & 7);
}

/**
 * returns a list of blocks with the same ID, but different meta (eg: wood
 * returns 4 blocks)
 */
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) {
	if (itemIn != Item.getItemFromBlock(MWMetadataBlocks.ore_double_slab)) {
		for (BlockOreSlab.EnumType blockstoneslab$enumtype : BlockOreSlab.EnumType.values()) {
			list.add(new ItemStack(itemIn, 1, blockstoneslab$enumtype.getMetadata()));
		}
	}
}

/**
 * Convert the given metadata into a BlockState for this Block
 */
public IBlockState getStateFromMeta(int meta) {
	IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT,
			BlockOreSlab.EnumType.byMetadata(meta & 7));

	if (this.isDouble()) {
		iblockstate = iblockstate.withProperty(SEAMLESS, Boolean.valueOf((meta &  != 0));
	} else {
		iblockstate = iblockstate.withProperty(HALF,
				(meta &  == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP);
	}

	return iblockstate;
}

/**
 * Convert the BlockState into the correct metadata value
 */
public int getMetaFromState(IBlockState state) {
	int i = 0;
	i = i | ((BlockOreSlab.EnumType) state.getValue(VARIANT)).getMetadata();

	if (this.isDouble()) {
		if (((Boolean) state.getValue(SEAMLESS)).booleanValue()) {
			i |= 8;
		}
	} else if (state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP) {
		i |= 8;
	}

	return i;
}

protected BlockStateContainer createBlockState() {
	return this.isDouble() ? new BlockStateContainer(this, new IProperty[] { SEAMLESS, VARIANT })
			: new BlockStateContainer(this, new IProperty[] { HALF, VARIANT });
}

/**
 * Gets the metadata of the item this Block can drop. This method is called
 * when the block gets destroyed. It returns the metadata of the dropped
 * item based on the old metadata of the block.
 */
public int damageDropped(IBlockState state) {
	return ((BlockOreSlab.EnumType) state.getValue(VARIANT)).getMetadata();
}

/**
 * Get the MapColor for this Block and the given BlockState
 */
public MapColor getMapColor(IBlockState state) {
	return ((BlockOreSlab.EnumType) state.getValue(VARIANT)).getMapColor();
}

@Override
public boolean canProvidePower(IBlockState state) {
	return state.getValue(VARIANT).equals(BlockOreSlab.EnumType.COPPER)
			|| state.getValue(VARIANT).equals(BlockOreSlab.EnumType.BRONZE);
}

@Override
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
	if (blockState.getValue(VARIANT).equals(BlockOreSlab.EnumType.COPPER))
		return 10;
	else if (blockState.getValue(VARIANT).equals(BlockOreSlab.EnumType.BRONZE))
		return 5;
	else
		return 0;
}

@Override
public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side) {
	return side == EnumFacing.UP;
}

public static enum EnumType implements IStringSerializable {
	RUBY(0, MapColor.tntColor, "ruby"), SAPPHIRE(1, MapColor.blueColor, "sapphire"), COPPER(2, MapColor.tntColor,
			"copper"), BRONZE(3, MapColor.tntColor, "bronze"), SILVER(4, MapColor.lightBlueColor,
					"silver"), ALUMINIUM(5, MapColor.silverColor, "aluminium"), WHITE_MARBLE(6,
							MapColor.quartzColor,
							"white_marble"), PINK_MARBLE(7, MapColor.pinkColor, "pink_marble");

	private static final BlockOreSlab.EnumType[] META_LOOKUP = new BlockOreSlab.EnumType[values().length];
	private final int meta;
	private final MapColor color;
	private final String name;
	private final String unlocalizedName;

	private EnumType(int meta, MapColor mapColor, String name) {
		this(meta, mapColor, name, name);
	}

	private EnumType(int meta, MapColor mapColor, String name, String unlocalizedName) {
		this.meta = meta;
		this.color = mapColor;
		this.name = name;
		this.unlocalizedName = unlocalizedName;
	}

	public int getMetadata() {
		return this.meta;
	}

	public MapColor getMapColor() {
		return this.color;
	}

	public String toString() {
		return this.name;
	}

	public static BlockOreSlab.EnumType byMetadata(int meta) {
		if (meta < 0 || meta >= META_LOOKUP.length) {
			meta = 0;
		}

		return META_LOOKUP[meta];
	}

	public String getName() {
		return this.name;
	}

	public String getUnlocalizedName() {
		return this.unlocalizedName;
	}

	static {
		for (BlockOreSlab.EnumType type : values()) {
			META_LOOKUP[type.getMetadata()] = type;
		}
	}
}
}

 

It's almost the same code i used in 1.8 and when building there it doesn't give me this error, any idea about what it's causing this? :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

1: are you Cd-ing to the right folder when you type gradlew build

2: not all 1.8 code works for 1.9 I have had to change all mine so you probably need to also

3: if you are cd-ing in the right folder either reinstall java SE dev kit, re-type gradlew setupDecompWorkspace, or just make a new mod folder and transfer your code

Posted

1: yes, i'm cd-ing in the right folder

2: i don't know what to change, since in game the slabs works as well

3: I've just created a new folder with a fresh installation of the Recommended 1.9 forge release and then copied the src code from previous folder (previous 1.9 forge release)

 

EDIT: looks like the problem is this

public static final PropertyEnum<BlockOreSlab.EnumType> VARIANT = PropertyEnum.<BlockOreSlab
		.EnumType> create("variant", BlockOreSlab.EnumType.class);

 

because instead formatting like this

public static final PropertyEnum<BlockOreSlab.EnumType> VARIANT = PropertyEnum.<BlockOreSlab.EnumType> create("variant", BlockOreSlab.EnumType.class);

let me export the mod :) Thanks everybody for the help :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

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.