Posted July 23, 201411 yr hello people, I have made a block with many bugs I don't understand. problem 1: If I restart minecraft, all the block changes to grass. problem 2: if I hit the block, the block gives the texture for grass for a half second. problem 3: If I am close enough, the block spreads as fast as I can run. But if I am further away, the block doesn't spread at all. problem 4: if an entity walks over the block, the wither effect doesnt work, it is a sort of corrupt. here is the class: package enderpower.Blocks; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import enderpower.lib.R; import enderpower.main.Enderpower; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class CursedGrass extends Block { @SideOnly(Side.CLIENT) private IIcon field_149991_b; @SideOnly(Side.CLIENT) private IIcon field_149993_M; @SideOnly(Side.CLIENT) private IIcon field_149994_N; @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { return p_149691_1_ == 1 ? this.field_149991_b : (p_149691_1_ == 0 ? Blocks.dirt.getBlockTextureFromSide(p_149691_1_) : this.blockIcon); } @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { if (p_149673_5_ == 1) { return this.field_149991_b; } else if (p_149673_5_ == 0) { return Blocks.dirt.getBlockTextureFromSide(p_149673_5_); } else { Material material = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_).getMaterial(); return material != Material.snow && material != Material.craftedSnow ? this.blockIcon : this.field_149993_M; } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); this.field_149991_b = p_149651_1_.registerIcon(this.getTextureName() + "_top"); this.field_149994_N = p_149651_1_.registerIcon(this.getTextureName() + "_side_overlay"); } protected CursedGrass() { super(Material.grass); } public void randomDisplayTick(World world, int x, int y, int z, Random random){ if(world.getBlock(x + 1, y, z) == Blocks.grass){ world.setBlock(x + 1, y, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y, z) == Blocks.grass){ world.setBlock(x - 1, y, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y, z + 1) == Blocks.grass){ world.setBlock(x + 1, y, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y, z + 1) == Blocks.grass){ world.setBlock(x - 1, y, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y, z - 1) == Blocks.grass){ world.setBlock(x + 1, y, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y, z - 1) == Blocks.grass){ world.setBlock(x - 1, y, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x, y + 1, z) == Blocks.grass){ world.setBlock(x, y + 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y + 1, z) == Blocks.grass){ world.setBlock(x + 1, y + 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y + 1, z) == Blocks.grass){ world.setBlock(x - 1, y + 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y + 1, z + 1) == Blocks.grass){ world.setBlock(x + 1, y + 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y + 1, z + 1) == Blocks.grass){ world.setBlock(x - 1, y + 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y + 1, z - 1) == Blocks.grass){ world.setBlock(x + 1, y + 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y + 1, z - 1) == Blocks.grass){ world.setBlock(x - 1, y + 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x, y - 1, z) == Blocks.grass){ world.setBlock(x, y - 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y - 1, z) == Blocks.grass){ world.setBlock(x + 1, y - 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y - 1, z) == Blocks.grass){ world.setBlock(x - 1, y - 1, z, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y - 1, z + 1) == Blocks.grass){ world.setBlock(x + 1, y - 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y - 1, z + 1) == Blocks.grass){ world.setBlock(x - 1, y - 1, z + 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x + 1, y - 1, z - 1) == Blocks.grass){ world.setBlock(x + 1, y - 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x - 1, y - 1, z - 1) == Blocks.grass){ world.setBlock(x - 1, y - 1, z - 1, EnderpowerBlocks.cursedgrass); } if(world.getBlock(x, y + 1, z) == Blocks.tallgrass){ world.setBlock(x, y + 1, z, Blocks.air); } if(world.getBlock(x, y + 1, z) == Blocks.double_plant){ world.setBlock(x, y + 1, z, Blocks.air); } if(world.getBlock(x, y + 2, z) == Blocks.double_plant){ world.setBlock(x, y + 2, z, Blocks.air); } } @Override public void onEntityWalking(World world, int x, int y, int z, Entity entity){ ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(20, 400, 0, true)); System.out.println("anyone walked over the block"); } }
July 23, 201411 yr Author I looked in the grass code. And in my class I changed randomDisplayTick in updateTick and added needs random tick. Now every problem is just fixed.
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.