Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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];
}

}

 

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.

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...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.