Jump to content

Custom block won't spread


P4NTH3R27

Recommended Posts

I'm working on a tiberium mod and I want the block to replace nearby grass and dirt, but it won't spread no matter how I try to make it.

I'm not sure exactly what I'm missing here, but a few hours ago I felt close to figuring it out and now it's slipping from my grasp. I feel like it's staring me in the face, too.

Forgive me if it's messy.

package com.P4NTH3R27.arimod.blocks;

import java.util.Random;

import com.P4NTH3R27.arimod.init.BlockInit;
import com.P4NTH3R27.arimod.init.ItemInit;

import net.minecraft.block.Block;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class TiberiumGrass extends BlockBase
{
	public static final Block block = null;
	public TiberiumGrass(String name, Material material, float hardness, float resistance, int miningLevel, String tool) 
	{
		super(name, material, hardness, resistance, miningLevel, name);
		
		setUnlocalizedName(name);
		setRegistryName(name);
		setHardness(5.0f);
		setResistance(5.0f);
		setHarvestLevel("shovel", 2);
		this.setItemDropped(() -> ItemInit.tiberium_shard);
		this.setTickRandomly(true);
		this.setDefaultState(this.blockState.getBaseState());
		
		BlockInit.BLOCKS.add(this);
		ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
	}
	
	
	
	@Override
	public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
		super.onBlockAdded(world, pos, state);
		int x = pos.getX();
		int y = pos.getY();
		int z = pos.getZ();
		world.scheduleUpdate(new BlockPos(x, y, z), this, this.tickRate(world));
	}


	@Override
	public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
	{
	        	BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
		        IBlockState iblockstate = worldIn.getBlockState(blockpos);
		        IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
		        
		        int x = pos.getX();
		        int y = pos.getY();
		        int z = pos.getZ();
		        
		        if (((iblockstate1.getBlock() == Blocks.DIRT)))
		        {
		        	worldIn.setBlockState(blockpos, this.getDefaultState());
		        }
		        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
	        
		
	}
}

 

 

Edited by P4NTH3R27
better explaination
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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