Override block with custom one

Discussion in 'Plugin Development' started by Azuna1, Dec 18, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Azuna1

    My aim is to let Mycelium spread over grass and not just dirt
    So i got my custom block
    Code:
    public class BlockMycelCustom extends BlockMycel
    and im rewriting the Mycelium entry in Block.REGISTRY at onLoad() with
    Code:
    Block.REGISTRY.a(110, new MinecraftKey("mycelium"), new BlockMycelCustom() );
    though my block never gets ticked, and instead of spreading it now sets the target block to AIR
    Now i checked where Blocks.MYCELIUM points and it was ofc the old class, so i changed it to point to my block instead

    So far so good,
    nothing changed, its still only spreadign to dirt and sets the target block to air
     
  2. Offline

    TGRHavoc

    @Azuna1
    I thought that it was "Block.a( int, String, Block)" but, looking into the source I find that you can do what you're doing :p
    Try doing "Block.REGISTRY.a(110, "mycelium", (new BlockMycelCustom()).c(0.6F).a(h).c("mycel").d("mycelium"));" (As found in the official code)

    Might not work but, hey. At least it's worth a shot right?

    Edit: You may also want to look into the BlockMycel code and find where it only spreads to dirt, then change this to allow it to also spread to grass.
     
    Last edited: Dec 18, 2014
  3. Offline

    Azuna1

    @TGRHavoc the registration works fine
    and you cant just change the NMS file, anyway the fix is:
    i was totaly ignoring this:
    Show Spoiler

    Code:
    iterator = Block.REGISTRY.iterator();
    while (iterator.hasNext())
    {
        block13 = (Block) iterator.next();
        Iterator iterator1 = block13.O().a().iterator();
        while (iterator1.hasNext())
        {
            IBlockData iblockdata = (IBlockData) iterator1.next();
            int i = Block.REGISTRY.b(block13) << 4 | block13.toLegacyData(iblockdata);
    
            Block.d.a(iblockdata, i);
        }
    }
     
    jjssman likes this.
  4. Offline

    jjssman

    Hey, thanks for posting how you solved it, I spent the whole morning trying to figure out how to get my custom block to work on 1.8 until I read this. =)
     
Thread Status:
Not open for further replies.

Share This Page