Guest User

Classe Bloc

a guest
Aug 24th, 2017
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.mod.androria.blocks;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import com.mod.androria.Reference;
  7. import com.mod.androria.entity.TileEntityTrappe;
  8. import com.trcgames.dbSynchronizer.DatabaseGetter;
  9. import com.trcgames.dbSynchronizer.database.DBFolder;
  10. import com.trcgames.dbSynchronizer.database.Database;
  11.  
  12. import cpw.mods.fml.relauncher.Side;
  13. import cpw.mods.fml.relauncher.SideOnly;
  14. import net.minecraft.block.Block;
  15. import net.minecraft.block.material.Material;
  16. import net.minecraft.client.renderer.texture.IIconRegister;
  17. import net.minecraft.creativetab.CreativeTabs;
  18. import net.minecraft.entity.Entity;
  19. import net.minecraft.entity.player.EntityPlayer;
  20. import net.minecraft.init.Blocks;
  21. import net.minecraft.item.Item;
  22. import net.minecraft.item.ItemStack;
  23. import net.minecraft.tileentity.TileEntity;
  24. import net.minecraft.util.AxisAlignedBB;
  25. import net.minecraft.util.ChatComponentText;
  26. import net.minecraft.util.IIcon;
  27. import net.minecraft.world.IBlockAccess;
  28. import net.minecraft.world.World;
  29.  
  30. public class Tappe extends Block
  31. {
  32. public static String[] subBlock = new String[] {"trappe", "Invisible_Block"};
  33. public IIcon[] iconArray = new IIcon[subBlock.length];
  34.  
  35. public Tappe(Material mat)
  36. {
  37. super(mat);
  38. setHardness(2.0F);
  39. setResistance(5.0F);
  40. // TODO Auto-generated constructor stub
  41. }
  42.  
  43. @Override
  44. public TileEntity createTileEntity(World world, int metadata)
  45. {
  46. TileEntityTrappe tile = new TileEntityTrappe();
  47. return tile;
  48. }
  49.  
  50. @Override
  51. public boolean hasTileEntity(int metadata)
  52. {
  53. return true;
  54. }
  55.  
  56. @Override
  57. public boolean isOpaqueCube()
  58. {
  59. return false;
  60. }
  61.  
  62. public boolean renderAsNormalBlock()
  63. {
  64. return false;
  65. }
  66.  
  67. public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
  68. {
  69. Database database = DatabaseGetter.getInstance(Reference.MOD_ID);
  70. DBFolder dossier = database.getPersistentFolder();
  71. DBFolder xpStock = dossier.getDBFolder("TrappeCooldown");
  72. if(xpStock.getInt(String.valueOf(x) + String.valueOf(y) + String.valueOf(z)) == 0)
  73. {
  74. if(this.getDamageValue(world, x, y, z) == 1)
  75. {
  76. world.setBlock(x, y, z, this, 0, 3);
  77. }
  78. else
  79. {
  80. world.setBlock(x, y, z, this, 1, 3);
  81. }
  82. xpStock.setInt(String.valueOf(x) + String.valueOf(y) + String.valueOf(z), 20);
  83. return true;
  84. }
  85. else
  86. {
  87. if(world.isRemote)
  88. player.addChatMessage(new ChatComponentText("Merci d'attendre la fin du cooldown. Encore " + String.valueOf(xpStock.getInt(String.valueOf(x) + String.valueOf(y) + String.valueOf(z)) / 20) + " secondes."));
  89. }
  90. return false;
  91. }
  92.  
  93. public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
  94. {
  95. this.setBlockBoundsBasedOnState(world, x, y, z);
  96. return super.getCollisionBoundingBoxFromPool(world, x, y, z);
  97. }
  98.  
  99. public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
  100. {
  101. this.setBounds(world.getBlockMetadata(x, y, z));
  102. }
  103.  
  104. public void setBounds(int metadata)
  105. {
  106.  
  107. if(metadata == 1)
  108. {
  109. this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.2F, 1F, 0.2F);
  110. }
  111. else
  112. {
  113. this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  114. }
  115. }
  116.  
  117. public void registerBlockIcons(IIconRegister iconRegister)
  118. {
  119. for(int i = 0; i < subBlock.length; i++)
  120. {
  121. this.iconArray[i] = iconRegister.registerIcon(Reference.MOD_ID + ":" + subBlock[i]);
  122. }
  123. }
  124.  
  125. public void getSubBlocks(Item item, CreativeTabs tabs, List list)
  126. {
  127. for(int i = 0; i < subBlock.length; i++)
  128. {
  129. list.add(new ItemStack(item, 1, i));
  130. }
  131. }
  132.  
  133. public IIcon getIcon(int side, int metadata)
  134. {
  135. if(metadata >= 0 && metadata < subBlock.length)
  136. {
  137. return this.iconArray[metadata];
  138. }
  139. return this.iconArray[0];
  140. }
  141.  
  142. public int damageDropped(int metadata)
  143. {
  144. return metadata;
  145. }
  146.  
  147. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×