Advertisement
WackoMcGoose

Untitled

Jan 26th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.26 KB | None | 0 0
  1. //mod_EvilMinecraft_Fragment.java:
  2.  
  3. package net.minecraft.src;
  4.  
  5. import org.lwjgl.opengl.GL11;
  6.  
  7. public class mod_EvilMinecraft_Fragment extends BaseMod
  8. {
  9.     public static int planterPotModelID;
  10.     public static int hypercubeModelID;
  11.     public static Block planterPot;
  12.     public static Block hypercube;
  13.     public static Item itemPlanterPot;
  14.     public mod_EvilMinecraft_Fragment()
  15.     {
  16.         //BlockPlanterPot
  17.         int planterPotID = 160;
  18.         int planterTextureIndex = 72; //Clay texture
  19.         planterPot = new BlockPlanterPot(planterPotID, planterTextureIndex, Material.glass);
  20.         planterPot.setHardness(0.2F);
  21.         planterPot.setBlockName("planterPot");
  22.         ModLoader.RegisterBlock(planterPot);
  23.         ModLoader.AddName(planterPot, "Planter Pot");
  24.        
  25.         //ItemPlanterPot
  26.         int itemPlanterPotID = 500 - 256;
  27.         int itemPlanterTextureIndex = 156; //Cauldron
  28.         itemPlanterPot = new ItemPlanterPot(itemPlanterPotID);
  29.         itemPlanterPot.setIconIndex(itemPlanterTextureIndex);
  30.         itemPlanterPot.setItemName("itemPlanterPot");
  31.         ModLoader.AddName(itemPlanterPot, "Planter Pot");
  32.         ModLoader.AddSmelting(Block.blockClay.blockID, new ItemStack(itemPlanterPot));
  33.        
  34.         //BlockHypercube
  35.         int hypercubeID = 161;
  36.         int hypercubeTextureIndex = 14; //NetherPortal?
  37.         hypercube = new BlockHypercube(hypercubeID, hypercubeTextureIndex, Material.portal);
  38.         hypercube.setBlockName("hypercube");
  39.         ModLoader.RegisterBlock(hypercube);
  40.         ModLoader.AddName(hypercube, "Hyper Cube");
  41.         ModLoader.AddRecipe(new ItemStack(hypercube), new Object[]{"B", Character.valueOf('B'), Block.bedrock});
  42.     }
  43.    
  44.     public String getVersion()
  45.     {
  46.         return "1.1.0";
  47.     }
  48.    
  49.     public void load()
  50.     {
  51.         planterPotModelID = ModLoader.getUniqueBlockModelID(this, true);
  52.         hypercubeModelID = ModLoader.getUniqueBlockModelID(this, true);
  53.     }
  54.    
  55.     private boolean RenderPlanterPotInWorld(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block)
  56.     {
  57.         //Base
  58.         block.setBlockBounds(0.1875F, 0.0F, 0.1875F, 0.8125F, 0.0625F, 0.8125F);
  59.         renderblocks.renderStandardBlock(block, i, j, k);
  60.         //Inner sides, also collision box
  61.         block.setBlockBounds(0.1875F, 0.0F, 0.125F, 0.875F, 0.8125F, 0.1875F);
  62.         renderblocks.renderStandardBlock(block, i, j, k);
  63.         block.setBlockBounds(0.1875F, 0.0F, 0.8125F, 0.875F, 0.8125F, 0.875F);
  64.         renderblocks.renderStandardBlock(block, i, j, k);
  65.         block.setBlockBounds(0.125F, 0.0F, 0.1875F, 0.1875F, 0.875F, 0.8125F);
  66.         renderblocks.renderStandardBlock(block, i, j, k);
  67.         block.setBlockBounds(0.8125F, 0.0F, 0.1875F, 0.875F, 0.875F, 0.8125F);
  68.         renderblocks.renderStandardBlock(block, i, j, k);
  69.         //Inner side-lip
  70.         block.setBlockBounds(0.125F, 0.8125F, 0.125F, 0.875F, 0.875F, 0.1875F);
  71.         renderblocks.renderStandardBlock(block, i, j, k);
  72.         block.setBlockBounds(0.125F, 0.8125F, 0.8125F, 0.875F, 0.875F, 0.875F);
  73.         renderblocks.renderStandardBlock(block, i, j, k);
  74.         //Outer sides
  75.         block.setBlockBounds(0.25F, 0.0F, 0.0625F, 0.75F, 0.8125F, 0.125F);
  76.         renderblocks.renderStandardBlock(block, i, j, k);
  77.         block.setBlockBounds(0.25F, 0.0F, 0.875F, 0.75F, 0.8125F, 0.9375F);
  78.         renderblocks.renderStandardBlock(block, i, j, k);
  79.         block.setBlockBounds(0.0625F, 0.0F, 0.25F, 0.125F, 0.8125F, 0.75F);
  80.         renderblocks.renderStandardBlock(block, i, j, k);
  81.         block.setBlockBounds(0.875F, 0.0F, 0.25F, 0.9375F, 0.8125F, 0.75F);
  82.         renderblocks.renderStandardBlock(block, i, j, k);
  83.         //Inner lip
  84.         block.setBlockBounds(0.1875F, 0.8125F, 0.0625F, 0.8125F, 0.875F, 0.125F);
  85.         renderblocks.renderStandardBlock(block, i, j, k);
  86.         block.setBlockBounds(0.1875F, 0.8125F, 0.875F, 0.8125F, 0.875F, 0.9375F);
  87.         renderblocks.renderStandardBlock(block, i, j, k);
  88.         block.setBlockBounds(0.0625F, 0.8125F, 0.1875F, 0.125F, 0.875F, 0.8125F);
  89.         renderblocks.renderStandardBlock(block, i, j, k);
  90.         block.setBlockBounds(0.875F, 0.8125F, 0.1875F, 0.9375F, 0.875F, 0.8125F);
  91.         renderblocks.renderStandardBlock(block, i, j, k);
  92.         //Outer lip
  93.         block.setBlockBounds(0.25F, 0.8125F, 0.0F, 0.75F, 0.875F, 0.0625F);
  94.         renderblocks.renderStandardBlock(block, i, j, k);
  95.         block.setBlockBounds(0.25F, 0.8125F, 0.9375F, 0.75F, 0.875F, 1.0F);
  96.         renderblocks.renderStandardBlock(block, i, j, k);
  97.         block.setBlockBounds(0.0F, 0.8125F, 0.25F, 0.0625F, 0.875F, 0.75F);
  98.         renderblocks.renderStandardBlock(block, i, j, k);
  99.         block.setBlockBounds(0.9375F, 0.8125F, 0.25F, 1.0F, 0.875F, 0.75F);
  100.         renderblocks.renderStandardBlock(block, i, j, k);
  101.         return false;
  102.     }
  103.    
  104.     private boolean RenderHypercubeInWorld(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block)
  105.     {
  106.         for(int layer = 0; layer < 7; layer++)
  107.         {
  108.             float offset = (float)layer / 16F;
  109.             block.setBlockBounds(0.0F + offset, 0.0F + offset, 0.0F + offset, 0.0625F + offset, 0.0625F + offset, 1.0F - offset);
  110.             renderblocks.renderStandardBlock(block, i, j, k);
  111.             block.setBlockBounds(0.9275F - offset, 0.0F + offset, 0.0F + offset, 1.0F - offset, 0.0625F + offset, 1.0F - offset);
  112.             renderblocks.renderStandardBlock(block, i, j, k);
  113.             block.setBlockBounds(0.0F + offset, 0.9375F - offset, 0.0F + offset, 0.0625F + offset, 1.0F - offset, 1.0F - offset);
  114.             renderblocks.renderStandardBlock(block, i, j, k);
  115.             block.setBlockBounds(0.9375F - offset, 0.9375F - offset, 0.0F + offset, 1.0F - offset, 1.0F - offset, 1.0F - offset);
  116.             renderblocks.renderStandardBlock(block, i, j, k);
  117.            
  118.             block.setBlockBounds(0.0625F + offset, 0.0F + offset, 0.0F + offset, 0.9375F - offset, 0.0625F + offset, 0.0625F + offset);
  119.             renderblocks.renderStandardBlock(block, i, j, k);
  120.             block.setBlockBounds(0.0625F + offset, 0.0F + offset, 0.9375F - offset, 0.9375F - offset, 0.0625F + offset, 1.0F - offset);
  121.             renderblocks.renderStandardBlock(block, i, j, k);
  122.             block.setBlockBounds(0.0625F + offset, 0.9375F - offset, 0.0F + offset, 0.9375F - offset, 1.0F - offset, 0.0625F + offset);
  123.             renderblocks.renderStandardBlock(block, i, j, k);
  124.             block.setBlockBounds(0.0625F + offset, 0.9375F - offset, 0.9375F - offset, 0.9375F - offset, 1.0F - offset, 1.0F - offset);
  125.             renderblocks.renderStandardBlock(block, i, j, k);
  126.            
  127.             block.setBlockBounds(0.0F + offset, 0.0625F + offset, 0.0F + offset, 0.0625F + offset, 0.9375F - offset, 0.0625F + offset);
  128.             renderblocks.renderStandardBlock(block, i, j, k);
  129.             block.setBlockBounds(0.0F + offset, 0.0625F + offset, 0.9375F - offset, 0.0625F + offset, 0.9375F - offset, 1.0F - offset);
  130.             renderblocks.renderStandardBlock(block, i, j, k);
  131.             block.setBlockBounds(0.9375F - offset, 0.0625F + offset, 0.0F + offset, 1.0F - offset, 0.9375F - offset, 0.0625F + offset);
  132.             renderblocks.renderStandardBlock(block, i, j, k);
  133.             block.setBlockBounds(0.9375F - offset, 0.0625F + offset, 0.9375F - offset, 1.0F - offset, 0.9375F - offset, 1.0F - offset);
  134.             renderblocks.renderStandardBlock(block, i, j, k);
  135.         }
  136.         block.setBlockBounds(0.4375F, 0.4375F, 0.4375F, 0.5625F, 0.5625F, 0.5625F);
  137.         renderblocks.renderStandardBlock(block, i, j, k);
  138.         return false;
  139.     }
  140.    
  141.     public boolean RenderWorldBlock(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l)
  142.     {
  143.         if(l == planterPotModelID)
  144.         {
  145.             return RenderPlanterPotInWorld(renderblocks, iblockaccess, i, j, k, block);
  146.         }
  147.         else if(l == hypercubeModelID)
  148.         {
  149.             return RenderHypercubeInWorld(renderblocks, iblockaccess, i, j, k, block);
  150.         }
  151.         else
  152.         {
  153.             return false;
  154.         }
  155.     }
  156. }
  157.  
  158. -----------------------------------------------
  159. //BlockPlanterPot.java:
  160.  
  161. package net.minecraft.src;
  162.  
  163. import java.util.ArrayList;
  164. import java.util.Random;
  165.  
  166. public class BlockPlanterPot extends Block
  167. {
  168.     public BlockPlanterPot(int id, int textureIndex, Material mat)
  169.     {
  170.         super(id, textureIndex, mat);
  171.     }
  172.    
  173.     public void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist)
  174.     {
  175.         setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.0625F, 0.875F);
  176.         super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
  177.         setBlockBounds(0.125F, 0.0625F, 0.125F, 0.875F, 0.875F, 0.1875F);
  178.         super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
  179.         setBlockBounds(0.125F, 0.0625F, 0.8125F, 0.875F, 0.875F, 0.875F);
  180.         super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
  181.         setBlockBounds(0.125F, 0.0625F, 0.1875F, 0.1875F, 0.875F, 0.8125F);
  182.         super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
  183.         setBlockBounds(0.8125F, 0.0625F, 0.1875F, 0.875F, 0.875F, 0.8125F);
  184.         super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
  185.         setBlockBoundsForItemRender();
  186.     }
  187.    
  188.     public void setBlockBoundsForItemRender() //Controls hitbox!
  189.     {
  190.         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.875F, 1.0F);
  191.     }
  192.  
  193.     public int getRenderType()
  194.     {
  195.         return mod_EvilMinecraft_Fragment.planterPotModelID;
  196.     }
  197.    
  198.     public boolean isOpaqueCube()
  199.     {
  200.         return false;
  201.     }
  202.  
  203.     public boolean renderAsNormalBlock()
  204.     {
  205.         return false;
  206.     }
  207.    
  208.     public int colorMultiplier(IBlockAccess iblockaccess, int i, int j, int k)
  209.     {
  210.         return 0xff2020;
  211.     }
  212.    
  213.     public int idDropped(int i, Random random, int j)
  214.     {
  215.         return mod_EvilMinecraft_Fragment.itemPlanterPot.shiftedIndex;
  216.     }
  217.  
  218.     public int quantityDropped(Random random)
  219.     {
  220.         return 1;
  221.     }
  222. }
  223.  
  224. ----------------------------------
  225. //ItemPlanterPot.java:
  226. package net.minecraft.src;
  227.  
  228. public class ItemPlanterPot extends Item
  229. {
  230.     public ItemPlanterPot(int i)
  231.     {
  232.         super(i);
  233.     }
  234.  
  235.     public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
  236.     {
  237.         if (world.getBlockId(i, j, k) != Block.snow.blockID)
  238.         {
  239.             if (l == 0)
  240.             {
  241.                 j--;
  242.             }
  243.             if (l == 1)
  244.             {
  245.                 j++;
  246.             }
  247.             if (l == 2)
  248.             {
  249.                 k--;
  250.             }
  251.             if (l == 3)
  252.             {
  253.                 k++;
  254.             }
  255.             if (l == 4)
  256.             {
  257.                 i--;
  258.             }
  259.             if (l == 5)
  260.             {
  261.                 i++;
  262.             }
  263.             if (!world.isAirBlock(i, j, k))
  264.             {
  265.                 return false;
  266.             }
  267.         }
  268.         if (!entityplayer.canPlayerEdit(i, j, k))
  269.         {
  270.             return false;
  271.         }
  272.         if (mod_EvilMinecraft_Fragment.planterPot.canPlaceBlockAt(world, i, j, k))
  273.         {
  274.             itemstack.stackSize--;
  275.             world.setBlockWithNotify(i, j, k, mod_EvilMinecraft_Fragment.planterPot.blockID);
  276.         }
  277.         return true;
  278.     }
  279.    
  280.     public int getColorFromDamage(int i, int j)
  281.     {
  282.         return 0xff2020;
  283.     }
  284. }
  285.  
  286. ----------------------------------
  287. //BlockHypercube.java:
  288. package net.minecraft.src;
  289.  
  290. public class BlockHypercube extends Block
  291. {
  292.     public BlockHypercube(int id, int textureIndex, Material mat)
  293.     {
  294.         super(id, textureIndex, mat);
  295.     }
  296.    
  297.     public void setBlockBoundsForItemRender()
  298.     {
  299.         setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  300.     }
  301.    
  302.     public int getRenderType()
  303.     {
  304.         return mod_EvilMinecraft_Fragment.hypercubeModelID;
  305.     }
  306.    
  307.     public boolean isOpaqueCube()
  308.     {
  309.         return false;
  310.     }
  311.  
  312.     public boolean renderAsNormalBlock()
  313.     {
  314.         return false;
  315.     }
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement