Jump to content

Recommended Posts

Posted (edited)
1 hour ago, Emerald_Galaxy said:

all it did was make them solid, like leaves on fast

 

I ran into the same issue in my custom leaves. Your leaves block will not get the game settings automatically as far as your leaves are concerned you're on fast level.

 

What you need to do is (a) stop overriding the methods, (b) explicitly set the fancy graphics in your block using a proxy method (because the call needs some sided code).

 

You can see how I do it in my constructor: https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/blocks/BlockLeavesCloud.java

 

EDIT: The reason why fancy graphics won't apply to custom leaves is the call to setFancyGraphics() is hard-coded to only be called on the vanilla Blocks.LEAVES and Blocks.LEAVES2 in the RenderGlobal#loadRenderers() method.

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Good point. Not only is vanilla hard-coded to the leaves for the init() method of Minecraft class, but for any other change in settings.

 

Personally I don't care about that as I feel that very few people must have computers which need to have fancy turned off any more, so I just forced it to be "fancy all the time". But logically yes you would fully handle the game setting directly if you wanted to support fast level.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted (edited)

Ok, I finally got it to work :D

 

All it took was a SideOnly annotation and using the leaves results for the render methods but its pretty simple and it works.

 

New Code

public class LeafBase extends BlockLeaves implements ModelInterface {
	
	private Item fruit;
	
	public LeafBase(String name, Item fruit, SoundType sound, Float hardness, Float blastResist, Float brightness, Integer isUnbreakable) {
		
		setUnlocalizedName(name);
		setRegistryName(name);
		
		setSoundType(sound);
		setHardness(hardness);
		setResistance(blastResist);
		setLightLevel(brightness);
		setLightOpacity(1);
		
		if(isUnbreakable == 1) {
			setBlockUnbreakable();
		}
		
		this.fruit = fruit;
		
		setDefaultState(this.blockState.getBaseState().withProperty(CHECK_DECAY, Boolean.valueOf(false)).withProperty(DECAYABLE, Boolean.valueOf(false)));
		
		ModBlocks.BLOCKS.add(this);
		ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
		
	}
	
	public Item getItemDropped(IBlockState state, Random rand, int fortune) {
		
		return fruit;
		
	}
	
	public ItemStack getSilkTouchDrop(IBlockState state) {
		
		return new ItemStack(Item.getItemFromBlock(this), 1);
		
	}
	
	public int quantityDropped(Random random) {
		
		if(random.nextInt(200) == 0) {
			
			return 1;
			
		} else {
			
			return 0;
			
		}
		
	}
	
	@Override
	public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
		
		return NonNullList.withSize(1, new ItemStack(this, 1));
		
	}
	
	@Override
	public boolean isOpaqueCube(IBlockState state) {
		
		return Blocks.LEAVES.isOpaqueCube(state);
		
	}
	
	@SideOnly(Side.CLIENT)
	@Override
	public BlockRenderLayer getBlockLayer() {
		
		return Blocks.LEAVES.getBlockLayer();
		
	}
	
	@SideOnly(Side.CLIENT)
	@Override
	public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
		
        return Blocks.LEAVES.shouldSideBeRendered(state, world, pos, side);
        
    }
	
	@Override
	public EnumType getWoodType(int meta) {
		
		return null;
		
	}
	
	@Override
	public IBlockState getStateFromMeta(int meta) {
		
		return this.getDefaultState();
		
	}
	
	@Override
	public int getMetaFromState(IBlockState state) {
		
		return 0;
		
	}
	
	@Override
	protected BlockStateContainer createBlockState() {
		
		return new BlockStateContainer(this, new IProperty[] {CHECK_DECAY, DECAYABLE});
		
	}
	
	@Override
	public void registerModels() {
		
		Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
	
	}

}

 

2018-03-07_15.35.00.png

Edited by Emerald_Galaxy
Picture

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.