Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.6.4]Multiple TickUpdates in One Block?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Ellbelly

[1.6.4]Multiple TickUpdates in One Block?

By Ellbelly, January 20, 2014 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Ellbelly    0

Ellbelly

Ellbelly    0

  • Tree Puncher
  • Ellbelly
  • Members
  • 0
  • 46 posts
Posted January 20, 2014

Okay so yesterday I got help with adding a random tickRate to make my block change into another block now that that is working I have the problem with my block being a leaf block and the leaves need to disappear if they are not connected to a wood block, but I already am using the tickUpdate to change it into a different block and I couldn't get both of them to work but on different tickUpdates. Now I don't know if this makes any sense but I have no idea how I could fix it.  :(

 

This is my block (the parts I need to show)

package name.mod.common.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import name.block.common.MainCLass;

public class BlockModLeaves2 extends BlockLeavesBase
{
     
    public BlockModLeaves2(int par1)
    {
        super(par1, Material.leaves, true);
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }
    
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
	world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world));
}
   
    @Override
    public int tickRate(World par1World)
    {
    	Random random = new Random();
    	return 24000+random.nextInt(6000);
    }

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        par1World.setBlock(par2, par3, par4, Mod.Leaves.blockID);
                   
    }

 

And I need to add this to it but it cant inter-fear with my updateTick that is already in it. And it needs tick randomly set to true but that stuffs up my tickRate.  :o:-\

    public BlockModLeaves2 (int par1, boolean par2)
    {
        super(par1, Material.leaves, true);
        this.setTickRandomly(true);
    }

    public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
    {
        byte b0 = 1;
        int j1 = b0 + 1;

        if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1))
        {
            for (int k1 = -b0; k1 <= b0; ++k1)
            {
                for (int l1 = -b0; l1 <= b0; ++l1)
                {
                    for (int i2 = -b0; i2 <= b0; ++i2)
                    {
                        int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2);

                        if (Block.blocksList[j2] != null)
                        {
                            Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2);
                        }
                    }
                }
            }
        }
    }

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
    {
        if (!par1World.isRemote)
        {
            int l = par1World.getBlockMetadata(par2, par3, par4);

            if ((l &  != 0 && (l & 4) == 0)
            {
                byte b0 = 4;
                int i1 = b0 + 1;
                byte b1 = 32;
                int j1 = b1 * b1;
                int k1 = b1 / 2;

                if (this.adjacentTreeBlocks == null)
                {
                    this.adjacentTreeBlocks = new int[b1 * b1 * b1];
                }

                int l1;

                if (par1World.checkChunksExist(par2 - i1, par3 - i1, par4 - i1, par2 + i1, par3 + i1, par4 + i1))
                {
                    int i2;
                    int j2;
                    int k2;

                    for (l1 = -b0; l1 <= b0; ++l1)
                    {
                        for (i2 = -b0; i2 <= b0; ++i2)
                        {
                            for (j2 = -b0; j2 <= b0; ++j2)
                            {
                                k2 = par1World.getBlockId(par2 + l1, par3 + i2, par4 + j2);

                                Block block = Block.blocksList[k2];

                                if (block != null && block.canSustainLeaves(par1World, par2 + l1, par3 + i2, par4 + j2))
                                {
                                    this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
                                }
                                else if (block != null && block.isLeaves(par1World, par2 + l1, par3 + i2, par4 + j2))
                                {
                                    this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
                                }
                                else
                                {
                                    this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
                                }
                            }
                        }
                    }

                    for (l1 = 1; l1 <= 4; ++l1)
                    {
                        for (i2 = -b0; i2 <= b0; ++i2)
                        {
                            for (j2 = -b0; j2 <= b0; ++j2)
                            {
                                for (k2 = -b0; k2 <= b0; ++k2)
                                {
                                    if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1)
                                    {
                                        if (this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
                                        {
                                            this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2)
                                        {
                                            this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2)
                                        {
                                            this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2)
                                        {
                                            this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
                                        }

                                        if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2)
                                        {
                                            this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
                                        }

                                        if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2)
                                        {
                                            this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                l1 = this.adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1];

                if (l1 >= 0)
                {
                    par1World.setBlockMetadataWithNotify(par2, par3, par4, l & -9, 4);
                }
                else
                {
                    this.removeLeaves(par1World, par2, par3, par4);
                }
            }
        }
    }

  private void removeLeaves(World par1World, int par2, int par3, int par4)
    {
        this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
        par1World.setBlockToAir(par2, par3, par4);
    }

  
    public void beginLeavesDecay(World world, int x, int y, int z)
    {
        world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4);
    }

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2401

Draco18s

Draco18s    2401

  • Reality Controller
  • Draco18s
  • Members
  • 2401
  • 15918 posts
Posted January 20, 2014

I don't think you're going to be able to do this.

  • Quote

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.

Share this post


Link to post
Share on other sites

Ellbelly    0

Ellbelly

Ellbelly    0

  • Tree Puncher
  • Ellbelly
  • Members
  • 0
  • 46 posts
Posted January 20, 2014

Dam that's what I thought :(

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • mireyaruff
      my server doens`t work

      By mireyaruff · Posted 11 minutes ago

      Thx, appreciate it!
    • Badnews4u
      My forge server won't load all the mods

      By Badnews4u · Posted 26 minutes ago

      Went through all the steps to make forge server hosted from my computer. I was able to successfully launch the server, but after joining the server I noticed not all my mods were working. Most notably it didn't generate a world with biomes o' plenty when I made sure to set the biomes o' plenty default world setting in the configs to true. Also gravestone mod won't give me gravestones. I made sure to update my java and everything and yes, I made sure to create the server using the forge .jar file. Any suggestions on how to fix this?
    • Lellian
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Lellian · Posted 2 hours ago

      Well this is embarrasing. I don't know how I missed this, but it fixed everything.   Thank you very much 🤣🔫
    • Draco18s
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Draco18s · Posted 2 hours ago

      Cough.  
    • Lellian
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Lellian · Posted 2 hours ago

      What do you mean? ExampleBlock is the small stone thing you see in the picture. It gets registered just fine (Via a DeferredRegistry), I can place it and then you see what is in the picture. This is about the hitbox/outline of the block, which I want to be smaller.
  • Topics

    • peermans
      2
      my server doens`t work

      By peermans
      Started January 7

    • Badnews4u
      0
      My forge server won't load all the mods

      By Badnews4u
      Started 26 minutes ago

    • Lellian
      4
      [SOLVED] [1.16.4] Change Block Hitbox/Outline

      By Lellian
      Started 4 hours ago

    • Chicckenprell
      0
      stoneblock 1.12.2 server crashing

      By Chicckenprell
      Started 4 hours ago

    • Veo
      2
      Unable to start LAN server detection: Can't assign requested address [Server][Modded][1.16.4]

      By Veo
      Started 8 hours ago

  • Who's Online (See full list)

    • LevelNaomi
    • Kreepydude
    • ChampionAsh5357
    • HEHEHAHAHA
    • Lellian
    • Badnews4u
    • thorstenschwager
    • Choonster
    • LexManos
    • mireyaruff
    • jbredwards
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.6.4]Multiple TickUpdates in One Block?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community