Jump to content

Recommended Posts

Posted

Ok what I ask is simple, how would I go about using an ENUM file listing to be used successfully with making blocks with subBlocks? I ask this because I have gotten it to work with items, (added almost 32 subitems), but for blocks I am a bit lost? How can I get it to work? Probably a stupid mistake.

 

Here is my working item's files:

 

 

public enum EnumCraftSetType {
LENS("lens", "Lens"),
EYEPIECE("eyePiece", "Eye Piece"),
STONECOG("stonecog", "Stone Cog"),
LOOP("loop", "Metal Ring"),
CHAIN("chain", "Chain"),
SPROCKET("sprocket", "Sprocket"),
JOINT("joint","Joint"),
SHARP("sharp", "Sharpened Point"),
SMALLPLATE("smallPlate", "Small Plate"),
CYLINDER("cylinder", "Cylinder"),
ROD("rod", "Rod"),
PISTON("piston", "Tiny Piston"),
ACTUATOR("actuator", "Soul Actuator"),
CANVAS("canvas", "Canvas"),
WING("wing", "Wing"),
PASSIVE("passive", "Controller (Passive)"),
AGGRESSIVE("aggressive", "Controller (Aggressive)"),
JAW("jaw", "Jaw"),
SENSOR("sensor", "NVS"),
DRILL("drill", "Pickaxe Module"),
ROLLERCHAIN("rollerChain", "Roller Chain"),
SMALLHEAD("wHead", "Small Head"),
SMALLBODY("smallBod", "Small Body"),
TOTEHEAD("totehead", "Tote Head"),
MIDBODY("medBod", "Greater Body"),
SMALLLEG("smallLeg", "Small Leg"),
SENTRYHEAD("sHead", "Sentry Head"),
SALT("salt", "Salt"),
SURF("sulf", "Sulf"),
FACTOTUMHEAD("factotumhead", "Factotum Head"),
FACTOTUMCHUNK("furnaceChunk", "Factotum Chunk"),
BLUECORE("automatonCore", "Blue Core"),
REDCORE("superCore", "Red Core"),
PLANTMATTER("planty", "Plant Matter"),
PARTICULATE("bitty", "Cybernetic Particulate"),
BIONICCONGLOMERATE("ABC", "Adaptive Bionic Conglomerate");

public final String name;
public final String fullname;

EnumCraftSetType(String par1, String par2) {
	this.name = par1; //png name
	this.fullname = par2;
}

 

public class ItemCraftSet extends Item{

private IIcon icons[];

public ItemCraftSet(){
	super();
	this.setHasSubtypes(true);
	this.setMaxDamage(0);
	this.setUnlocalizedName("am:craftset");
	this.setCreativeTab(AM_CreativeTabs.tabItem);

}

@Override
public IIcon getIconFromDamage(int par1){
	int i = MathHelper.clamp_int(par1, 0, EnumCraftSetType.values().length-1);
	return icons[i];
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconregister){
	icons = new IIcon[EnumCraftSetType.values().length];
	for(int var4 = 0; var4 < EnumCraftSetType.values().length; var4++){
		icons[var4] = iconregister.registerIcon("am:"+EnumCraftSetType.values()[var4].name);
	}
}

@Override
public void getSubItems(Item par1, CreativeTabs creativeTabs,
		List list){
	for(int var4 = 0;var4 < EnumCraftSetType.values().length; var4++){
		list.add(new ItemStack(par1, 1, var4));
	}
}

@Override
public String getUnlocalizedName(ItemStack itemStack){
	return super.getUnlocalizedName(itemStack) + "."
			+ EnumCraftSetType.values()[itemStack.getItemDamage()].name;
}
}

 

 

 

Here is the non working subBlock files:

 

 

public enum EnumCropType {

WHEAT("wheat", "Wheat"),
POTATOES("potatos","Potatoes"),
CARROTS("carrots","Carrots"),
MELON("melon","Melon"),
PUMPKIN("pumpkin","Pumpkin"),
NETHERWART("nether_wart","Nether Wart"),
MUSHROOMR("mush_wred","Mushroom"),
MUSHROOMBR("mush_brown","Mushroom"),
SUGARCANE("sugar_cane","Sugar Cane"),

;



public final String name;
public final String fullname;

EnumCropType(String par1, String par2){
	this.name = par1; //png name
	this.fullname = par2;
}
}

 

public class BlockCropage extends Block {

@SideOnly(Side.CLIENT)
private IIcon[] icons;

public BlockCropage(){
	super(Material.plants);
	this.setTickRandomly(true);
	float f = 0.5F;
	this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
	this.setCreativeTab(CreativeTabsPLM.tabBlock);
	this.setHardness(0.0F);
	this.setStepSound(soundTypeGrass);
	this.disableStats();
	//this.setBlockName(name);
}

@Override
public boolean isOpaqueCube(){
	return false;
}

public int getRenderType()
    {
        return 6;
    }

@Override
public boolean renderAsNormalBlock() {
	return false;
}

@SideOnly(Side.CLIENT)
public void getSubBlocks(Item block, CreativeTabs creativeTabs, List list){

	for(int i = 0; i < EnumCropType.values().length; i++){
		list.add(new ItemStack(block, 1, i));
	}
}


@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconRegister){
	//icons = new IIcon[15];
	icons = new IIcon[EnumCropType.values().length];
	icons[0] = iconRegister.registerIcon("plantmo" + ":" + "carrots_stage_0");	
	icons[1] = iconRegister.registerIcon("plantmo" + ":" + "template_stage_7");
	for(int pun = 0; pun < EnumCropType.values().length; pun++){
	  icons[pun] = iconRegister.registerIcon("plantmo:"+EnumCropType.values()[pun].name);
	}		
}	

@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta){
 switch(meta){
	case 0:
		return icons[1];
	default:
		return icons[0];

	}
}


}

 

public class ItemblockCropage extends ItemBlockWithMetadata{

public ItemblockCropage(Block block) {
	super(block, block);
	this.setHasSubtypes(true);
}

public String getUnlocalizedName(ItemStack itemstack){
	int i =  itemstack.getItemDamage();
	if (i < 0 || i >= EnumCropType.values().length){
		i = 0;
	}
	return getUnlocalizedName() + "." + EnumCropType.values().length;
}

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


}

 

 

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

You say it does not work. What does not work? What happens? What did you expect to happen instead?

Well for one I get a terminated console/minecraft instance (with the codes I provided), said that a block was already initialized. I expected it to load blocks equal to the amounts in the ENUM file. I probably adjusted the block files with the wrong data, but for the life of me I can't figure out what that data could be, one reason why I displayed the code I used, so I could get help finding what code is wrong in it. :( Because I technically adjusted metadata block code with code I knew worked with the "Enum" items, with adjustments seen in the code in the OP.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Ok, so figured out my dumb mistake, seems I Imported the wrong item class from minecraft *facepalm

But now I have another problem, aswell as a question. The problem I am having, is that while the correct number of them are created i.e 9 of them, they all have the same basic name of: tile.PlanterBlocks.9.name. Any idea on this, will look into get unlocalized name methods, probably the issue to be honest, since from the looks of it, I had it set to "return getUnlocalizedName() + "." + EnumCropType.values(). Which would explain why it was giving the total in the name. Also how would I be able to decide what icon/texture it needs easily? Just the getUnlocalizedName is needed to be resolved :)

 

Strike that, so simple to fix, all I had to do was make the getUnlocalizedName method return "getUnlocalizedName() + "." + ENUMFILENAME.values()..name"  "i" being "itemstack.getItemDamage()" and "name" being set in the ENUM file :) Yay I am learning :)

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

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.