use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleEffectLight method run.
@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
BlockPos targetPos = spell.getTargetPos();
Vec3d hit = spell.getTarget();
Entity targetEntity = spell.getVictim();
EnumFacing facing = spell.getData(FACE_HIT);
Entity caster = spell.getCaster();
if (targetPos == null && hit != null)
targetPos = new BlockPos(hit);
if (targetPos == null)
return false;
BlockPos finalPos = null;
if (world.isAirBlock(targetPos))
finalPos = targetPos;
else if (facing != null && world.isAirBlock(targetPos.offset(facing)))
finalPos = targetPos.offset(facing);
if (finalPos == null)
return false;
if (!spellRing.taxCaster(spell))
return false;
BlockUtils.placeBlock(world, finalPos, ModBlocks.LIGHT.getDefaultState(), caster instanceof EntityPlayerMP ? (EntityPlayerMP) caster : null);
return true;
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleEffectLight method render.
@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Vec3d position = spell.getTarget();
if (position == null)
return;
LibParticles.EXPLODE(world, position, getPrimaryColor(), getSecondaryColor(), 0.2, 0.3, 20, 40, 10, true);
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleEffectLightning method run.
@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Vec3d target = spell.getTarget();
Entity caster = spell.getCaster();
float yaw = spell.getData(YAW, 0F);
float pitch = spell.getData(PITCH, 0F);
if (target == null)
return false;
Vec3d origin = target;
if (caster != null) {
float offX = 0.5f * (float) Math.sin(Math.toRadians(-90.0f - yaw));
float offZ = 0.5f * (float) Math.cos(Math.toRadians(-90.0f - yaw));
origin = new Vec3d(offX, caster.getEyeHeight(), offZ).add(target);
}
double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell) / 2.0;
if (!spellRing.taxCaster(spell))
return false;
RayTraceResult traceResult = new RayTrace(world, PosUtils.vecFromRotations(pitch, yaw), target, range).setSkipBlocks(true).setSkipEntities(true).trace();
long seed = RandUtil.nextLong(100, 100000);
spell.addData(SEED, seed);
LightningGenerator generator = new LightningGenerator(origin, traceResult.hitVec, new RandUtilSeed(seed));
ArrayList<Vec3d> points = generator.generate();
spell.world.playSound(null, new BlockPos(traceResult.hitVec), ModSounds.LIGHTNING, SoundCategory.NEUTRAL, 0.5f, RandUtil.nextFloat(1, 1.5f));
for (Vec3d point : points) {
List<Entity> entityList = world.getEntitiesWithinAABBExcludingEntity(caster, new AxisAlignedBB(new BlockPos(point)).contract(0.2, 0.2, 0.2));
if (!entityList.isEmpty()) {
for (Entity entity : entityList) {
LightningTracker.INSTANCE.addEntity(origin, entity, caster, (int) strength);
}
}
}
return true;
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleEffectBackup method run.
@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Entity targetEntity = spell.getVictim();
Vec3d targetPos = spell.getTarget();
EnumFacing facing = spell.getData(FACE_HIT);
Entity caster = spell.getCaster();
double range = spellRing.getAttributeValue(AttributeRegistry.AREA, spell) / 2.0;
double time = spellRing.getAttributeValue(AttributeRegistry.DURATION, spell);
if (!spellRing.taxCaster(spell))
return false;
if (targetPos == null)
return true;
if (!(caster instanceof EntityLivingBase))
return true;
if (facing != null && !world.isAirBlock(new BlockPos(targetPos))) {
targetPos = new Vec3d(new BlockPos(targetPos).offset(facing)).addVector(0.5, 0.5, 0.5);
}
EntityBackupZombie zombie = new EntityBackupZombie(world, (EntityLivingBase) caster, (int) time);
zombie.setPosition(targetPos.x, targetPos.y, targetPos.z);
zombie.forceSpawn = true;
world.spawnEntity(zombie);
return true;
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleEffectBreak method render.
@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Vec3d position = spell.getTarget();
if (position == null)
return;
LibParticles.EXPLODE(world, position, getPrimaryColor(), getSecondaryColor(), 0.2, 0.3, 20, 40, 10, true);
}
Aggregations