Jump to content

Recommended Posts

Posted

I get an error on

 

BlockBreaker

saying that "BlockBreaker cannot be resolved to a varieable", does anyone know how to fix this?

 

package com.MonstrousApple.mod.render;

import com.MonstrousApple.mod.MAGlobal;
import com.MonstrousApple.mod.blocks.MABlocks;
import com.MonstrousApple.mod.handler.MAEnumHandler;
import com.MonstrousApple.mod.ores.MAOres;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MAMetablockRender {

public static void registerBlockRender() {

	//Meta Blocks
	for(int i = 0; i < MAEnumHandler.BlockBreakerTypes.values().length; i++) {
		regBlock(BlockBreaker, i, MAEnumHandler.BlockBreakerTypes.values()[i].getName() + "BlockBreaker");
	}
}

public static void regBlock(Block block, int meta, String fileName) {
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta,
			new ModelResourceLocation(MAGlobal.MOD_ID + ":" + fileName, "inventory"));
}
}

Posted

I get an error on

 

BlockBreaker

saying that "BlockBreaker cannot be resolved to a varieable", does anyone know how to fix this?

 

package com.MonstrousApple.mod.render;

import com.MonstrousApple.mod.MAGlobal;
import com.MonstrousApple.mod.blocks.MABlocks;
import com.MonstrousApple.mod.handler.MAEnumHandler;
import com.MonstrousApple.mod.ores.MAOres;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MAMetablockRender {

public static void registerBlockRender() {

	//Meta Blocks
	for(int i = 0; i < MAEnumHandler.BlockBreakerTypes.values().length; i++) {
		regBlock(BlockBreaker, i, MAEnumHandler.BlockBreakerTypes.values()[i].getName() + "BlockBreaker");
	}
}

public static void regBlock(Block block, int meta, String fileName) {
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta,
			new ModelResourceLocation(MAGlobal.MOD_ID + ":" + fileName, "inventory"));
}
}

Posted

Well, how about actually having such variable? You are using name for variable that doesn't exist, what did you expect? Porgramming 101 (not even java).

1.7.10 is no longer supported by forge, you are on your own.

Posted

Well, how about actually having such variable? You are using name for variable that doesn't exist, what did you expect? Porgramming 101 (not even java).

1.7.10 is no longer supported by forge, you are on your own.

Posted

Well I thought I did... here's my class's:

 

MAEnumHandler:

package com.MonstrousApple.mod.handler;

import net.minecraft.util.IStringSerializable;

public class MAEnumHandler {

public enum BlockBreakerTypes implements IStringSerializable {

	Wood(0, "Wood"),
	Stone(1, "Stone"),
	Iron(2, "Iron"),
	Gold(3, "Gold"),
	Diamond(4, "Diamond"),
	Copper(5, "Copper");


	private int ID;
	private String name;

	private BlockBreakerTypes(int ID, String name) {
		this.ID = ID;
		this.name= name;
	}

	public String getName(){
		return name;
	}

	public int getID() {
		return ID;
	}

	@Override
	public String toString() {
		return getName();
	}
}

}

 

MABlocks:

package com.MonstrousApple.mod.blocks;

import com.MonstrousApple.mod.blocks.crops.MABananaCropDrop;
import com.MonstrousApple.mod.blocks.crops.MACherryCropDrop;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MABlocks {

//Blocks
public static Block CompressedStone;

public static Block BlockBreaker;


public static void initBlocks() {

	//Blocks; GameResistry.registerBlock (Name of Block = new MABlock("Name of Block", Material.rock, hardness, resistance), "Name of Block");
	//Harvest Levels; 0 = Wooden/Gold Can Mine || 1 = Stone Can Mine || 2 = Iron Can Mine || 3 = Diamond Can Mine.

	GameRegistry.registerBlock(CompressedStone = new MABlock("CompressedStone", Material.rock, 3, 20), "CompressedStone");
	CompressedStone.setHarvestLevel("pickaxe", 0);

	GameRegistry.registerBlock(BlockBreaker, MAMetaBlocks.class, "BlockBreaker");
}
}

 

 

MABlockBreaker:

 

package com.MonstrousApple.mod.blocks;

import java.util.List;

import com.MonstrousApple.mod.MAGlobal;
import com.MonstrousApple.mod.handler.MAEnumHandler;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;


public class MABlockBreaker extends Block implements IMetaBlockName {

public static final PropertyEnum TYPE = PropertyEnum.create("TYPE", MAEnumHandler.BlockBreakerTypes.class);

public MABlockBreaker(String unlocalizedName) {
	super(Material.rock);
	this.setUnlocalizedName(unlocalizedName);
	this.setCreativeTab(MAGlobal.maCreativeTabBlocks);
	this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Wood));
}

@Override
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
	list.add(new ItemStack(item, 1, 0));
	list.add(new ItemStack(item, 1, 1));
	list.add(new ItemStack(item, 1, 2));
	list.add(new ItemStack(item, 1, 3));
	list.add(new ItemStack(item, 1, 4));
	list.add(new ItemStack(item, 1, 5));
}

@Override
protected BlockState createBlockState() {
	return new BlockState(this, new IProperty[] { TYPE });
}

@Override
public IBlockState getStateFromMeta(int meta) {
	if(meta == 0) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Wood);
	}
	if(meta == 1) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Stone);
	}
	if(meta == 2) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Iron);
	}
	if(meta == 3) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Gold);
	}
	if(meta == 4) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Diamond);
	}
	if(meta == 5) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Copper);
	}
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Wood);
}

@Override
public int getMetaFromState(IBlockState state) {
	MAEnumHandler.BlockBreakerTypes type = (MAEnumHandler.BlockBreakerTypes) state.getValue(TYPE);
	return type.getID();
}

@Override
public int damageDropped(IBlockState state) {
	return this.getMetaFromState(state);
}

@Override
public String getSpecialName(ItemStack stack) {
	if(stack.getItemDamage() == 0) {
		return "Wood";
	}
	if(stack.getItemDamage() == 1) {
		return "Stone";
	}
	if(stack.getItemDamage() == 2) {
		return "Iron";
	}
	if(stack.getItemDamage() == 3) {
		return "Gold";
	}
	if(stack.getItemDamage() == 4) {
		return "Diamond";
	}
	if(stack.getItemDamage() == 5) {
		return "Copper";
	}
	return "Wood";
}

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
	return new ItemStack(Item.getItemFromBlock(this), 1, this.getMetaFromState(world.getBlockState(pos)));
}

}

 

 

IMetaBlockName:

 

package com.MonstrousApple.mod.blocks;

import net.minecraft.item.ItemStack;

public interface IMetaBlockName {

String getSpecialName(ItemStack stack);

}

 

 

MAMetaBlocks:

 

package com.MonstrousApple.mod.blocks;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

public class MAMetaBlocks extends ItemBlock {

public MAMetaBlocks(Block block) {
	super(block);
	if(!(block instanceof IMetaBlockName)) {
		throw new IllegalArgumentException(String.format("The given Block %s is not an instance of IMetaBlockName", block.getUnlocalizedName()));
	}
	this.setMaxDamage(0);
	this.setHasSubtypes(true);
}

public int getMetaData(int damage) {
	return damage;
}

@Override
public String getUnlocalizedName(ItemStack stack) {
	return super.getUnlocalizedName(stack) + "." + ((IMetaBlockName)this.block).getSpecialName(stack);
}

}

 

 

MAMetaBlockRender:

 

package com.MonstrousApple.mod.render;

import com.MonstrousApple.mod.MAGlobal;
import com.MonstrousApple.mod.blocks.MABlocks;
import com.MonstrousApple.mod.handler.MAEnumHandler;
import com.MonstrousApple.mod.ores.MAOres;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MAMetablockRender {

public static void registerBlockRender() {

	//Meta Blocks
	for(int i = 0; i < MAEnumHandler.BlockBreakerTypes.values().length; i++) {
		regBlock(BlockBreaker, i, MAEnumHandler.BlockBreakerTypes.values()[i].getName() + "BlockBreaker");
	}
}

public static void regBlock(Block block, int meta, String fileName) {
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta,
			new ModelResourceLocation(MAGlobal.MOD_ID + ":" + fileName, "inventory"));
}
}

Posted

Well I thought I did... here's my class's:

 

MAEnumHandler:

package com.MonstrousApple.mod.handler;

import net.minecraft.util.IStringSerializable;

public class MAEnumHandler {

public enum BlockBreakerTypes implements IStringSerializable {

	Wood(0, "Wood"),
	Stone(1, "Stone"),
	Iron(2, "Iron"),
	Gold(3, "Gold"),
	Diamond(4, "Diamond"),
	Copper(5, "Copper");


	private int ID;
	private String name;

	private BlockBreakerTypes(int ID, String name) {
		this.ID = ID;
		this.name= name;
	}

	public String getName(){
		return name;
	}

	public int getID() {
		return ID;
	}

	@Override
	public String toString() {
		return getName();
	}
}

}

 

MABlocks:

package com.MonstrousApple.mod.blocks;

import com.MonstrousApple.mod.blocks.crops.MABananaCropDrop;
import com.MonstrousApple.mod.blocks.crops.MACherryCropDrop;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MABlocks {

//Blocks
public static Block CompressedStone;

public static Block BlockBreaker;


public static void initBlocks() {

	//Blocks; GameResistry.registerBlock (Name of Block = new MABlock("Name of Block", Material.rock, hardness, resistance), "Name of Block");
	//Harvest Levels; 0 = Wooden/Gold Can Mine || 1 = Stone Can Mine || 2 = Iron Can Mine || 3 = Diamond Can Mine.

	GameRegistry.registerBlock(CompressedStone = new MABlock("CompressedStone", Material.rock, 3, 20), "CompressedStone");
	CompressedStone.setHarvestLevel("pickaxe", 0);

	GameRegistry.registerBlock(BlockBreaker, MAMetaBlocks.class, "BlockBreaker");
}
}

 

 

MABlockBreaker:

 

package com.MonstrousApple.mod.blocks;

import java.util.List;

import com.MonstrousApple.mod.MAGlobal;
import com.MonstrousApple.mod.handler.MAEnumHandler;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;


public class MABlockBreaker extends Block implements IMetaBlockName {

public static final PropertyEnum TYPE = PropertyEnum.create("TYPE", MAEnumHandler.BlockBreakerTypes.class);

public MABlockBreaker(String unlocalizedName) {
	super(Material.rock);
	this.setUnlocalizedName(unlocalizedName);
	this.setCreativeTab(MAGlobal.maCreativeTabBlocks);
	this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Wood));
}

@Override
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
	list.add(new ItemStack(item, 1, 0));
	list.add(new ItemStack(item, 1, 1));
	list.add(new ItemStack(item, 1, 2));
	list.add(new ItemStack(item, 1, 3));
	list.add(new ItemStack(item, 1, 4));
	list.add(new ItemStack(item, 1, 5));
}

@Override
protected BlockState createBlockState() {
	return new BlockState(this, new IProperty[] { TYPE });
}

@Override
public IBlockState getStateFromMeta(int meta) {
	if(meta == 0) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Wood);
	}
	if(meta == 1) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Stone);
	}
	if(meta == 2) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Iron);
	}
	if(meta == 3) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Gold);
	}
	if(meta == 4) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Diamond);
	}
	if(meta == 5) {
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Copper);
	}
	return this.getDefaultState().withProperty(TYPE, MAEnumHandler.BlockBreakerTypes.Wood);
}

@Override
public int getMetaFromState(IBlockState state) {
	MAEnumHandler.BlockBreakerTypes type = (MAEnumHandler.BlockBreakerTypes) state.getValue(TYPE);
	return type.getID();
}

@Override
public int damageDropped(IBlockState state) {
	return this.getMetaFromState(state);
}

@Override
public String getSpecialName(ItemStack stack) {
	if(stack.getItemDamage() == 0) {
		return "Wood";
	}
	if(stack.getItemDamage() == 1) {
		return "Stone";
	}
	if(stack.getItemDamage() == 2) {
		return "Iron";
	}
	if(stack.getItemDamage() == 3) {
		return "Gold";
	}
	if(stack.getItemDamage() == 4) {
		return "Diamond";
	}
	if(stack.getItemDamage() == 5) {
		return "Copper";
	}
	return "Wood";
}

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) {
	return new ItemStack(Item.getItemFromBlock(this), 1, this.getMetaFromState(world.getBlockState(pos)));
}

}

 

 

IMetaBlockName:

 

package com.MonstrousApple.mod.blocks;

import net.minecraft.item.ItemStack;

public interface IMetaBlockName {

String getSpecialName(ItemStack stack);

}

 

 

MAMetaBlocks:

 

package com.MonstrousApple.mod.blocks;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

public class MAMetaBlocks extends ItemBlock {

public MAMetaBlocks(Block block) {
	super(block);
	if(!(block instanceof IMetaBlockName)) {
		throw new IllegalArgumentException(String.format("The given Block %s is not an instance of IMetaBlockName", block.getUnlocalizedName()));
	}
	this.setMaxDamage(0);
	this.setHasSubtypes(true);
}

public int getMetaData(int damage) {
	return damage;
}

@Override
public String getUnlocalizedName(ItemStack stack) {
	return super.getUnlocalizedName(stack) + "." + ((IMetaBlockName)this.block).getSpecialName(stack);
}

}

 

 

MAMetaBlockRender:

 

package com.MonstrousApple.mod.render;

import com.MonstrousApple.mod.MAGlobal;
import com.MonstrousApple.mod.blocks.MABlocks;
import com.MonstrousApple.mod.handler.MAEnumHandler;
import com.MonstrousApple.mod.ores.MAOres;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class MAMetablockRender {

public static void registerBlockRender() {

	//Meta Blocks
	for(int i = 0; i < MAEnumHandler.BlockBreakerTypes.values().length; i++) {
		regBlock(BlockBreaker, i, MAEnumHandler.BlockBreakerTypes.values()[i].getName() + "BlockBreaker");
	}
}

public static void regBlock(Block block, int meta, String fileName) {
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta,
			new ModelResourceLocation(MAGlobal.MOD_ID + ":" + fileName, "inventory"));
}
}

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.