Posted March 30, 20187 yr 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 March 30, 20187 yr by StudioMaker
March 30, 20187 yr 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 March 30, 20187 yr 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.