Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, I want my block (Frozen dirt) after a while to transform into my dirt. i just didnt figure it out how to do that, here is my FrozenDirt class 

package com.studiomaker.poweredelements2.blocks;

import java.util.Random;

import com.studiomaker.poweredelements2.init.ModBlocks;
import com.studiomaker.poweredelements2.util.IHasModel;

import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;

public class FrozenDirt extends BlockBase implements IHasModel
{

	public FrozenDirt(String name, Material material) 
	{
		super(name, material);
		setSoundType(SoundType.GLASS);
		setHardness(1.0F);
		setResistance(1F);
		setTickRandomly(true);
    }
	
}

 

And here is my MarsDirt class 

package com.studiomaker.poweredelements2.blocks;

import java.util.Random;

import com.studiomaker.poweredelements2.init.ModBlocks;
import com.studiomaker.poweredelements2.init.ModItems;
import com.studiomaker.poweredelements2.util.IHasModel;

import net.minecraft.block.BlockSapling;
import net.minecraft.block.IGrowable;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class MarsDirt extends BlockBase implements IHasModel
{

	public MarsDirt(String name, Material material) 
	{
		super(name, material);
		setSoundType(SoundType.GROUND);
		setHardness(1.0F);
		setResistance(1F);
	}

	   @Override
	    public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
	    {
	        IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	        net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	        if (plant.getBlock() instanceof BlockSapling)
	        {
	            return true;
	        }

	        return false;
	    }
	    
	    @Override
	    public void onPlantGrow(IBlockState state, World world, BlockPos pos, BlockPos source)
	    {
	    	
	    }
	    
	    
	    @Override
	    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
	    {
	       if(rand.nextInt(99)+1 <= 60)
	        {
	            IBlockState iblockstate = worldIn.getBlockState(pos.up());

	            if (iblockstate.getBlock() instanceof IGrowable && iblockstate.getBlock() != Blocks.GRASS)
	            {
	                IGrowable igrowable = (IGrowable)iblockstate.getBlock();

	                if (igrowable.canGrow(worldIn, pos.up(), iblockstate, worldIn.isRemote))
	                {
	                    if (!worldIn.isRemote)
	                    {
	                        if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos.up(), iblockstate))
	                        {
	                            igrowable.grow(worldIn, worldIn.rand, pos.up(), iblockstate);
	                            worldIn.playEvent(300, pos, 0);
	                        }

	                    }

	                }
	            }
	        }
	    }
}

 

Edited by StudioMaker

 

had same problem this should work but it updates randomly so the time can't be controlled well.

 

this will just change the block at random update

 

package com.studiomaker.poweredelements2.blocks;

import java.util.Random;

import com.studiomaker.poweredelements2.init.ModBlocks;
import com.studiomaker.poweredelements2.util.IHasModel;

import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;

public class FrozenDirt extends BlockBase implements IHasModel
{

	public FrozenDirt(String name, Material material) 
	{
		super(name, material);
		setSoundType(SoundType.GLASS);
		setHardness(1.0F);
		setResistance(1F);
		setTickRandomly(true);
    }
   
	@Override
	 public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
	    {
		
		
			
				 worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());//chage this to the block you want
				 
		
		
	    }
}

 

Edited by JavaMan7

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.