Jump to content

[1.12.2] Lighting bug with custom model


ProspectPyxis

Recommended Posts

I have a block with a custom model that also emits some light, but when I place it on the world this happens:
 

Spoiler

java_2018-10-10_10-09-39.thumb.png.bd8fdecac0ff2a0f4c551b4e79a5fdf8.png

Here's the code for this block:

Spoiler

package prospectpyxis.glowinglights.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;

import java.util.Random;

public class BlockGlowGravelPath extends BlockBase {

    protected static final AxisAlignedBB GLOWING_GRAVEL_PATH_AABB = new AxisAlignedBB(0.0625d, 0.0d, 0.0625d, 0.9375d, 0.0625d, 0.9375d);

    @GameRegistry.ObjectHolder("glowinglights:glowing_gravel_path_item")
    public static final Item glowGravelPathOH = null;

    public BlockGlowGravelPath() {
        super(Material.GROUND, "glowing_gravel_path", 0.1f, 0, MapColor.SAND);
        this.lightValue = 5;
        this.lightOpacity = 255;
        this.fullBlock = false;
        this.blockSoundType = SoundType.STONE;
    }

    @Override
    public Item getItemDropped(IBlockState state, Random rand, int fortune) {
        return glowGravelPathOH;
    }

    @Override
    public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
        return new ItemStack(glowGravelPathOH);
    }

    @Override
    public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
        BlockPos blockPos = pos.offset(EnumFacing.DOWN);
        IBlockState state = worldIn.getBlockState(blockPos);

        if (state.isSideSolid(worldIn, blockPos, EnumFacing.UP) || state.getBlockFaceShape(worldIn, blockPos, EnumFacing.UP) == BlockFaceShape.SOLID) {
            return state.getBlock() != Blocks.END_GATEWAY && state.getBlock() != Blocks.LIT_PUMPKIN;
        }
        else {
            return false;
        }
    }

    @Override
    @SuppressWarnings("deprecation")
    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
        BlockPos blockPos = pos.offset(EnumFacing.DOWN);

        if (worldIn.getBlockState(blockPos).getBlockFaceShape(worldIn, blockPos, EnumFacing.UP) != BlockFaceShape.SOLID) {
            this.dropBlockAsItem(worldIn, pos, state, 0);
            worldIn.setBlockToAir(pos);
        }
    }

    @Override
    @SuppressWarnings("deprecation")
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
        return GLOWING_GRAVEL_PATH_AABB;
    }

    @Override
    @SuppressWarnings("deprecation")
    public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
        return NULL_AABB;
    }

    @Override
    @SuppressWarnings("deprecation")
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    @SuppressWarnings("deprecation")
    public boolean isFullCube(IBlockState state) {
        return false;
    }

    @Override
    @SuppressWarnings("deprecation")
    public boolean isFullBlock(IBlockState state) {
        return false;
    }

    @Override
    @SuppressWarnings("deprecation")
    public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
        return BlockFaceShape.CENTER_SMALL;
    }
}

 

I have another light-emitting block with a custom model with very similar code to this but that works fine, so I really don't know what's wrong here...

Edited by ProspectPyxis
  • Like 1
Link to comment
Share on other sites

16 minutes ago, ProspectPyxis said:

I have a block with a custom model that also emits some light, but when I place it on the world this happens:

What exactly is your problem?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

3 minutes ago, ProspectPyxis said:

The image in the first spoiler should say it all, I think, but the problem is that the block below the one this block is placed on is inexplicably dark.

I'll be honest with you. Until you pointed it out I didn't notice it, could be a me just waking up, it not being that noticable, or I'm just really bad at that sort of thing. However I believe the solution is returning CUTOUT in getBlockLayer.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Override getLightOpacity? (Between 0-15) 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Can you post your code as a GitHub repository? I've got some spare time & could clone & test your project myself

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.



×
×
  • Create New...

Important Information

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