Also prevent these two from being cast through walls

This commit is contained in:
Electroblob77
2020-04-21 22:10:55 +01:00
parent 5d8a90167c
commit 755933486c
2 changed files with 12 additions and 1 deletions
@@ -129,7 +129,8 @@ public class SpellConstructRanged<T extends EntityMagicConstruct> extends SpellC
SpellModifiers modifiers){
double range = getProperty(RANGE).doubleValue() * modifiers.get(WizardryItems.range_upgrade);
Vec3d origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ);
if(target != null && caster.getDistance(target) <= range){
if(!world.isRemote){
@@ -138,6 +139,12 @@ public class SpellConstructRanged<T extends EntityMagicConstruct> extends SpellC
double y = target.posY;
double z = target.posZ;
RayTraceResult hit = world.rayTraceBlocks(origin, new Vec3d(x, y, z), hitLiquids, ignoreUncollidables, false);
if(hit != null && hit.typeOfHit == RayTraceResult.Type.BLOCK && !hit.getBlockPos().equals(new BlockPos(x, y, z))){
return false; // Something was in the way
}
EnumFacing side = null;
// If the target is not on the ground but the construct must be placed on the floor, searches for the