You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.3 KiB
Java
142 lines
4.3 KiB
Java
package net.minecraft.block;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import java.util.Random;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.tileentity.TileEntityDaylightDetector;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.EnumSkyBlock;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockDaylightDetector extends BlockContainer
|
|
{
|
|
private IIcon[] field_149958_a = new IIcon[2];
|
|
private static final String __OBFID = "CL_00000223";
|
|
|
|
public BlockDaylightDetector()
|
|
{
|
|
super(Material.wood);
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
|
|
this.setCreativeTab(CreativeTabs.tabRedstone);
|
|
}
|
|
|
|
/**
|
|
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
|
*/
|
|
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, int x, int y, int z)
|
|
{
|
|
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
|
|
}
|
|
|
|
public int isProvidingWeakPower(IBlockAccess worldIn, int x, int y, int z, int side)
|
|
{
|
|
return worldIn.getBlockMetadata(x, y, z);
|
|
}
|
|
|
|
/**
|
|
* Ticks the block if it's been scheduled
|
|
*/
|
|
public void updateTick(World worldIn, int x, int y, int z, Random random) {}
|
|
|
|
/**
|
|
* 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 worldIn, int x, int y, int z, Block neighbor) {}
|
|
|
|
/**
|
|
* Called whenever the block is added into the world. Args: world, x, y, z
|
|
*/
|
|
public void onBlockAdded(World worldIn, int x, int y, int z) {}
|
|
|
|
public void func_149957_e(World p_149957_1_, int p_149957_2_, int p_149957_3_, int p_149957_4_)
|
|
{
|
|
if (!p_149957_1_.provider.hasNoSky)
|
|
{
|
|
int l = p_149957_1_.getBlockMetadata(p_149957_2_, p_149957_3_, p_149957_4_);
|
|
int i1 = p_149957_1_.getSavedLightValue(EnumSkyBlock.Sky, p_149957_2_, p_149957_3_, p_149957_4_) - p_149957_1_.skylightSubtracted;
|
|
float f = p_149957_1_.getCelestialAngleRadians(1.0F);
|
|
|
|
if (f < (float)Math.PI)
|
|
{
|
|
f += (0.0F - f) * 0.2F;
|
|
}
|
|
else
|
|
{
|
|
f += (((float)Math.PI * 2F) - f) * 0.2F;
|
|
}
|
|
|
|
i1 = Math.round((float)i1 * MathHelper.cos(f));
|
|
|
|
if (i1 < 0)
|
|
{
|
|
i1 = 0;
|
|
}
|
|
|
|
if (i1 > 15)
|
|
{
|
|
i1 = 15;
|
|
}
|
|
|
|
if (l != i1)
|
|
{
|
|
p_149957_1_.setBlockMetadataWithNotify(p_149957_2_, p_149957_3_, p_149957_4_, i1, 3);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
|
*/
|
|
public boolean renderAsNormalBlock()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
|
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
|
*/
|
|
public boolean isOpaqueCube()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Can this block provide power. Only wire currently seems to have this change based on its state.
|
|
*/
|
|
public boolean canProvidePower()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Returns a new instance of a block's tile entity class. Called on placing the block.
|
|
*/
|
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
|
{
|
|
return new TileEntityDaylightDetector();
|
|
}
|
|
|
|
/**
|
|
* Gets the block's texture. Args: side, meta
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon(int side, int meta)
|
|
{
|
|
return side == 1 ? this.field_149958_a[0] : this.field_149958_a[1];
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public void registerBlockIcons(IIconRegister reg)
|
|
{
|
|
this.field_149958_a[0] = reg.registerIcon(this.getTextureName() + "_top");
|
|
this.field_149958_a[1] = reg.registerIcon(this.getTextureName() + "_side");
|
|
}
|
|
} |