package me.mackan.random_mod.blocks; import me.mackan.random_mod.Main; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.common.registry.GameRegistry; public class BlackLight extends Block{ private String name = "blacklight"; public BlackLight(){ super(Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); this.setBlockName(Main.MODID+"_"+name); this.setBlockTextureName(Main.MODID+":"+name); this.setStepSound(soundTypeStone); this.lightValue = 15; this.blockHardness = (float)1.5; GameRegistry.registerBlock(this, name); } @Override public boolean onBlockActivated(World wor, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { int v = this.getLightValue(wor, x, y, z); if(player.isSneaking()){ ChatComponentText txt = new ChatComponentText("Light level is "+v); player.addChatComponentMessage(txt); }else{ if(v > 1){ v = v-1; wor.setBlockMetadataWithNotify(x, y, z, v, 0); }else{ v = 15; wor.setBlockMetadataWithNotify(x, y, z, v, 0); } } return true; } @Override public int getLightValue(IBlockAccess w, int x, int y, int z) { w.getBlock(x, y, z).setLightLevel((float)w.getBlockMetadata(x, y, z)); return super.getLightValue(w, x, y, z); } }