Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.89 KB | None | 0 0
  1. package com.nextlevelminecraft.cad435.objloader.ColoredLamp;
  2.  
  3.  
  4. //Block_Class
  5.  
  6. import com.nextlevelminecraft.cad435.TNL_Client_Dependencies.MoreStuff.MoreTab;
  7. import com.nextlevelminecraft.cad435.TNL_Client_Dependencies.libs.CLC_API_RGBWuerfel;
  8. import cpw.mods.fml.relauncher.Side;
  9. import cpw.mods.fml.relauncher.SideOnly;
  10. import net.minecraft.block.BlockContainer;
  11. import net.minecraft.block.material.Material;
  12. import net.minecraft.client.renderer.texture.IIconRegister;
  13. import net.minecraft.tileentity.TileEntity;
  14. import net.minecraft.util.IIcon;
  15. import net.minecraft.world.IBlockAccess;
  16. import net.minecraft.world.World;
  17.  
  18.  
  19.  
  20. public class LampBlock extends BlockContainer {
  21.     public LampBlock(Material mat) {
  22.         super(mat);
  23.         this.setLightLevel(1.0F);
  24.         this.setBlockTextureName("objloader:clear");
  25.         this.setCreativeTab(MoreTab.MoreItemTab);
  26.         this.setHardness(0.3F);
  27.         this.lightValue = CLC_API_RGBWuerfel.makeRGBLightValue(255, 255, 255, 15);//this made all right, it returns the right int!
  28.         this.needsRandomTick = true;
  29.  
  30.     }
  31.  
  32.     public TileEntity createNewTileEntity(World world, int i) {
  33.         return new LampTileEntity();
  34.     }
  35.  
  36.     @Override
  37.     public boolean isOpaqueCube() {
  38.         return false;
  39.     }
  40.  
  41.     @Override
  42.     public boolean renderAsNormalBlock() {
  43.         return false;
  44.     }
  45.  
  46.     @Override
  47.     @SideOnly(Side.CLIENT)
  48.     public int getLightValue(IBlockAccess world, int x, int y, int z)
  49.     {
  50.  
  51.         try {
  52.  
  53.             LampTileEntity tile = (LampTileEntity) world.getTileEntity(x, y, z);
  54.  
  55.             if (tile.getWorldObj().isRemote)
  56.                 System.out.println(tile.RGB_VALUES.toString() + "@" + x + ";" + y + ";" + z + "@Server");
  57.             else
  58.                 System.out.println(tile.RGB_VALUES.toString() + "@" + x + ";" + y + ";" + z + "@Client");
  59.  
  60.             int[] color = new int[]{255,255,255};
  61.  
  62.  
  63.             if (tile != null) {
  64.                 color = tile.RGB_VALUES.toIntArray();
  65.  
  66.             }
  67.  
  68.             return CLC_API_RGBWuerfel.makeRGBLightValue(color[0], color[1], color[2], 15);
  69.         }
  70.         catch (Exception e)
  71.         {
  72.             System.out.println("ERORR!");
  73.             return CLC_API_RGBWuerfel.makeRGBLightValue(255, 255, 255, 15);
  74.         }
  75.         finally {
  76.  
  77.         }
  78.  
  79.     }
  80.  
  81.  
  82.     @Override
  83.     public int damageDropped (int metadata) {
  84.         return metadata;
  85.     }
  86.  
  87.  
  88.  
  89.  
  90.     public static IIcon[] icons = new IIcon[14];
  91.  
  92.  
  93.     @Override
  94.     @SideOnly(Side.CLIENT)
  95.     public void registerBlockIcons(IIconRegister reg) {
  96.         for (int i = 0; i < 13; i ++) {
  97.             this.icons[i] = reg.registerIcon("objloader:ColoredLamp/" + i);
  98.         }
  99.         this.icons[13] = reg.registerIcon("objloader:clear");
  100.     }
  101.  
  102.  
  103.     @Override
  104.     @SideOnly(Side.CLIENT)
  105.     public IIcon getIcon(int side, int meta) {
  106.         //if (meta > 12)
  107.         //    meta = 0;
  108.  
  109.         return icons[0];
  110.  
  111.         //return icons[13];
  112.  
  113.     }
  114.  
  115.  
  116.     @Override
  117.     @SideOnly(Side.CLIENT)
  118.     public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_)
  119.     {
  120.         return icons[13];
  121.     }
  122.  
  123.  
  124.     @Override
  125.     public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
  126.     {
  127.         //super.onBlockPlaced(world,x,y,z,side,hitX,hitY,hitZ,metadata);
  128.  
  129.         try {
  130.  
  131.             LampTileEntity entity = (LampTileEntity) world.getTileEntity(x, y, z);
  132.             entity.CustomupdateEntity();
  133.         }
  134.         catch (Exception e){}
  135.  
  136.         return metadata;
  137.     }
  138.  
  139.  
  140.  
  141.  
  142.     /*@Override
  143.     @SideOnly(Side.CLIENT)
  144.     public void getSubBlocks(Item block, CreativeTabs p_149666_2_, List list) {
  145.  
  146.         for (int i = 0; i < ItemLampBlock.Colors.length; i++) {
  147.             list.add(new ItemStack(block, 1, i));
  148.         }
  149.     }*/
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement