Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import java.util.ArrayList;
- import java.util.Random;
- public class BlockGrass extends Block
- {
- protected BlockGrass(int i)
- {
- super(i, Material.grass);
- blockIndexInTexture = 3;
- setTickOnLoad(true);
- }
- public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
- {
- return super.getCollisionBoundingBoxFromPool(world, i, j, k);
- }
- public void getCollidingBoundingBoxes(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist)
- {
- int northBlockID = world.getBlockId(i, j, k + 1);
- if(northBlockID == 0) { northBlockID = 36; }
- int eastBlockID = world.getBlockId(i + 1, j, k);
- if(eastBlockID == 0) { eastBlockID = 36; }
- int southBlockID = world.getBlockId(i, j, k - 1);
- if(southBlockID == 0) { southBlockID = 36; }
- int westBlockID = world.getBlockId(i - 1, j, k);
- if(westBlockID == 0) { westBlockID = 36; }
- int northwestBlockID = world.getBlockId(i - 1, j, k + 1);
- if(northwestBlockID == 0) { northwestBlockID = 36; }
- int northeastBlockID = world.getBlockId(i + 1, j, k + 1);
- if(northeastBlockID == 0) { northeastBlockID = 36; }
- int southeastBlockID = world.getBlockId(i + 1, j, k - 1);
- if(southeastBlockID == 0) { southeastBlockID = 36; }
- int southwestBlockID = world.getBlockId(i - 1, j, k - 1);
- if(southwestBlockID == 0) { southwestBlockID = 36; }
- //System.out.println((new StringBuilder()).append("n=").append(northBlockID).append(" e=").append(eastBlockID).append(" s=").append(southBlockID).append(" w=").append(westBlockID).toString());
- boolean blocksToNW = ((Block.blocksList[northBlockID].isOpaqueCube() || northBlockID == Block.grass.blockID) && (Block.blocksList[westBlockID].isOpaqueCube() || westBlockID == Block.grass.blockID) && (Block.blocksList[northwestBlockID].isOpaqueCube() || northwestBlockID == Block.grass.blockID));
- boolean blocksToNE = ((Block.blocksList[northBlockID].isOpaqueCube() || northBlockID == Block.grass.blockID) && (Block.blocksList[eastBlockID].isOpaqueCube() || eastBlockID == Block.grass.blockID) && (Block.blocksList[northeastBlockID].isOpaqueCube() || northeastBlockID == Block.grass.blockID));
- boolean blocksToSE = ((Block.blocksList[southBlockID].isOpaqueCube() || southBlockID == Block.grass.blockID) && (Block.blocksList[eastBlockID].isOpaqueCube() || eastBlockID == Block.grass.blockID) && (Block.blocksList[southeastBlockID].isOpaqueCube() || southeastBlockID == Block.grass.blockID));
- boolean blocksToSW = ((Block.blocksList[southBlockID].isOpaqueCube() || southBlockID == Block.grass.blockID) && (Block.blocksList[westBlockID].isOpaqueCube() || westBlockID == Block.grass.blockID) && (Block.blocksList[southwestBlockID].isOpaqueCube() || southwestBlockID == Block.grass.blockID));
- //Default case - Grass surrounded by solid blocks on all sides, or has something on top
- if(((Block.blocksList[northBlockID].isOpaqueCube()) && (Block.blocksList[eastBlockID].isOpaqueCube()) && (Block.blocksList[southBlockID].isOpaqueCube()) && (Block.blocksList[westBlockID].isOpaqueCube())) || (world.getBlockId(i, j + 1, k) != 0))
- {
- setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
- super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
- world.setBlockMetadataWithNotify(i, j, k, 0);
- }
- else
- {
- //Base half-layer, placed even if grass has no solid blocks around it
- setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
- super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
- //Corner cases, NOT mutually exclusive (will usually have more than one!)
- if(blocksToNW)
- {
- setBlockBounds(0.0F, 0.5F, 0.5F, 0.5F, 1.0F, 1.0F);
- super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
- }
- if(blocksToNE)
- {
- setBlockBounds(0.5F, 0.5F, 0.5F, 1.0F, 1.0F, 1.0F);
- super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
- }
- if(blocksToSE)
- {
- setBlockBounds(0.5F, 0.5F, 0.0F, 1.0F, 1.0F, 0.5F);
- super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
- }
- if(blocksToSW)
- {
- setBlockBounds(0.0F, 0.5F, 0.0F, 0.5F, 1.0F, 0.5F);
- super.getCollidingBoundingBoxes(world, i, j, k, axisalignedbb, arraylist);
- }
- world.setBlockMetadataWithNotify(i, j, k, 1); //Signal for custom render and to use doubleSidegrass.png
- }
- setBlockBoundsForItemRender();
- }
- public static boolean isCustomRender(IBlockAccess iblockaccess, int i, int j, int k)
- {
- int northBlockID = iblockaccess.getBlockId(i, j, k + 1);
- if(northBlockID == 0) { northBlockID = 36; }
- int eastBlockID = iblockaccess.getBlockId(i + 1, j, k);
- if(eastBlockID == 0) { eastBlockID = 36; }
- int southBlockID = iblockaccess.getBlockId(i, j, k - 1);
- if(southBlockID == 0) { southBlockID = 36; }
- int westBlockID = iblockaccess.getBlockId(i - 1, j, k);
- if(westBlockID == 0) { westBlockID = 36; }
- int northwestBlockID = iblockaccess.getBlockId(i - 1, j, k + 1);
- if(northwestBlockID == 0) { northwestBlockID = 36; }
- int northeastBlockID = iblockaccess.getBlockId(i + 1, j, k + 1);
- if(northeastBlockID == 0) { northeastBlockID = 36; }
- int southeastBlockID = iblockaccess.getBlockId(i + 1, j, k - 1);
- if(southeastBlockID == 0) { southeastBlockID = 36; }
- int southwestBlockID = iblockaccess.getBlockId(i - 1, j, k - 1);
- if(southwestBlockID == 0) { southwestBlockID = 36; }
- //System.out.println((new StringBuilder()).append("n=").append(northBlockID).append(" e=").append(eastBlockID).append(" s=").append(southBlockID).append(" w=").append(westBlockID).toString());
- boolean blocksToNW = ((Block.blocksList[northBlockID].isOpaqueCube() || northBlockID == Block.grass.blockID) && (Block.blocksList[westBlockID].isOpaqueCube() || westBlockID == Block.grass.blockID) && (Block.blocksList[northwestBlockID].isOpaqueCube() || northwestBlockID == Block.grass.blockID));
- boolean blocksToNE = ((Block.blocksList[northBlockID].isOpaqueCube() || northBlockID == Block.grass.blockID) && (Block.blocksList[eastBlockID].isOpaqueCube() || eastBlockID == Block.grass.blockID) && (Block.blocksList[northeastBlockID].isOpaqueCube() || northeastBlockID == Block.grass.blockID));
- boolean blocksToSE = ((Block.blocksList[southBlockID].isOpaqueCube() || southBlockID == Block.grass.blockID) && (Block.blocksList[eastBlockID].isOpaqueCube() || eastBlockID == Block.grass.blockID) && (Block.blocksList[southeastBlockID].isOpaqueCube() || southeastBlockID == Block.grass.blockID));
- boolean blocksToSW = ((Block.blocksList[southBlockID].isOpaqueCube() || southBlockID == Block.grass.blockID) && (Block.blocksList[westBlockID].isOpaqueCube() || westBlockID == Block.grass.blockID) && (Block.blocksList[southwestBlockID].isOpaqueCube() || southwestBlockID == Block.grass.blockID));
- //Default case - Grass surrounded by solid blocks on all sides, or has something on top
- if(((Block.blocksList[northBlockID].isOpaqueCube()) && (Block.blocksList[eastBlockID].isOpaqueCube()) && (Block.blocksList[southBlockID].isOpaqueCube()) && (Block.blocksList[westBlockID].isOpaqueCube())) || (iblockaccess.getBlockId(i, j + 1, k) != 0))
- {
- return false;
- }
- return true;
- }
- public boolean blockConsideredSolid(int id, int i, int j, int k, IBlockAccess iblockaccess)
- {
- Material material = iblockaccess.getBlockMaterial(i, j, k);
- if(Block.blocksList[id].isOpaqueCube())
- {
- return true;
- }
- else if(material == Material.grass || material == Material.lava || material == Material.water)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public void setBlockBoundsForItemRender() //Controls hitbox!
- {
- setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
- }
- public int getBlockTextureFromSideAndMetadata(int i, int j)
- {
- if (i == 1)
- {
- return 0;
- }
- return i != 0 ? /*(j == 1 ? mod_EvilMinecraft_Fragment.doubleSidegrassTextureIndex : 3)*/ 3 : 2;
- }
- public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l)
- {
- if (l == 1)
- {
- return 0;
- }
- if (l == 0)
- {
- return 2;
- }
- Material material = iblockaccess.getBlockMaterial(i, j + 1, k);
- return material != Material.snow && material != Material.craftedSnow ? (isCustomRender(iblockaccess, i, j, k) ? getBlockTextureFromSideAndMetadata(l, 1) : getBlockTextureFromSideAndMetadata(l, 0)) : 68;
- }
- public int getBlockColor()
- {
- double d = 0.5D;
- double d1 = 1.0D;
- return ColorizerGrass.getGrassColor(d, d1);
- }
- public int getRenderColor(int i)
- {
- return getBlockColor();
- }
- public int colorMultiplier(IBlockAccess iblockaccess, int i, int j, int k)
- {
- int l = 0;
- int i1 = 0;
- int j1 = 0;
- for (int k1 = -1; k1 <= 1; k1++)
- {
- for (int l1 = -1; l1 <= 1; l1++)
- {
- int i2 = iblockaccess.getWorldChunkManager().getBiomeGenAt(i + l1, k + k1).getGrassColorAtCoords(iblockaccess, i + l1, j, k + k1);
- l += (i2 & 0xff0000) >> 16;
- i1 += (i2 & 0xff00) >> 8;
- j1 += i2 & 0xff;
- }
- }
- return (l / 9 & 0xff) << 16 | (i1 / 9 & 0xff) << 8 | j1 / 9 & 0xff;
- }
- public void updateTick(World world, int i, int j, int k, Random random)
- {
- if (world.multiplayerWorld)
- {
- return;
- }
- if (world.getBlockLightValue(i, j + 1, k) < 4 && Block.lightOpacity[world.getBlockId(i, j + 1, k)] > 2)
- {
- world.setBlockWithNotify(i, j, k, Block.dirt.blockID);
- }
- else if (world.getBlockLightValue(i, j + 1, k) >= 9)
- {
- for (int l = 0; l < 4; l++)
- {
- int i1 = (i + random.nextInt(3)) - 1;
- int j1 = (j + random.nextInt(5)) - 3;
- int k1 = (k + random.nextInt(3)) - 1;
- int l1 = world.getBlockId(i1, j1 + 1, k1);
- if (world.getBlockId(i1, j1, k1) == Block.dirt.blockID && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && Block.lightOpacity[l1] <= 2 && l1 != Block.grass.blockID)
- {
- world.setBlockWithNotify(i1, j1, k1, Block.grass.blockID);
- }
- }
- }
- }
- public int idDropped(int i, Random random, int j)
- {
- return Block.dirt.idDropped(0, random, j);
- }
- public int getRenderType()
- {
- return mod_EvilMinecraft_Fragment.grassModelID;
- }
- public boolean isOpaqueCube()
- {
- return false;
- }
- public boolean renderAsNormalBlock()
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement