Jump to content

[Solved] Leave Visibility


Setrion

Recommended Posts

Hey guys, i have a small (i hope it is nothing that can be a big problem xD) texture/visibility bug with my leaves
the issue is, that i can see through them and the other leaves behind the first one are invisible
i think these 2 screenshots can show what my issue is :D (one is the Vanilla Oak Leaves & one are my leaves, i hope you can see what i want to say..)
Sorry for my bad english, try to be better by time :D
 

2018-03-26_22.50.57.png

2018-03-26_22.50.19.png

Edited by Setrion
Solved
Link to comment
Share on other sites

You need a few things all correct, such as the shouldSideBeRendered() and the render layer, etc. 

 

Is your block extending BlockLeaves? If so then it should already work unless you're overriding the block methods improperly. Otherwise just inspect BlockLeaves and make sure all the code related to rendering is copied.

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

Link to comment
Share on other sites

If i override the methods for rendering etc. they're like the picture of my leaves, if i delete them from my leaves file, they're the same, but with black in the transparent fields

I can paste you the code if you want

 

package com.setrion.koratio.blocks;

import java.util.List;
import java.util.Random;

import com.setrion.koratio.main.Koratio;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.BlockPlanks.EnumType;
import net.minecraft.block.BlockSlab.EnumBlockHalf;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockJubanLeaves extends BlockLeaves {
	
	private boolean leavesFancy = GameSettings.Options.GRAPHICS != null;
	
	public BlockJubanLeaves() {
		this.setUnlocalizedName("juban_leaves");
		this.setRegistryName("juban_leaves");
		this.setCreativeTab(Koratio.blockTab);
		this.setDefaultState(this.blockState.getBaseState().withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true)));
	}
	
	public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(DECAYABLE, Boolean.valueOf((meta & 2) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & 4) > 0));
    }
	
	@Override
	public int getMetaFromState(IBlockState state) 
	{
		int i = 0;
		
		if(!((Boolean)state.getValue(DECAYABLE)).booleanValue())
		{
			i |= 2;
		}
		
		if(!((Boolean)state.getValue(CHECK_DECAY)).booleanValue())
		{
			i |= 4;
		}
		
		return i;
	}
	
	protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {CHECK_DECAY, DECAYABLE});
    }
	
	@Override
    public NonNullList<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
    {
        return NonNullList.withSize(1, new ItemStack(this, 1));
    }

	@Override
	public EnumType getWoodType(int meta) {
		return null;
	}
	
	@Override
    public void beginLeavesDecay(IBlockState state, World world, BlockPos pos)
    {
        if (!(Boolean)state.getValue(CHECK_DECAY))
        {
            world.setBlockState(pos, state.withProperty(CHECK_DECAY, true), 1);
        }
    }

	@Override public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos){ return true; }
    @Override public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos){ return true; }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
    
    public boolean isOpaqueCube(IBlockState state)
    {
        return !this.leavesFancy;
    }

    /**
     * Pass true to draw this block using fancy graphics, or false for fast graphics.
     */
    @SideOnly(Side.CLIENT)
    public void setGraphicsLevel(boolean fancy)
    {
        this.leavesFancy = fancy;
    }

    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return this.leavesFancy ? BlockRenderLayer.CUTOUT_MIPPED : BlockRenderLayer.SOLID;
    }
    
    public boolean causesSuffocation(IBlockState state)
    {
        return false;
    }

    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return Item.getItemFromBlock(ModBlocks.blockJubanSapling);
    }

    protected int getSaplingDropChance(IBlockState state)
    {
        return 20;
    }
	
	public void registerItemModel(Item itemBlock) {
		Koratio.proxy.registerItemRenderer(itemBlock, 0, "juban_leaves");
	}
	
	public Item createItemBlock() {
		return new ItemBlock(this).setRegistryName(getRegistryName());
	}
	
	@SideOnly(Side.CLIENT)
    public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
    {
        return !this.leavesFancy && blockAccess.getBlockState(pos.offset(side)).getBlock() == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side);
    }

}

 

Edited by Setrion
Link to comment
Share on other sites

The black in the transparent fields is a problem where leaves are hard-coded for honoring the fancy graphics setting. For custom leaves it is very difficult to make your leaves honor that setting, so I just make it always fancy for my own leaves.

 

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

 

In the constructor you can see I call a proxy method to set the graphics level to always be fancy. You should do the same -- you'll also need to look at my code in my ClientProxy and ServerProxy classes.

 

It is possible but tricky to get the fancy setting to work as a user setting. There are other threads on that if you really care. I personally think anyone who needs to turn off fancy settings should get a new computer!

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

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Anyone have some time to lend me a bit of a helping hand, cuz I'm a lil stumped on why Chiseled Reborn is breaking the modpack. - All I get on the suspected mods area of the error log is this: Suspected Mods: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:392) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:250) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.processClass(MixinTransformationHandler.java:131) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:113) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) at java.base/java.lang.Class.getDeclaredMethods0(Native Method) at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.findMixinMerged(ModIdentifier.java:133) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.getMixinInfo(ModIdentifier.java:165) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.identifyFromThrowable(ModIdentifier.java:64) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.lambda$identifyFromStacktrace$2(ModIdentifier.java:42) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.visitChildrenThrowables(ModIdentifier.java:52) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.identifyFromStacktrace(ModIdentifier.java:41) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.lambda$getSuspectedModsOf$0(ModIdentifier.java:34) at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220) at TRANSFORMER/[email protected]+1.20.1/fudge.notenoughcrashes.stacktrace.ModIdentifier.getSuspectedModsOf(ModIdentifier.java:34) at TRANSFORMER/[email protected]/net.minecraft.CrashReport.md57ae67$lambda$beforeSystemDetailsAreWritten$1$0(CrashReport.java:535) at TRANSFORMER/[email protected]/net.minecraft.SystemReport.m_143522_(SystemReport.java:66) at TRANSFORMER/[email protected]/net.minecraft.CrashReport.handler$cpk000$beforeSystemDetailsAreWritten(CrashReport.java:533) at TRANSFORMER/[email protected]/net.minecraft.CrashReport.m_127519_(CrashReport.java:71) at TRANSFORMER/[email protected]/net.minecraft.CrashReport.m_127526_(CrashReport.java:114) at TRANSFORMER/[email protected]/net.minecraft.CrashReport.m_127512_(CrashReport.java:135) at TRANSFORMER/[email protected]/net.minecraft.client.Minecraft.m_91332_(Minecraft.java:846) at TRANSFORMER/[email protected]/net.minecraft.client.main.Main.main(Main.java:192) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111) at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:99) at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$makeService$0(CommonClientLaunchHandler.java:25) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:108) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:78) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at [email protected]/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) Caused by: org.spongepowered.asm.mixin.throwables.MixinApplyError: Mixin [entity_texture_features-common.mixins.json:entity.misc.MixinBlockEntityRenderDispatcher] from phase [DEFAULT] in config [entity_texture_features-common.mixins.json] FAILED during APPLY at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.handleMixinError(MixinProcessor.java:636) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.handleMixinApplyError(MixinProcessor.java:588) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:379) ... 48 more Caused by: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: Specified index 4 for @ModifyArg is invalid for args (Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderer;Lnet/minecraft/world/level/block/entity/BlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;II), expected I on net/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher::etf$vanillaLightOverride [INJECT Applicator Phase -> entity_texture_features-common.mixins.json:entity.misc.MixinBlockEntityRenderDispatcher -> Apply Injections -> -> Inject -> entity_texture_features-common.mixins.json:entity.misc.MixinBlockEntityRenderDispatcher->@ModifyArg::etf$vanillaLightOverride(I)I] at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.invoke.ModifyArgInjector.findArgIndex(ModifyArgInjector.java:158) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.invoke.ModifyArgInjector.injectAtInvoke(ModifyArgInjector.java:113) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.invoke.InvokeInjector.inject(InvokeInjector.java:82) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.invoke.ModifyArgInjector.inject(ModifyArgInjector.java:103) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.code.Injector.inject(Injector.java:276) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.injection.struct.InjectionInfo.inject(InjectionInfo.java:445) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinTargetContext.applyInjections(MixinTargetContext.java:1355) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyInjections(MixinApplicatorStandard.java:1051) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:400) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:325) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:383) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:365) at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) ... 48 more I can't exactly narrow down what could be breaking it, maybe one of you can?
    • i need help fixing my server ui dont know what is going wrong here is the latest log help pls latestlog.txt
  • Topics

×
×
  • Create New...

Important Information

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