Advertisement
Guest User

BlockPTest

a guest
Nov 26th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.69 KB | None | 0 0
  1. package red.veiloflegends.items;
  2.  
  3. import static net.minecraftforge.common.util.ForgeDirection.EAST;
  4. import static net.minecraftforge.common.util.ForgeDirection.NORTH;
  5. import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
  6. import static net.minecraftforge.common.util.ForgeDirection.WEST;
  7.  
  8. import java.util.List;
  9. import java.util.Random;
  10.  
  11. import net.minecraft.block.Block;
  12. import net.minecraft.block.BlockPane;
  13. import net.minecraft.block.material.Material;
  14. import net.minecraft.client.renderer.texture.IIconRegister;
  15. import net.minecraft.creativetab.CreativeTabs;
  16. import net.minecraft.entity.Entity;
  17. import net.minecraft.init.Blocks;
  18. import net.minecraft.item.Item;
  19. import net.minecraft.item.ItemStack;
  20. import net.minecraft.util.AxisAlignedBB;
  21. import net.minecraft.util.IIcon;
  22. import net.minecraft.world.IBlockAccess;
  23. import net.minecraft.world.World;
  24. import net.minecraftforge.common.util.ForgeDirection;
  25. import cpw.mods.fml.relauncher.Side;
  26. import cpw.mods.fml.relauncher.SideOnly;
  27.  
  28. public class BlockPTest extends BlockPane
  29. {
  30.     private final String field_150100_a;
  31.     private final boolean field_150099_b;
  32.     private final String field_150101_M;
  33.     @SideOnly(Side.CLIENT)
  34.     private IIcon field_150102_N;
  35.     private static final String __OBFID = "CL_00000322";
  36.  
  37.     protected BlockPTest(String p_i45432_1_, String p_i45432_2_, Material p_i45432_3_, boolean p_i45432_4_)
  38.     {
  39.         super(p_i45432_2_, p_i45432_2_, p_i45432_3_, p_i45432_4_);
  40.         this.field_150100_a = p_i45432_2_;
  41.         this.field_150099_b = p_i45432_4_;
  42.         this.field_150101_M = p_i45432_1_;
  43.         this.setCreativeTab(CreativeTabs.tabDecorations);
  44.     }
  45.  
  46.  
  47.     public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
  48.     {
  49.         return !this.field_150099_b ? null : super.getItemDropped(p_149650_1_, p_149650_2_, p_149650_3_);
  50.     }
  51.  
  52.     /**
  53.      * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
  54.      * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
  55.      */
  56.     public boolean isOpaqueCube()
  57.     {
  58.         return false;
  59.     }
  60.  
  61.     /**
  62.      * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
  63.      */
  64.     public boolean renderAsNormalBlock()
  65.     {
  66.         return false;
  67.     }
  68.  
  69.     /**
  70.      * The type of render function that is called for this block
  71.      */
  72.     public int getRenderType()
  73.     {
  74.         return this.blockMaterial == Material.glass ? 41 : 18;
  75.     }
  76.  
  77.     /**
  78.      * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
  79.      * coordinates.  Args: blockAccess, x, y, z, side
  80.      */
  81.     @SideOnly(Side.CLIENT)
  82.     public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_)
  83.     {
  84.         return p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_) == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_);
  85.     }
  86.  
  87.     /**
  88.      * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the
  89.      * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
  90.      */
  91.     public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_)
  92.     {
  93.         boolean flag  = this.canPaneConnectTo(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_ - 1, NORTH);
  94.         boolean flag1 = this.canPaneConnectTo(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_ + 1, SOUTH);
  95.         boolean flag2 = this.canPaneConnectTo(p_149743_1_, p_149743_2_ - 1, p_149743_3_, p_149743_4_, WEST );
  96.         boolean flag3 = this.canPaneConnectTo(p_149743_1_, p_149743_2_ + 1, p_149743_3_, p_149743_4_, EAST );
  97.  
  98.         if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
  99.         {
  100.             if (flag2 && !flag3)
  101.             {
  102.                 this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
  103.                 super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
  104.             }
  105.             else if (!flag2 && flag3)
  106.             {
  107.                 this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
  108.                 super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
  109.             }
  110.         }
  111.         else
  112.         {
  113.             this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
  114.             super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
  115.         }
  116.  
  117.         if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
  118.         {
  119.             if (flag && !flag1)
  120.             {
  121.                 this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
  122.                 super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
  123.             }
  124.             else if (!flag && flag1)
  125.             {
  126.                 this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
  127.                 super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
  128.             }
  129.         }
  130.         else
  131.         {
  132.             this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
  133.             super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
  134.         }
  135.     }
  136.  
  137.     /**
  138.      * Sets the block's bounds for rendering it as an item
  139.      */
  140.     public void setBlockBoundsForItemRender()
  141.     {
  142.         this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  143.     }
  144.  
  145.     /**
  146.      * Updates the blocks bounds based on its current state. Args: world, x, y, z
  147.      */
  148.     public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
  149.     {
  150.         float f = 0.4375F;
  151.         float f1 = 0.5625F;
  152.         float f2 = 0.4375F;
  153.         float f3 = 0.5625F;
  154.         boolean flag  = this.canPaneConnectTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ - 1, NORTH);
  155.         boolean flag1 = this.canPaneConnectTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ + 1, SOUTH);
  156.         boolean flag2 = this.canPaneConnectTo(p_149719_1_, p_149719_2_ - 1, p_149719_3_, p_149719_4_, WEST );
  157.         boolean flag3 = this.canPaneConnectTo(p_149719_1_, p_149719_2_ + 1, p_149719_3_, p_149719_4_, EAST );
  158.  
  159.         if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
  160.         {
  161.             if (flag2 && !flag3)
  162.             {
  163.                 f = 0.0F;
  164.             }
  165.             else if (!flag2 && flag3)
  166.             {
  167.                 f1 = 1.0F;
  168.             }
  169.         }
  170.         else
  171.         {
  172.             f = 0.0F;
  173.             f1 = 1.0F;
  174.         }
  175.  
  176.         if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
  177.         {
  178.             if (flag && !flag1)
  179.             {
  180.                 f2 = 0.0F;
  181.             }
  182.             else if (!flag && flag1)
  183.             {
  184.                 f3 = 1.0F;
  185.             }
  186.         }
  187.         else
  188.         {
  189.             f2 = 0.0F;
  190.             f3 = 1.0F;
  191.         }
  192.  
  193.         this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
  194.     }
  195.  
  196.  
  197.  
  198.     @SideOnly(Side.CLIENT)
  199.     public IIcon func_150097_e()
  200.     {
  201.         return this.field_150102_N;
  202.     }
  203.  
  204.     /**
  205.      * Return true if a player with Silk Touch can harvest this block directly, and not its normal drops.
  206.      */
  207.     protected boolean canSilkHarvest()
  208.     {
  209.         return true;
  210.     }
  211.  
  212.     /**
  213.      * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage
  214.      * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null.
  215.      */
  216.     protected ItemStack createStackedBlock(int p_149644_1_)
  217.     {
  218.         return new ItemStack(Item.getItemFromBlock(this), 1, p_149644_1_);
  219.     }
  220.  
  221.     @SideOnly(Side.CLIENT)
  222.     public void registerBlockIcons(IIconRegister p_149651_1_)
  223.     {
  224.         this.blockIcon = p_149651_1_.registerIcon(this.field_150101_M);
  225.         this.field_150102_N = p_149651_1_.registerIcon(this.field_150100_a);
  226.     }
  227.  
  228.     public boolean canPaneConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir)
  229.     {
  230.         return canPaneConnectToBlock(world.getBlock(x, y, z)) ||
  231.                 world.isSideSolid(x, y, z, dir.getOpposite(), false);
  232.     }
  233. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement