Posted February 21, 201510 yr Hi! I am trying to make a leaf block whose color changes with the biome (like vanilla) and cannot quite figure out how. The block class: package net.mc42.mods.TPDWSP.blocks; import net.mc42.mods.LeVCore.LeVBlock; import net.mc42.mods.TPDWSP.TPDWSP; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; public class PearwoodLeaves extends LeVBlock { public PearwoodLeaves(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub setBlockTextureName(TPDWSP.MODID + ":pearwood_leaves"); setStepSound(Block.soundTypeGrass); setBlockName("pearwood_leaves"); // changed in 1.7 setCreativeTab(CreativeTabs.tabBlock); setSideCount(1); setOpaque(false); } } (LeVBlock has the texture and opaque rendering in it.) LeVBlock: package net.mc42.mods.LeVCore; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; public class LeVBlock extends Block { public IIcon[] icons = new IIcon[6]; private int scount = 1; private boolean opq = true; public LeVBlock(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub } public void setSideCount(int c){ scount = c; } public void setOpaque(boolean tf){ opq = tf; } public boolean isOpaqueCube(){ return opq; } @Override public void registerBlockIcons(IIconRegister reg) { if(scount <= 1){ for (int i = 0; i < 6; i ++) { this.icons[i] = reg.registerIcon(textureName); } } else if(scount==2){ for (int i = 0; i < 6; i ++) { if(i<2){ this.icons[i] = reg.registerIcon(textureName + "_top"); } else { this.icons[i] = reg.registerIcon(textureName + "_side"); } } } else if(scount==3){ for (int i = 0; i < 6; i ++) { if(i==0){ this.icons[i] = reg.registerIcon(textureName + "_down"); } else if(i==1){ this.icons[i] = reg.registerIcon(textureName + "_top"); } else { this.icons[i] = reg.registerIcon(textureName + "_side"); } } } else { int i = 0; this.icons[i++] = reg.registerIcon(textureName + "_down"); this.icons[i++] = reg.registerIcon(textureName + "_top"); this.icons[i++] = reg.registerIcon(textureName + "_n"); this.icons[i++] = reg.registerIcon(textureName + "_s"); this.icons[i++] = reg.registerIcon(textureName + "_w"); this.icons[i++] = reg.registerIcon(textureName + "_e"); } } @Override public IIcon getIcon(int side, int meta) { return this.icons[side]; } }
February 21, 201510 yr I'd help if you actually looked at the vanilla leaves. Say, BlockLeaves line 151. 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.