Cleaning up hitbox code

This commit is contained in:
Adubbz 2013-05-24 20:01:13 +10:00
parent 458c3507b1
commit bcdb783c0a
2 changed files with 55 additions and 19 deletions

View file

@ -11,6 +11,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -77,6 +78,7 @@ public class BlockBOPFlower extends BlockFlower
return 0; return 0;
} }
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4) public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4)
{ {
int meta = world.getBlockMetadata(par2, par3, par4); int meta = world.getBlockMetadata(par2, par3, par4);
@ -93,11 +95,15 @@ public class BlockBOPFlower extends BlockFlower
case 6: case 6:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F); this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.6F, 0.7F);
break;
case 9:
this.setBlockBounds(0.3F, 0.0F, 0.3F, 0.7F, 0.5F, 0.7F);
break; break;
case 10: case 10:
//this.setBlockBounds(0.3F, -1.0F, 0.3F, 0.7F, -0.4F, 0.7F); this.setBlockBounds(0.3F, -0.97F, 0.3F, 0.7F, -0.7F, 0.7F);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F); //this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
break; break;
case 11: case 11:

View file

@ -17,6 +17,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.ColorizerGrass; import net.minecraft.world.ColorizerGrass;
@ -219,22 +220,51 @@ public class BlockBOPFoliage extends BlockFlower implements IShearable
return -1; return -1;
} }
public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4) @Override
{ public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
int meta = world.getBlockMetadata(par2, par3, par4); {
int meta = world.getBlockMetadata(x, y, z);
switch (meta) switch (meta)
{ {
case ALGAE:
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.015625D, (double) z + 1.0D);
case ALGAE: default:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.015625F, 1.0F); return AxisAlignedBB.getBoundingBox(x + 0.1D, y, z + 0.1D, (double) x + 0.9D, (double) y + 0.8D, (double) z + 0.9D);
break; }
}
default: @Override
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F); public void setBlockBoundsBasedOnState(IBlockAccess iblockaccess, int x, int y, int z)
break; {
} int meta = iblockaccess.getBlockMetadata(x, y, z);
}
float minX;
float minY;
float minZ;
float maxX;
float maxY;
float maxZ;
switch (meta)
{
case ALGAE:
minX = minY = minZ = 0F;
maxX = maxZ = 1.0F;
maxY = 0.015625F;
break;
default:
minX = minZ = 0.1F;
minY = 0.0F;
maxX = maxZ = 0.9F;
maxY = 0.8F;
break;
}
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
@Override @Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta)