public class BlockAdvancedLamp extends Block
{
private final boolean isEnable;
public BlockRedstoneLight(boolean status)
{
super(Material.redstoneLight);
this.isEnable = status;
if (status)
{
this.setLightLevel(1.0F);
}
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
public void onBlockAdded(World world, int x, int y, int z)
{
if (!world.isRemote)
{
if (this.isEnable && !world.isBlockIndirectlyGettingPowered(x, y, z))
{
world.scheduleBlockUpdate(x, y, z, this, 4);
}
else if (!this.isEnable && world.isBlockIndirectlyGettingPowered(x, y, z))
{
world.setBlock(x, y, z, YOUR_ON_LAMP_BLOCK, 0, 2);
}
}
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor Block
*/
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
if (!world.isRemote)
{
if (this.isEnable && !world.isBlockIndirectlyGettingPowered(x, y, z))
{
world.scheduleBlockUpdate(x, y, z, this, 4);
}
else if (!this.isEnable && world.isBlockIndirectlyGettingPowered(x, y, z))
{
world.setBlock(x, y, z, YOUR_ON_LAMP_BLOCK, 0, 2);
}
}
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World world, int x, int y, int z, Random rand)
{
if (!world.isRemote && this.isEnable && !world.isBlockIndirectlyGettingPowered(x, y, z))
{
world.setBlock(x, y, z, YOUR_OFF_LAMP_BLOCK, 0, 2);
}
}
public Item getItemDropped(int p_149650_1_, Random rand, int fortune)
{
return Item.getItemFromBlock(YOUR_OFF_LAMP_BLOCK);
}
/**
* Gets an item for the block being called on. Args: world, x, y, z
*/
@SideOnly(Side.CLIENT)
public Item getItem(World world, int x, int y, int z)
{
return Item.getItemFromBlock(YOUR_OFF_LAMP_BLOCK);
}
/**
* Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
* and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
*/
protected ItemStack createStackedBlock(int p_149644_1_)
{
return new ItemStack(YOUR_OFF_LAMP_BLOCK);
}
}