EntityThrowable entity = (EntityThrowable) burst;
switch(stack.getItemDamage()) {
case BOUNCE : {
if(!isManaBlock && pos.entityHit == null) {
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
if(coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) {
Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize();
Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec);
burst.setMotion(movementVec.x, movementVec.y, movementVec.z);
dead = false;
}
}
break;
}
case MINE : {
World world = entity.worldObj;
int x = pos.blockX;
int y = pos.blockY;
int z = pos.blockZ;
Block block = world.getBlock(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
float hardness = block.getBlockHardness(world, x, y, z);
int mana = burst.getMana();
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
if((coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && block != null && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) {
List<ItemStack> items = new ArrayList();
items.addAll(block.getDrops(world, x, y, z, meta, 0));
if(!burst.hasAlreadyCollidedAt(x, y, z)) {
if(!burst.isFake() && !entity.worldObj.isRemote) {
world.setBlockToAir(x, y, z);
if(ConfigHandler.blockBreakParticles)
entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
for(ItemStack stack_ : items)
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack_));
burst.setMana(mana - 24);
}
}
dead = false;
}
break;
}
case PHANTOM : {
if(!isManaBlock) {
dead = false;
burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4));
}
break;
}
case EXPLOSIVE : {
if(!burst.isFake()) {
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ))
entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true);
} else dead = false;
break;
}
case WEIGHT : {
if(!burst.isFake()) {
int x = pos.blockX;
int y = pos.blockY;
int z = pos.blockZ;
Block block = entity.worldObj.getBlock(x, y, z);
Block blockBelow = entity.worldObj.getBlock(x, y - 1, z);
if(blockBelow.isAir(entity.worldObj, x, y - 1, z) && block.getBlockHardness(entity.worldObj, x, y, z) != -1 && entity.worldObj.getTileEntity(x, y, z) == null) {
EntityFallingBlock falling = new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, entity.worldObj.getBlockMetadata(x, y, z));
if(!entity.worldObj.isRemote)
entity.worldObj.spawnEntityInWorld(falling);
}
}
break;
}
case PAINT : {
int storedColor = getStoredColor(stack);
if(!burst.isFake() && storedColor > -1 && storedColor < 17) {
if(pos.entityHit != null && pos.entityHit instanceof EntitySheep) {
int r = 20;
int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor();
List<EntitySheep> sheepList = entity.worldObj.getEntitiesWithinAABB(EntitySheep.class, AxisAlignedBB.getBoundingBox(pos.entityHit.posX - r, pos.entityHit.posY - r, pos.entityHit.posZ - r, pos.entityHit.posX + r, pos.entityHit.posY + r, pos.entityHit.posZ + r));
for(EntitySheep sheep : sheepList) {
if(sheep.getFleeceColor() == sheepColor)
sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor);
}
dead = true;
} else {
Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(paintableBlocks.contains(block)) {
int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
List<ChunkCoordinates> coordsToPaint = new ArrayList();
List<ChunkCoordinates> coordsFound = new ArrayList();
ChunkCoordinates theseCoords = new ChunkCoordinates(pos.blockX, pos.blockY, pos.blockZ);
coordsFound.add(theseCoords);
do {
List<ChunkCoordinates> iterCoords = new ArrayList(coordsFound);
for(ChunkCoordinates coords : iterCoords) {
coordsFound.remove(coords);
coordsToPaint.add(coords);
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block block_ = entity.worldObj.getBlock(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
int meta_ = entity.worldObj.getBlockMetadata(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
ChunkCoordinates coords_ = new ChunkCoordinates(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
if(block_ == block && meta_ == meta && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_))
coordsFound.add(coords_);
}
}
} while(!coordsFound.isEmpty() && coordsToPaint.size() < 1000);
for(ChunkCoordinates coords : coordsToPaint) {
int placeColor = storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor;
int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ);
if(metaThere != placeColor) {
if(!entity.worldObj.isRemote)
entity.worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, placeColor, 2);
float[] color = EntitySheep.fleeceColorTable[placeColor];
float r = color[0];
float g = color[1];
float b = color[2];
for(int i = 0; i < 4; i++)
Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);
}
}
}
}
}
break;
}
case FIRE : {
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) {
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
int x = pos.blockX + dir.offsetX;
int y = pos.blockY + dir.offsetY;
int z = pos.blockZ + dir.offsetZ;
Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
Block blockAt_ = entity.worldObj.getBlock(x, y, z);
if(blockAt == Blocks.portal)
entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
else if(blockAt_.isAir(entity.worldObj, x, y, z))
entity.worldObj.setBlock(x, y, z, Blocks.fire);
}
break;
}
case PISTON : {
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock && !entity.worldObj.isRemote) {
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite();
int x = pos.blockX + dir.offsetX;
int y = pos.blockY + dir.offsetY;
int z = pos.blockZ + dir.offsetZ;