Posted August 25, 20169 yr I'm having trouble with my custom ice block that is supposed to change into 8 more blocks shortly after placed. I used #scheduleBlockUpdate in 1.7.10 and replaced it with #scheduleUpdate in 1.8 but I don't really get what's happening ...I think the third parameter is the tickRate which I set to 1, and I have tried setting setTickRandomly both true and false. What I want to happen works when #setTickRandomly is true but the blocks update truly randomly, not immediately. When I have #setTickRandomly set to false, nothing happens , ie, the custom block ice that I place does not change at all . . . Do I have the parameters wrong? Using wrong method? no idea what is the problem... this is my LiquidIce class, that is, my custom block ice: package com.glistre.glistremod.blocks; import java.util.Random; import com.glistre.glistremod.init.BiomeRegistry; import com.glistre.glistremod.init.BlockRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockIce; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; public class LiquidIceBlock extends BlockIce { public String blockName; public LiquidIceBlock() { super(); this.setUnlocalizedName(blockName); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, .99F, 1.0F); this.setTickRandomly(true); } /* @Override public int tickRate(){ return 30; }*/ public void onBlockAdded(World worldIn, BlockPos pos) { worldIn.scheduleUpdate(pos, this, 1); //was #scheduleBlockUpdate worldIn.setBlockState(pos, BlockRegistry.liquid_ice.getDefaultState()); } @Override public void updateTick( World worldIn, BlockPos pos, IBlockState state, Random rand) { super.updateTick(worldIn, pos, state, rand); Block blk = Blocks.snow_layer; Block blk1 = Blocks.snow; pos = new BlockPos(pos.getX(), pos.getY(), pos.getZ());//liquid ice BlockPos pos0 = new BlockPos(pos.getX(), (pos.getY()+1), pos.getZ());//ice BlockPos pos1 = new BlockPos((pos.getX()+1), pos.getY(), pos.getZ());//ice BlockPos pos2 = new BlockPos(pos.getX()-1, pos.getY(), pos.getZ());//ice BlockPos pos3 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()+1));//ice BlockPos pos4 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()-1));//ice BlockPos pos5 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()+2));//ice BlockPos pos6 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()-2));//ice BlockPos pos7 = new BlockPos((pos.getX()+2), pos.getY(), pos.getZ()); //snow_layer BlockPos pos8 = new BlockPos(pos.getX(), (pos.getY()+2), pos.getZ());//snow state=BlockRegistry.liquid_ice.getDefaultState(); IBlockState state0=blk.getDefaultState(); IBlockState state1= Blocks.ice.getDefaultState(); IBlockState state2=blk1.getDefaultState(); worldIn.setBlockState(pos, state); worldIn.setBlockState(pos0, state1); worldIn.setBlockState(pos1, state1); worldIn.setBlockState(pos2, state1); worldIn.setBlockState(pos3, state1); worldIn.setBlockState(pos4, state1); worldIn.setBlockState(pos5, state1); worldIn.setBlockState(pos6, state1); worldIn.setBlockState(pos7, state0); worldIn.setBlockState(pos8, state2); if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11 - this.getLightOpacity()) { if (worldIn.provider.doesWaterVaporize()) { worldIn.setBlockToAir(pos); } else { this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); worldIn.setBlockState(pos, Blocks.water.getDefaultState()); } } } @Override public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { return new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.99, 1.0); } // when right click placing Liquid Ice block draws in lightning @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand){ BiomeGenBase b = BiomeRegistry.biomeFreon; if (b == BiomeRegistry.biomeFreon){ { worldIn.spawnEntityInWorld(new EntityLightningBolt(worldIn, (double)pos.getX() + 1.0D, (double)pos.getY() + 0.99D, (double)pos.getZ() + 1.0D)); } } } //not even sure what this does @Override public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { super.setBlockBoundsBasedOnState(worldIn, pos); }
August 25, 20169 yr I'm having trouble with my custom ice block that is supposed to change into 8 more blocks shortly after placed. I used #scheduleBlockUpdate in 1.7.10 and replaced it with #scheduleUpdate in 1.8 but I don't really get what's happening ...I think the third parameter is the tickRate which I set to 1, and I have tried setting setTickRandomly both true and false. What I want to happen works when #setTickRandomly is true but the blocks update truly randomly, not immediately. When I have #setTickRandomly set to false, nothing happens , ie, the custom block ice that I place does not change at all . . . Do I have the parameters wrong? Using wrong method? no idea what is the problem... this is my LiquidIce class, that is, my custom block ice: package com.glistre.glistremod.blocks; import java.util.Random; import com.glistre.glistremod.init.BiomeRegistry; import com.glistre.glistremod.init.BlockRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockIce; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; public class LiquidIceBlock extends BlockIce { public String blockName; public LiquidIceBlock() { super(); this.setUnlocalizedName(blockName); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, .99F, 1.0F); this.setTickRandomly(true); } /* @Override public int tickRate(){ return 30; }*/ public void onBlockAdded(World worldIn, BlockPos pos) { worldIn.scheduleUpdate(pos, this, 1); //was #scheduleBlockUpdate worldIn.setBlockState(pos, BlockRegistry.liquid_ice.getDefaultState()); } @Override public void updateTick( World worldIn, BlockPos pos, IBlockState state, Random rand) { super.updateTick(worldIn, pos, state, rand); Block blk = Blocks.snow_layer; Block blk1 = Blocks.snow; pos = new BlockPos(pos.getX(), pos.getY(), pos.getZ());//liquid ice BlockPos pos0 = new BlockPos(pos.getX(), (pos.getY()+1), pos.getZ());//ice BlockPos pos1 = new BlockPos((pos.getX()+1), pos.getY(), pos.getZ());//ice BlockPos pos2 = new BlockPos(pos.getX()-1, pos.getY(), pos.getZ());//ice BlockPos pos3 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()+1));//ice BlockPos pos4 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()-1));//ice BlockPos pos5 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()+2));//ice BlockPos pos6 = new BlockPos(pos.getX(), pos.getY(), (pos.getZ()-2));//ice BlockPos pos7 = new BlockPos((pos.getX()+2), pos.getY(), pos.getZ()); //snow_layer BlockPos pos8 = new BlockPos(pos.getX(), (pos.getY()+2), pos.getZ());//snow state=BlockRegistry.liquid_ice.getDefaultState(); IBlockState state0=blk.getDefaultState(); IBlockState state1= Blocks.ice.getDefaultState(); IBlockState state2=blk1.getDefaultState(); worldIn.setBlockState(pos, state); worldIn.setBlockState(pos0, state1); worldIn.setBlockState(pos1, state1); worldIn.setBlockState(pos2, state1); worldIn.setBlockState(pos3, state1); worldIn.setBlockState(pos4, state1); worldIn.setBlockState(pos5, state1); worldIn.setBlockState(pos6, state1); worldIn.setBlockState(pos7, state0); worldIn.setBlockState(pos8, state2); if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11 - this.getLightOpacity()) { if (worldIn.provider.doesWaterVaporize()) { worldIn.setBlockToAir(pos); } else { this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); worldIn.setBlockState(pos, Blocks.water.getDefaultState()); } } } @Override public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { return new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0.99, 1.0); } // when right click placing Liquid Ice block draws in lightning @Override @SideOnly(Side.CLIENT) public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand){ BiomeGenBase b = BiomeRegistry.biomeFreon; if (b == BiomeRegistry.biomeFreon){ { worldIn.spawnEntityInWorld(new EntityLightningBolt(worldIn, (double)pos.getX() + 1.0D, (double)pos.getY() + 0.99D, (double)pos.getZ() + 1.0D)); } } } //not even sure what this does @Override public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { super.setBlockBoundsBasedOnState(worldIn, pos); } Perhaps I'm not quite understanding your intentions, but why are you even bothering with the scheduling updates? If you want it to happen instantly why don't you just put your code in the onBlockAdded method? If you insist, however, you are not overriding Block#onBlockAdded, as you forgot the IBlockState parameter. Try Block#onBlockAdded(World world, BlockPos pos, IBlockState state) instead.
August 25, 20169 yr Author I originally had a slight delay which made a cool effect when I placed the block ...a freezing effect... Thanks for the quick reply ...you are MLG boss works great now I set the tickRate to 30 and it works just the way I had planned ...
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.