Jump to content

Custom lamp problem 1.12.2


MrPablo2000

Recommended Posts

Hi, it me   - again...

 

 

I want to make my neon letter as a redstone lamp. I use the code from RedstoneLight.class. 

When I power my block, its working. It place block NeonLetterENeonActive...but with another rotation as NeonLetterEIdle...

 

My default direction is West, but i make a method that the block rotates to player on placing. 

 

For example: Idle block is north, but when i power it, the powered block are placed with default, west rotation..

 

 

What i must change in code, to get this: when i power the block, powered block has the same ratation as unpowered?

 

I use this code - it's coppied from vanilla RedstoneLight:

Spoiler

   public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!worldIn.isRemote)
        {
            if (this.isOn && !worldIn.isBlockPowered(pos))
            {
                worldIn.setBlockState(pos, ModBlocks.neonletterENeonIdle.getDefaultState(), 2);
            }
            else if (!this.isOn && worldIn.isBlockPowered(pos))
            {
                worldIn.setBlockState(pos, ModBlocks.neonletterENeonActive.getDefaultState(), 2);
            }
        }
    }

    /**
     * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
     * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
     * block, etc.
     */
    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
    {
        if (!worldIn.isRemote)
        {
            if (this.isOn && !worldIn.isBlockPowered(pos))
            {
                worldIn.scheduleUpdate(pos, this, 4);
            }
            else if (!this.isOn && worldIn.isBlockPowered(pos))
            {
                worldIn.setBlockState(pos, ModBlocks.neonletterENeonActive.getDefaultState(), 2);
            }
        }
    }

    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
    {
        if (!worldIn.isRemote)
        {
            if (this.isOn && !worldIn.isBlockPowered(pos))
            {
                worldIn.setBlockState(pos, ModBlocks.neonletterENeonIdle.getDefaultState(), 2);
            }
        }
    }

 

Edited by MrPablo2000
language errors - sorry for my bad English..
Link to comment
Share on other sites

As I told you via PM, @deprecated means "do not INVOKE," not "do not override." If you look at the block class literally every method is marked @deprecated.

Edited by Draco18s

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.

Link to comment
Share on other sites

I still don't know how to do it..  :(

 

I try this way, to use only 1 block:

public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        if (!worldIn.isBlockPowered(pos))
        {
            isActive=false;
        }
    }
}

 

In constructor:

	if(this.isActive=true)
		{
			setLightLevel(1F);
		}

 

 

and boolean:

private boolean isActive = false;	

 

 

But it stil doesn't work... :/ 

Link to comment
Share on other sites

2 hours ago, MrPablo2000 said:

I still don't know how to do it..  :(

 

I try this way, to use only 1 block:


public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        if (!worldIn.isBlockPowered(pos))
        {
            isActive=false;
        }
    }
}

 

In constructor:


	if(this.isActive=true)
		{
			setLightLevel(1F);
		}

 

 

and boolean:


private boolean isActive = false;	

 

 

But it stil doesn't work... :/ 

Post your entire code, and preferably a GitHub 

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

2 hours ago, MrPablo2000 said:

public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)

This doesn't work the way you think it does. It's not the same as the update method of TileEntities that gets called once per tick. This method gets called once per tick... on one random block in all loaded chunks.

 

2 hours ago, MrPablo2000 said:

if(this.isActive=true)

This is always true since this sets the isActive field to true.

 

2 hours ago, MrPablo2000 said:

private boolean isActive = false;	

 

Blocks are singletons. You can't use fields to store per-block data. Use block properties.

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

This method gets called once per tick... on one random block in all loaded chunks.

Well, I think its actually on 16 blocks per chunk, but otherwise more or less.

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.

Link to comment
Share on other sites

7 hours ago, V0idWa1k3r said:

This doesn't work the way you think it does. It's not the same as the update method of TileEntities that gets called once per tick. This method gets called once per tick... on one random block in all loaded chunks.

 

This is always true since this sets the isActive field to true.

 

Blocks are singletons. You can't use fields to store per-block data. Use block properties.

Block Properties? You mean .setHardness, .setLightLevel etc?

Link to comment
Share on other sites

3 hours ago, MrPablo2000 said:

I try to do it with crops code, but i never works with Properties...Have you any toturial about it ?

Check out the forge docs on BlockStates.

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

Quote

 "facing=north": 

That is not how you define states in forge blockstates. If you want to use vanilla syntax use vanilla format.

 

On 8/21/2018 at 3:46 PM, V0idWa1k3r said:
On 8/21/2018 at 12:51 PM, MrPablo2000 said:

public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)

This doesn't work the way you think it does. It's not the same as the update method of TileEntities that gets called once per tick. This method gets called once per tick... on one random block in all loaded chunks.

 

public boolean isMaxState(IBlockState state)
{
    return ((Integer)state.getValue(this.getStateProperty())).intValue() >= this.getMaxState();
}

This will never be true as your state property is within a [0-1] range and getMaxState returns 7 for whatever reason.

Also you don't need half of these methods, they just make your block class bloated. Never copy vanilla code and simply change the names of methods and variables without understanding of what's going on.

 

@Override
    public int getMetaFromState(IBlockState state) {
        return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
}
 
    @Override
    public IBlockState getStateFromMeta(int meta) {
        return getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta));
    }

You must include your state property in metadata serialization/deserialization.

 

@Override
    public BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, FACING);
    }

You must include your state property in the BlockStateContainer created.

 

    public static final PropertyInteger STATE = PropertyInteger.create("state", 0, 1);

If your integer is only within a [0-1] range then you don't need an integer, you need a boolean. 

 

Here are the docs on the blockstates. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • ASIABET adalah pilihan terbaik bagi Anda yang mencari slot gacor hari ini dengan server Rusia dan jackpot menggiurkan. Berikut adalah beberapa alasan mengapa Anda harus memilih ASIABET: Slot Gacor Hari Ini Kami menyajikan koleksi slot gacor terbaik yang diperbarui setiap hari. Dengan fitur-fitur unggulan dan peluang kemenangan yang tinggi, Anda akan merasakan pengalaman bermain yang tak terlupakan setiap kali Anda memutar gulungan. Server Rusia yang Handal Kami menggunakan server Rusia yang handal dan stabil untuk memastikan kelancaran dan keadilan dalam setiap putaran permainan. Anda dapat bermain dengan nyaman tanpa khawatir tentang gangguan atau lag. Jackpot Menggiurkan Nikmati kesempatan untuk memenangkan jackpot menggiurkan yang dapat mengubah hidup Anda secara instan. Dengan hadiah-hadiah besar yang ditawarkan, setiap putaran permainan bisa menjadi peluang untuk meraih keberuntungan besar.
    • Sonic77 adalah pilihan tepat bagi Anda yang menginginkan pengalaman bermain slot yang unggul dengan akun pro Swiss terbaik. Berikut adalah beberapa alasan mengapa Anda harus memilih Sonic77: Slot Gacor Terbaik Kami menyajikan koleksi slot gacor terbaik dari provider terkemuka. Dengan fitur-fitur unggulan dan peluang kemenangan yang tinggi, Anda akan merasakan pengalaman bermain yang tak terlupakan. Akun Pro Swiss Berkualitas Kami menawarkan akun pro Swiss yang berkualitas dan terpercaya. Dengan akun ini, Anda dapat menikmati berbagai keuntungan eksklusif dan fasilitas premium yang tidak tersedia untuk akun reguler.
    • SV388 SITUS RESMI SABUNG AYAM 2024   Temukan situs resmi untuk sabung ayam terpercaya di tahun 2024 dengan SV388! Dengan layanan terbaik dan pengalaman bertaruh yang tak tertandingi, SV388 adalah tempat terbaik untuk pecinta sabung ayam. Daftar sekarang untuk mengakses arena sabung ayam yang menarik dan nikmati kesempatan besar untuk meraih kemenangan. Jelajahi sensasi taruhan yang tak terlupakan di tahun ini dengan SV388! [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]   JURAGANSLOT88 SITUS JUDI SLOT ONLINE TERPERCAYA 2024 Jelajahi pengalaman judi slot online terpercaya di tahun 2024 dengan JuraganSlot88! Sebagai salah satu situs terkemuka, JuraganSlot88 menawarkan berbagai pilihan permainan slot yang menarik dengan layanan terbaik dan keamanan yang terjamin. Daftar sekarang untuk mengakses sensasi taruhan yang tak terlupakan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan JuraganSlot88 [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
    • Slot Bank MEGA atau Daftar slot Bank MEGA bisa anda lakukan pada situs WINNING303 kapanpun dan dimanapun, Bermodalkan Hp saja anda bisa mengakses chat ke agen kami selama 24 jam full. keuntungan bergabung bersama kami di WINNING303 adalah anda akan mendapatkan bonus 100% khusus member baru yang bergabung dan deposit. Tidak perlu banyak, 5 ribu rupiah saja anda sudah bisa bermain bersama kami di WINNING303 . Tunggu apa lagi ? Segera Klik DAFTAR dan anda akan jadi Jutawan dalam semalam.
    • ladangtoto situs resmi ladangtoto situs terpercaya 2024   Temukan situs resmi dan terpercaya untuk tahun 2024 di LadangToto! Dengan layanan terbaik dan keamanan yang terjamin, LadangToto adalah pilihan utama untuk penggemar judi online. Daftar sekarang untuk mengakses berbagai jenis permainan taruhan, termasuk togel, kasino, dan banyak lagi. Jelajahi sensasi taruhan yang tak terlupakan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan LadangToto!" [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
  • Topics

×
×
  • Create New...

Important Information

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