use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleShapeTouch method render.
@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Entity targetEntity = spell.getVictim();
if (targetEntity == null)
return;
ParticleBuilder glitter = new ParticleBuilder(1);
glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
ParticleSpawner.spawn(glitter, spell.world, new InterpCircle(targetEntity.getPositionVector().addVector(0, targetEntity.height / 2.0, 0), new Vec3d(0, 1, 0), 1, 10), 50, RandUtil.nextInt(10, 15), (aFloat, particleBuilder) -> {
if (RandUtil.nextBoolean()) {
glitter.setColor(getPrimaryColor());
glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
} else {
glitter.setColor(getSecondaryColor());
glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(-0.1, -0.01), 0));
}
glitter.setLifetime(RandUtil.nextInt(20, 30));
glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
glitter.setLifetime(RandUtil.nextInt(10, 20));
glitter.setScaleFunction(new InterpScale(1, 0));
});
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ItemStaff method onItemUse.
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
if (player.isSneaking()) {
for (SpellRing spellRing : SpellUtils.getSpellChains(stack)) {
if (spellRing.getModule() instanceof IBlockSelectable) {
player.getEntityData().setTag("selected", NBTUtil.writeBlockState(new NBTTagCompound(), world.getBlockState(pos)));
player.swingArm(hand);
return EnumActionResult.PASS;
}
}
}
if (isCoolingDown(stack))
return EnumActionResult.PASS;
if (BaublesSupport.getItem(player, ModItems.CREATIVE_HALO, ModItems.FAKE_HALO, ModItems.REAL_HALO).isEmpty())
return EnumActionResult.PASS;
boolean isOnTouch = false;
for (SpellRing spellRing : SpellUtils.getSpellChains(stack)) if (spellRing.getModule() instanceof ModuleShapeTouch) {
isOnTouch = true;
break;
}
if (!isOnTouch)
return EnumActionResult.PASS;
SpellData spell = new SpellData(world);
spell.processEntity(player, true);
spell.processBlock(pos, side, new Vec3d(pos).addVector(0.5, 0.5, 0.5));
SpellUtils.runSpell(stack, spell);
setCooldown(world, player, hand, stack, spell);
return EnumActionResult.PASS;
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleShapeZone method run.
@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Vec3d position = spell.getData(ORIGIN);
Entity caster = spell.getCaster();
Vec3d targetPos = spell.getTarget();
if (targetPos == null)
return false;
double aoe = spellRing.getAttributeValue(AttributeRegistry.AREA, spell);
double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell);
double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
spellRing.multiplyMultiplierForAll((float) (aoe / 7.0 * strength / 15.0 * range / 15.0));
List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(new BlockPos(targetPos)).grow(aoe, 1, aoe));
if (RandUtil.nextInt((int) ((70 - strength))) == 0) {
if (!spellRing.taxCaster(spell))
return false;
for (Entity entity : entities) {
if (entity.getDistance(targetPos.x, targetPos.y, targetPos.z) <= aoe) {
Vec3d vec = targetPos.addVector(RandUtil.nextDouble(-strength, strength), RandUtil.nextDouble(range), RandUtil.nextDouble(-strength, strength));
SpellData copy = spell.copy();
copy.processEntity(entity, false);
copy.addData(YAW, entity.rotationYaw);
copy.addData(PITCH, entity.rotationPitch);
copy.addData(ORIGIN, vec);
if (spellRing.getChildRing() != null) {
spellRing.getChildRing().runSpellRing(spell);
}
}
}
}
if (RandUtil.nextInt((int) ((40 - strength))) != 0)
return false;
ArrayList<Vec3d> blocks = new ArrayList<>();
for (double i = -aoe; i < aoe; i++) for (double j = 0; j < range; j++) for (double k = -aoe; k < aoe; k++) {
Vec3d pos = targetPos.addVector(i, j, k);
if (pos.distanceTo(targetPos) <= aoe) {
// BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(new BlockPos(pos));
blocks.add(pos);
}
}
if (blocks.isEmpty())
return false;
if (!spellRing.taxCaster(spell))
return false;
Vec3d pos = blocks.get(RandUtil.nextInt(blocks.size() - 1));
SpellData copy = spell.copy();
copy.addData(ORIGIN, pos);
copy.processBlock(new BlockPos(pos), EnumFacing.UP, pos);
copy.addData(YAW, RandUtil.nextFloat(-180, 180));
copy.addData(PITCH, RandUtil.nextFloat(-50, 50));
if (spellRing.getChildRing() != null) {
spellRing.getChildRing().runSpellRing(copy);
}
return true;
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleEffectDisarm 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.EFFECT_REGENERATE(world, position, getPrimaryColor());
}
use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.
the class ModuleEffectLeech method run.
@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Entity targetEntity = spell.getVictim();
BlockPos targetPos = spell.getTargetPos();
Entity caster = spell.getCaster();
EnumFacing facing = spell.getData(FACE_HIT);
double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell) / 2;
if (!spellRing.taxCaster(spell))
return false;
if (targetEntity instanceof EntityLivingBase) {
if (targetEntity instanceof EntityPlayer) {
double targetMana = new CapManager(targetEntity).getMana();
targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
if (targetEntity.isDead) {
targetMana /= 2;
targetMana = MathHelper.clamp(targetMana, targetMana, spellRing.getManaDrain() * 2);
new CapManager(caster).addMana(targetMana);
}
} else if (targetEntity instanceof EntityWitch) {
double targetMana = spellRing.getManaDrain() * 2;
targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
if (targetEntity.isDead) {
new CapManager(caster).addMana(targetMana);
}
} else {
if (caster instanceof EntityLivingBase)
((EntityLivingBase) caster).setLastAttackedEntity(targetEntity);
if (caster != null)
targetEntity.attackEntityFrom(new EntityDamageSource("magic", caster).setDamageBypassesArmor().setMagicDamage(), (float) strength);
else
targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
}
}
Vec3d target = spell.getTargetWithFallback();
if (target != null)
world.playSound(null, new BlockPos(target), ModSounds.CHAINY_ZAP, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.35f, 0.75f), RandUtil.nextFloat(0.35f, 1.5f));
return true;
}
Aggregations