package net.silentchaos512.gems.entity;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.silentchaos512.gems.SilentGems;

public class EntityChaosProjectileSweep extends EntityChaosProjectile {

  public EntityChaosProjectileSweep(World world) {

    super(world);
  }

  public EntityChaosProjectileSweep(EntityLivingBase shooter, ItemStack castingStack,
      float damage, float yaw) {

    super(shooter, castingStack, damage);

    Vec3d vec = shooter.getLookVec();
    vec = vec.rotateYaw(yaw);
    motionX = vec.xCoord;
    motionY = vec.yCoord;
    motionZ = vec.zCoord;
//    SilentGems.instance.logHelper.debug(motionX, motionY, motionZ);

    float speedMulti = 0.7f;
    motionX += shooter.motionX;
    motionY += shooter.motionY;
    motionZ += shooter.motionZ;
    motionX *= speedMulti;
    motionY *= speedMulti;
    motionZ *= speedMulti;
  }

  @Override
  public int getMaxLife() {

    return 80;
  }

  @Override
  protected void onImpact(RayTraceResult mop) {

    if (mop.typeOfHit == Type.ENTITY && mop.entityHit != shooter) {
      mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, shooter), damage);
    } else if (mop.typeOfHit == Type.BLOCK) {
      switch (mop.sideHit) {
        case UP:
          motionY = 0.0;
          break;
        case DOWN:
          motionY = -motionY;
          break;
        case EAST:
        case NORTH:
        case SOUTH:
        case WEST:
          posY += 1.1;
          break;
      }
    }
  }

  @Override
  public float getGravityVelocity() {

    return 0.06f;
  }
}

@@ -34,16 +34,108 @@
 ntity;%0A%0A
+import net.minecraft.block.material.Material;%0Aimport net.minecraft.block.state.IBlockState;%0A
 import n
@@ -249,16 +249,103 @@
 Source;%0A
+import net.minecraft.util.math.AxisAlignedBB;%0Aimport net.minecraft.util.math.BlockPos;%0A
 import n
@@ -510,51 +510,8 @@
 rld;
-%0Aimport net.silentchaos512.gems.SilentGems;
 %0A%0Apu
@@ -741,22 +741,16 @@
 ngStack,
-%0A     
  float d
@@ -755,16 +755,22 @@
  damage,
+%0A     
  float y
@@ -969,13 +969,14 @@
 rd;%0A
-//
    
+ //
  Sil
@@ -1366,24 +1366,65 @@
 ult mop) %7B%0A%0A
+    BlockPos posHit = mop.getBlockPos();%0A
     if (mop.
@@ -1614,16 +1614,76 @@
 pe.BLOCK
+ && canCollideWithBlock(world.getBlockState(posHit), posHit)
 ) %7B%0A    
@@ -1924,31 +1924,224 @@
     
-posY += 1
+BlockPos posUp = mop.getBlockPos().up();%0A          if (canCollideWithBlock(world.getBlockState(posUp), posUp)) %7B%0A            setDead();%0A          %7D else %7B%0A            posY = posUp.getY() + 0
 .1;%0A   
+  
+     %7D%0A
        
+   
 brea
@@ -2158,24 +2158,303 @@
 %0A    %7D%0A  %7D%0A%0A
+  private boolean canCollideWithBlock(IBlockState state, BlockPos pos) %7B%0A%0A    Material mat = state.getMaterial();%0A    if (mat == Material.AIR %7C%7C mat == Material.PLANTS %7C%7C mat == Material.VINE) %7B%0A      return false;%0A    %7D%0A    return state.getBoundingBox(world, pos) != null;%0A  %7D%0A%0A
   @Override%0A

Fix katana shots being too good at climbing.