Posted November 21, 201311 yr Hey all, CJ here, I was recently creating a block (pretty standard) and when testing it in world I noticed something. It can be replaced with another block. When you try to place a block on top of it, or on the side of it, or anything, if you click on the block to do so, it replaces the block. Now, I went and did another block, and it doesn't do this at all. Looked, and I have the same stuff in it that affects bounding boxes and all that. Nothing. Yep, that is right, I originally messed with the BB and then took it out because it didn't fix it, but now it is gone. So their should be nothing that makes it do this, right? Well, that is what I thought. Here is the code I used for the block. package net.CJCutrone.TheGrid.block; import java.util.Random; import net.CJCutrone.TheGrid.common.TheGrid; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.Explosion; import net.minecraft.world.World; public class MaelstromSource extends Block{ public MaelstromSource(int par1, Material par2Material) { super(par1, par2Material); this.setHardness(1F); this.setLightValue(-1F); } public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity par5Entity) { par5Entity.attackEntityFrom(DamageSource.wither, 2.0F); par5Entity.setInWeb(); } public int idDropped(int par1, Random par2Random, int par3) { return 0; } public void registerIcons(IconRegister ir){ blockIcon = ir.registerIcon("TheGrid:MS"); } public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4, Explosion par5Explosion) { if(par1World.isAirBlock(par2, par3, par4)){ par1World.setBlock(par2, par3, par4, TheGrid.MaelstromSource.blockID); }if(par1World.isAirBlock(par2 + 1, par3, par4)){ par1World.setBlock(par2 + 1, par3, par4, TheGrid.MaelstromSource.blockID); }if(par1World.isAirBlock(par2, par3, par4 + 1)){ par1World.setBlock(par2, par3, par4 + 1, TheGrid.MaelstromSource.blockID); }if(par1World.isAirBlock(par2 - 1, par3, par4)){ par1World.setBlock(par2 - 1, par3, par4, TheGrid.MaelstromSource.blockID); }if(par1World.isAirBlock(par2, par3, par4 - 1)){ par1World.setBlock(par2, par3, par4 - 1, TheGrid.MaelstromSource.blockID); }if(!par1World.isAirBlock(par2, par3 + 1, par4)){ par1World.setBlock(par2, par3 + 1, par4, TheGrid.MaelstromSource.blockID); } } public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) { par1World.setBlock(par2, par3, par4, TheGrid.MaelstromSource.blockID); } }
November 21, 201311 yr Author Snow. But it shouldn't do that, should it? I mean the snow block doesn't do that....
November 21, 201311 yr Author Thanks! That seemed to fix it, but now I have another question. Before it would turn into an air block when it came into contact with a specific fluid source, how would I do it, only for that fluid source?
November 22, 201311 yr I'd suggest override: Block#onNeighborBlockUpdate(...) check if neighbour is the fluid source, then set the block to air.
November 22, 201311 yr Author And that worked! Thanks man, with the code I put in to that block it was indestructible even in creative and my entire test world was turning into it my world my explosions.
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.