Initial 1.11.2 update

This commit is contained in:
Electroblob
2018-02-07 21:15:50 +00:00
parent 67f6be0671
commit 3df5597dcc
368 changed files with 17234 additions and 15082 deletions
@@ -18,29 +18,32 @@ import net.minecraft.world.World;
public class Agility extends Spell {
public Agility() {
public Agility(){
super(Tier.APPRENTICE, 20, Element.SORCERY, "agility", SpellType.UTILITY, 40, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// 1.10 allows the particles to be completely hidden.
caster.addPotionEffect(new PotionEffect(MobEffects.SPEED, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
caster.addPotionEffect(new PotionEffect(MobEffects.SPEED,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
if(world.isRemote){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
}
@@ -27,38 +27,46 @@ import net.minecraft.world.World;
// be useful for future reference.
public class Arc extends Spell {
public Arc() {
public Arc(){
super(Tier.BASIC, 5, Element.LIGHTNING, "arc", SpellType.ATTACK, 15, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade), 4.0f);
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
8 * modifiers.get(WizardryItems.range_upgrade), 4.0f);
if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){
Entity target = rayTrace.entityHit;
if(!world.isRemote){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ,
target.posX, target.posY + target.height/2, target.posZ);
world.spawnEntityInWorld(arc);
arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ, target.posX,
target.posY + target.height / 2, target.posZ);
world.spawnEntity(arc);
}else{
for(int i=0;i<8;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
for(int i = 0; i < 8; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
}
}
// This is a lot neater than it was, thanks to the damage type system.
if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()));
}else{
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
}
caster.swingArm(hand);
target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F);
return true;
@@ -66,40 +74,46 @@ public class Arc extends Spell {
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ,
target.posX, target.posY + target.height/2, target.posZ);
world.spawnEntityInWorld(arc);
arc.setEndpointCoords(caster.posX, caster.posY + 1, caster.posZ, target.posX,
target.posY + target.height / 2, target.posZ);
world.spawnEntity(arc);
}else{
for(int i=0;i<8;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
for(int i = 0; i < 8; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
}
}
// What's great about the damage type system is that, because I don't need to know if the creature resisted
// the damage here, I can simply call this without having to check for immunities at all.
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
caster.swingArm(hand);
target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -28,60 +28,70 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class ArcaneJammer extends Spell {
public ArcaneJammer() {
public ArcaneJammer(){
super(Tier.ADVANCED, 30, Element.HEALING, "arcane_jammer", SpellType.ATTACK, 50, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase entity = (EntityLivingBase) rayTrace.entityHit;
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase entity = (EntityLivingBase)rayTrace.entityHit;
if(entity instanceof EntityWizard) caster.addStat(WizardryAchievements.jam_wizard);
if(!world.isRemote){
entity.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
entity.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer,
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f);
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_DEFLECTION, 0.7F, world.rand.nextFloat() * 0.4F + 0.8F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_DEFLECTION, 0.7F,
world.rand.nextFloat() * 0.4F + 0.8F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
target.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
target.addPotionEffect(new PotionEffect(WizardryPotions.arcane_jammer,
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
if(world.isRemote){
double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target);
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target);
double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f;
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f);
double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), 0.9f, 0.3f, 0.7f);
}
}
caster.swingArm(hand);
@@ -95,7 +105,7 @@ public class ArcaneJammer extends Spell {
public boolean canBeCastByNPCs(){
return true;
}
@SubscribeEvent
public static void onSpellCastPreEvent(SpellCastEvent.Pre event){
// Arcane jammer prevents spell casting.
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
public class ArrowRain extends Spell {
public ArrowRain() {
public ArrowRain(){
super(Tier.MASTER, 75, Element.SORCERY, "arrow_rain", SpellType.ATTACK, 300, EnumAction.NONE, false);
}
@@ -26,26 +26,30 @@ public class ArrowRain extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
if(!world.isRemote){
double x = rayTrace.hitVec.xCoord;
double y = rayTrace.hitVec.yCoord;
double z = rayTrace.hitVec.zCoord;
// Moves the entity back towards the caster a bit, so the area of effect is better centred on the position.
// Moves the entity back towards the caster a bit, so the area of effect is better centred on the
// position.
// 3.0d is the distance to move the entity back towards the caster.
double dx = caster.posX - x;
double dz = caster.posZ - z;
double distRatio = 3.0d/Math.sqrt(dx*dx + dz*dz);
x += dx*distRatio;
z += dz*distRatio;
EntityArrowRain arrowrain = new EntityArrowRain(world, x, y + 5, z, caster, (int)(120*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE));
double distRatio = 3.0d / Math.sqrt(dx * dx + dz * dz);
x += dx * distRatio;
z += dz * distRatio;
EntityArrowRain arrowrain = new EntityArrowRain(world, x, y + 5, z, caster,
(int)(120 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
arrowrain.rotationYaw = caster.rotationYawHead;
world.spawnEntityInWorld(arrowrain);
world.spawnEntity(arrowrain);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 1.0F, 1.0F);
@@ -23,137 +23,150 @@ import net.minecraft.world.World;
public class Banish extends Spell {
public Banish() {
public Banish(){
super(Tier.APPRENTICE, 15, Element.NECROMANCY, "banish", SpellType.ATTACK, 40, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
double radius = (8 + world.rand.nextDouble()*8) * modifiers.get(WizardryItems.range_upgrade);
double angle = world.rand.nextDouble()*Math.PI*2;
int x = MathHelper.floor_double(target.posX + Math.sin(angle)*radius);
int z = MathHelper.floor_double(target.posZ - Math.cos(angle)*radius);
int y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius);
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
double radius = (8 + world.rand.nextDouble() * 8) * modifiers.get(WizardryItems.range_upgrade);
double angle = world.rand.nextDouble() * Math.PI * 2;
int x = MathHelper.floor(target.posX + Math.sin(angle) * radius);
int z = MathHelper.floor(target.posZ - Math.cos(angle) * radius);
int y = WizardryUtilities.getNearestFloorLevel(world,
new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius);
if(world.isRemote){
for(int i=0;i<10;i++){
for(int i = 0; i < 10; i++){
double dx1 = target.posX;
double dy1 = target.getEntityBoundingBox().minY + target.height*world.rand.nextFloat();
double dy1 = target.getEntityBoundingBox().minY + target.height * world.rand.nextFloat();
double dz1 = target.posZ;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
}
}
if(y > -1){
// This means stuff like snow layers is ignored, meaning when on snow-covered ground the caster does
// not teleport 1 block above the ground.
if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().blocksMovement()){
y--;
}
if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){
if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement()
|| world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){
return false;
}
if(!world.isRemote){
target.setPositionAndUpdate(x + 0.5, y + 1, z + 0.5);
}
target.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
}
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.2f, 0.0f, 0.2f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0,
0.2f, 0.0f, 0.2f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
caster.swingArm(hand);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
if(target != null){
double radius = (8 + world.rand.nextDouble()*8) * modifiers.get(WizardryItems.range_upgrade);
double angle = world.rand.nextDouble()*Math.PI*2;
int x = MathHelper.floor_double(target.posX + Math.sin(angle)*radius);
int z = MathHelper.floor_double(target.posZ - Math.cos(angle)*radius);
int y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius);
if(world.isRemote){
double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target);
for(int i=1; i<25; i+=2){
double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f;
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
double radius = (8 + world.rand.nextDouble() * 8) * modifiers.get(WizardryItems.range_upgrade);
double angle = world.rand.nextDouble() * Math.PI * 2;
int x = MathHelper.floor(target.posX + Math.sin(angle) * radius);
int z = MathHelper.floor(target.posZ - Math.cos(angle) * radius);
int y = WizardryUtilities.getNearestFloorLevel(world,
new BlockPos(x, (int)caster.getEntityBoundingBox().minY, z), (int)radius);
if(world.isRemote){
double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target);
for(int i = 1; i < 25; i += 2){
double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.2f, 0.0f, 0.2f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
0, 0.2f, 0.0f, 0.2f);
}
for(int i=0;i<10;i++){
for(int i = 0; i < 10; i++){
double dx1 = target.posX;
double dy1 = target.getEntityBoundingBox().minY + target.height*world.rand.nextFloat();
double dy1 = target.getEntityBoundingBox().minY + target.height * world.rand.nextFloat();
double dz1 = target.posZ;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
}
}
if(y > -1){
// This means stuff like snow layers is ignored, meaning when on snow-covered ground the caster does
// not teleport 1 block above the ground.
if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().blocksMovement()){
y--;
}
if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){
if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement()
|| world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){
return false;
}
if(!world.isRemote){
target.setPositionAndUpdate(x + 0.5, y + 1, z + 0.5);
}
target.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
}
}
caster.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
caster.swingArm(hand);
return true;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class BlackHole extends Spell {
public BlackHole() {
public BlackHole(){
super(Tier.MASTER, 150, Element.SORCERY, "black_hole", SpellType.ATTACK, 400, EnumAction.NONE, false);
}
@@ -27,33 +27,38 @@ public class BlackHole extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
// This demonstrates beautifully the elegance of BlockPos. In 1.7.10 this required a 50-line long switch
// statement and a flag variable; now it only needs a few lines.
BlockPos pos = new BlockPos(rayTrace.hitVec).offset(rayTrace.sideHit);
if(world.isAirBlock(pos)){
if(!world.isRemote){
world.spawnEntityInWorld(new EntityBlackHole(world, pos.getX()+0.5, pos.getY()-1+0.5, pos.getZ()+0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)));
world.spawnEntity(new EntityBlackHole(world, pos.getX() + 0.5, pos.getY() - 1 + 0.5,
pos.getZ() + 0.5, caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE)));
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 2.0f, 0.7f);
return true;
}
}else{
int x = (int) (Math.floor(caster.posX) + caster.getLookVec().xCoord*8);
int y = (int) (Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord*8);
int z = (int) (Math.floor(caster.posZ) + caster.getLookVec().zCoord*8);
int x = (int)(Math.floor(caster.posX) + caster.getLookVec().xCoord * 8);
int y = (int)(Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord * 8);
int z = (int)(Math.floor(caster.posZ) + caster.getLookVec().zCoord * 8);
if(!world.isRemote){
world.spawnEntityInWorld(new EntityBlackHole(world, x, y, z, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE)));
world.spawnEntity(new EntityBlackHole(world, x, y, z, caster,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE)));
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 2.0f, 0.7f);
@@ -62,5 +67,4 @@ public class BlackHole extends Spell {
return false;
}
}
@@ -21,114 +21,122 @@ import net.minecraft.world.World;
public class Blink extends Spell {
public Blink() {
public Blink(){
super(Tier.APPRENTICE, 15, Element.SORCERY, "blink", SpellType.UTILITY, 25, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(25*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(25 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
// It's worth noting that on the client side, the cast() method only gets called if the server side
// cast method succeeded, so you need not check any conditions for spawning particles.
if(world.isRemote){
for(int i=0;i<10;i++){
for(int i = 0; i < 10; i++){
double dx = caster.posX;
double dy = caster.getEntityBoundingBox().minY + 2*world.rand.nextFloat();
double dy = caster.getEntityBoundingBox().minY + 2 * world.rand.nextFloat();
double dz = caster.posZ;
// For portal particles, velocity is not velocity but the offset where they start, then drift to
// the actual position given.
world.spawnParticle(EnumParticleTypes.PORTAL, dx, dy, dz, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
world.spawnParticle(EnumParticleTypes.PORTAL, dx, dy, dz, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
}
}
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
// Can't teleport onto the ceiling.
if(rayTrace.sideHit == EnumFacing.DOWN) return false;
// This means stuff like snow layers is ignored, meaning when on snow-covered ground the player does
// not teleport 1 block above the ground.
if(rayTrace.sideHit == EnumFacing.UP && !world.getBlockState(pos).getMaterial().blocksMovement()){
pos = pos.down();
}
pos = rayTrace.getBlockPos().offset(rayTrace.sideHit);
// Prevents the player from teleporting into blocks and suffocating.
if(world.getBlockState(pos).getMaterial().blocksMovement() || world.getBlockState(pos.up()).getMaterial().blocksMovement()){
if(world.getBlockState(pos).getMaterial().blocksMovement()
|| world.getBlockState(pos.up()).getMaterial().blocksMovement()){
return false;
}
// Plays before and after so it is heard from both positions
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
if(!world.isRemote) caster.setPositionAndUpdate(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
double angle = Math.atan2(target.posZ - caster.posZ, target.posX - caster.posX) + world.rand.nextDouble()*Math.PI;
double radius = caster.getDistance(target.posX, target.getEntityBoundingBox().minY, target.posZ) + world.rand.nextDouble()*3.0d;
int x = MathHelper.floor_double(target.posX + Math.sin(angle)*radius);
int z = MathHelper.floor_double(target.posZ - Math.cos(angle)*radius);
double angle = Math.atan2(target.posZ - caster.posZ, target.posX - caster.posX)
+ world.rand.nextDouble() * Math.PI;
double radius = caster.getDistance(target.posX, target.getEntityBoundingBox().minY, target.posZ)
+ world.rand.nextDouble() * 3.0d;
int x = MathHelper.floor(target.posX + Math.sin(angle) * radius);
int z = MathHelper.floor(target.posZ - Math.cos(angle) * radius);
int y = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(caster), (int)radius);
// It's worth noting that on the client side, the cast() method only gets called if the server side
// cast method succeeded, so you need not check any conditions for spawning particles.
// For some reason, the wizard version spwans the particles where the wizard started
if(world.isRemote){
for(int i=0;i<10;i++){
for(int i = 0; i < 10; i++){
double dx1 = caster.posX;
double dy1 = caster.getEntityBoundingBox().minY + caster.height*world.rand.nextFloat();
double dy1 = caster.getEntityBoundingBox().minY + caster.height * world.rand.nextFloat();
double dz1 = caster.posZ;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
}
}
if(y > -1){
// This means stuff like snow layers is ignored, meaning when on snow-covered ground the caster does
// not teleport 1 block above the ground.
if(!world.getBlockState(new BlockPos(x, y, z)).getMaterial().blocksMovement()){
y--;
}
if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement() || world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){
if(world.getBlockState(new BlockPos(x, y + 1, z)).getMaterial().blocksMovement()
|| world.getBlockState(new BlockPos(x, y + 2, z)).getMaterial().blocksMovement()){
return false;
}
// Plays before and after so it is heard from both positions
caster.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
if(!world.isRemote){
caster.setPositionAndUpdate(x + 0.5, y + 1, z + 0.5);
}
caster.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs() {
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -18,7 +18,7 @@ import net.minecraft.world.World;
public class Blizzard extends Spell {
public Blizzard() {
public Blizzard(){
super(Tier.ADVANCED, 40, Element.ICE, "blizzard", SpellType.ATTACK, 100, EnumAction.NONE, false);
}
@@ -28,17 +28,20 @@ public class Blizzard extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
if(!world.isRemote){
double x = rayTrace.hitVec.xCoord;
double y = rayTrace.hitVec.yCoord;
double z = rayTrace.hitVec.zCoord;
EntityBlizzard blizzard = new EntityBlizzard(world, x, y+0.5, z, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(blizzard);
EntityBlizzard blizzard = new EntityBlizzard(world, x, y + 0.5, z, caster,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(blizzard);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F);
@@ -46,30 +49,33 @@ public class Blizzard extends Spell {
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
double x = target.posX;
double y = target.posY;
double z = target.posZ;
EntityBlizzard blizzard = new EntityBlizzard(world, x, y+0.5, z, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(blizzard);
EntityBlizzard blizzard = new EntityBlizzard(world, x, y + 0.5, z, caster,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(blizzard);
}
caster.swingArm(hand);
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, 1.0F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -25,72 +25,86 @@ import net.minecraft.world.World;
public class Bubble extends Spell {
public Bubble() {
public Bubble(){
super(Tier.APPRENTICE, 15, Element.EARTH, "bubble", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase entity = (EntityLivingBase) rayTrace.entityHit;
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase entity = (EntityLivingBase)rayTrace.entityHit;
if(!world.isRemote){
entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE));
entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
1.0f * modifiers.get(SpellModifiers.DAMAGE));
// Deprecated in favour of entity riding method
//entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0));
EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), false, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(entitybubble);
// entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0));
EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), false,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(entitybubble);
entity.startRiding(entitybubble);
}
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
world.spawnParticle(EnumParticleTypes.WATER_SPLASH, x1, y1, z1, 0.0d, 0.0d, 0.0d);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_BUBBLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_GENERIC_SWIM, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.5F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_GENERIC_SWIM, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.5F,
world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
1.0f * modifiers.get(SpellModifiers.DAMAGE));
// Deprecated in favour of entity riding method
//entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0));
EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), false, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(entitybubble);
// entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0));
EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), false,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(entitybubble);
target.startRiding(entitybubble);
}
if(world.isRemote){
double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target);
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target);
double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f;
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
world.spawnParticle(EnumParticleTypes.WATER_SPLASH, x1, y1, z1, 0.0d, 0.0d, 0.0d);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_BUBBLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_BUBBLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
0);
}
}
caster.swingArm(hand);
@@ -26,105 +26,142 @@ import net.minecraft.world.World;
public class ChainLightning extends Spell {
public ChainLightning() {
public ChainLightning(){
super(Tier.ADVANCED, 25, Element.LIGHTNING, "chain_lightning", SpellType.ATTACK, 50, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// First shot has range 10 (this is the only range affected by upgrades) and does 5 hearts of damage.
// Chains to up to 5 secondary targets within a range of 5 of the primary target, and then to up to 2
// tertiary targets per secondary target within a range of 5 of that. Secondary targets are dealt 4 hearts
// of damage; tertiary targets are dealt 3 hearts of damage.
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 8.0f);
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade), 8.0f);
// Anything can be attacked with the initial arc, because the player has control over where it goes. If they
// hit a minion or an ally, it's their problem!
if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){
Entity target = rayTrace.entityHit;
if(!world.isRemote){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(caster.posX, caster.posY + caster.height/2, caster.posZ,
target.posX, target.posY + target.height/2, target.posZ);
world.spawnEntityInWorld(arc);
arc.setEndpointCoords(caster.posX, caster.posY + caster.height / 2, caster.posZ, target.posX,
target.posY + target.height / 2, target.posZ);
world.spawnEntity(arc);
}else{
for(int i=0;i<8;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
for(int i = 0; i < 8; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
}
}
target.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F);
if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()));
}else{
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 10.0f * modifiers.get(SpellModifiers.DAMAGE));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
10.0f * modifiers.get(SpellModifiers.DAMAGE));
}
// Secondary chaining effect
double seekerRange = 5.0d;
List<EntityLivingBase> secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, target.posX, target.posY + target.height/2, target.posZ, world);
List<EntityLivingBase> secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange,
target.posX, target.posY + target.height / 2, target.posZ, world);
for(int i = 0; i < Math.min(secondaryTargets.size(), 5); i++){
for(int i=0; i<Math.min(secondaryTargets.size(), 5); i++){
EntityLivingBase secondaryTarget = secondaryTargets.get(i);
if(secondaryTarget != target && WizardryUtilities.isValidTarget(caster, secondaryTarget)){
if(!world.isRemote){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(target.posX, target.posY + target.height/2, target.posZ,
secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ);
world.spawnEntityInWorld(arc);
arc.setEndpointCoords(target.posX, target.posY + target.height / 2, target.posZ,
secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2,
secondaryTarget.posZ);
world.spawnEntity(arc);
}else{
for(int j=0;j<8;j++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, secondaryTarget.posX + world.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + world.rand.nextFloat()*2 - 1, secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, secondaryTarget.posX + world.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + world.rand.nextFloat()*2 - 1, secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
for(int j = 0; j < 8; j++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
secondaryTarget.posX + world.rand.nextFloat() - 0.5,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2
+ world.rand.nextFloat() * 2 - 1,
secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE,
secondaryTarget.posX + world.rand.nextFloat() - 0.5,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2
+ world.rand.nextFloat() * 2 - 1,
secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
}
}
secondaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F);
if(MagicDamage.isEntityImmune(DamageType.SHOCK, secondaryTarget)){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", secondaryTarget.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist",
secondaryTarget.getName(), this.getNameForTranslationFormatted()));
}else{
secondaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 8.0f * modifiers.get(SpellModifiers.DAMAGE));
secondaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
8.0f * modifiers.get(SpellModifiers.DAMAGE));
}
// Tertiary chaining effect
List<EntityLivingBase> tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ, world);
List<EntityLivingBase> tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange,
secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2,
secondaryTarget.posZ, world);
for(int j = 0; j < Math.min(tertiaryTargets.size(), 2); j++){
for(int j=0;j<Math.min(tertiaryTargets.size(), 2);j++){
EntityLivingBase tertiaryTarget = (EntityLivingBase)tertiaryTargets.get(j);
if(tertiaryTarget != target && !secondaryTargets.contains(tertiaryTarget) && WizardryUtilities.isValidTarget(caster, tertiaryTarget)){
if(tertiaryTarget != target && !secondaryTargets.contains(tertiaryTarget)
&& WizardryUtilities.isValidTarget(caster, tertiaryTarget)){
if(!world.isRemote){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ,
tertiaryTarget.posX, tertiaryTarget.posY + tertiaryTarget.height/2, tertiaryTarget.posZ);
world.spawnEntityInWorld(arc);
arc.setEndpointCoords(secondaryTarget.posX,
secondaryTarget.posY + secondaryTarget.height / 2, secondaryTarget.posZ,
tertiaryTarget.posX, tertiaryTarget.posY + tertiaryTarget.height / 2,
tertiaryTarget.posZ);
world.spawnEntity(arc);
}else{
for(int k=0;k<8;k++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, tertiaryTarget.posX + world.rand.nextFloat() - 0.5, tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height/2 + world.rand.nextFloat()*2 - 1, tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, tertiaryTarget.posX + world.rand.nextFloat() - 0.5, tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height/2 + world.rand.nextFloat()*2 - 1, tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
for(int k = 0; k < 8; k++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
tertiaryTarget.posX + world.rand.nextFloat() - 0.5,
tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2
+ world.rand.nextFloat() * 2 - 1,
tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE,
tertiaryTarget.posX + world.rand.nextFloat() - 0.5,
tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2
+ world.rand.nextFloat() * 2 - 1,
tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0);
}
}
tertiaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F, world.rand.nextFloat() * 0.4F + 1.5F);
tertiaryTarget.playSound(WizardrySounds.SPELL_SPARK, 1.0F,
world.rand.nextFloat() * 0.4F + 1.5F);
if(MagicDamage.isEntityImmune(DamageType.SHOCK, tertiaryTarget)){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", tertiaryTarget.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist",
tertiaryTarget.getName(), this.getNameForTranslationFormatted()));
}else{
tertiaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 6.0f * modifiers.get(SpellModifiers.DAMAGE));
tertiaryTarget.attackEntityFrom(
MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
6.0f * modifiers.get(SpellModifiers.DAMAGE));
}
}
}
@@ -137,5 +174,4 @@ public class ChainLightning extends Spell {
return false;
}
}
@@ -49,7 +49,7 @@ public class Clairvoyance extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
WizardData properties = WizardData.get(caster);
@@ -57,47 +57,58 @@ public class Clairvoyance extends Spell {
if(caster.dimension == properties.getClairvoyanceDimension()){
if(properties.getClairvoyanceLocation() != null){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.clairvoyance.searching"));
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.searching"));
EntityZombie arbitraryZombie = new EntityZombie(world){
@Override public float getBlockPathWeight(BlockPos pos){ return 0; }
@Override
public float getBlockPathWeight(BlockPos pos){
return 0;
}
};
arbitraryZombie.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(256*modifiers.get(WizardryItems.range_upgrade));
arbitraryZombie.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
.setBaseValue(256 * modifiers.get(WizardryItems.range_upgrade));
arbitraryZombie.setPosition(caster.posX, caster.posY, caster.posZ);
arbitraryZombie.setPathPriority(PathNodeType.WATER, 0.0F);
arbitraryZombie.onGround = true;
BlockPos destination = properties.getClairvoyanceLocation();
WizardryPathFinder pathfinder = new WizardryPathFinder(arbitraryZombie.getNavigator().getNodeProcessor());
Path path = pathfinder.findPath(world, arbitraryZombie, destination, 256*modifiers.get(WizardryItems.range_upgrade));
WizardryPathFinder pathfinder = new WizardryPathFinder(
arbitraryZombie.getNavigator().getNodeProcessor());
Path path = pathfinder.findPath(world, arbitraryZombie, destination,
256 * modifiers.get(WizardryItems.range_upgrade));
if(path != null && path.getFinalPathPoint() != null){
int x = path.getFinalPathPoint().xCoord;
int y = path.getFinalPathPoint().xCoord;
int z = path.getFinalPathPoint().xCoord;
if(x == destination.getX() && y == destination.getY() && z == destination.getZ()){
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
if(!world.isRemote && caster instanceof EntityPlayerMP){
WizardryPacketHandler.net.sendTo(new PacketClairvoyance.Message(path, modifiers.get(WizardryItems.duration_upgrade)), (EntityPlayerMP)caster);
WizardryPacketHandler.net.sendTo(new PacketClairvoyance.Message(path,
modifiers.get(WizardryItems.duration_upgrade)), (EntityPlayerMP)caster);
}
return true;
}
}
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.clairvoyance.outofrange"));
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.outofrange"));
}else{
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.clairvoyance.undefined"));
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.undefined"));
}
}else{
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.clairvoyance.wrongdimension"));
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.wrongdimension"));
}
}
@@ -108,20 +119,21 @@ public class Clairvoyance extends Spell {
}
public static void spawnPathPaticles(World world, Path path, float durationMultiplier){
PathPoint point, nextPoint;
while(!path.isFinished()){
point = path.getPathPointFromIndex(path.getCurrentPathIndex());
if(point == path.getFinalPathPoint()) break;
nextPoint = path.getCurrentPathLength() - path.getCurrentPathIndex() <= 2 ? path.getFinalPathPoint() : path.getPathPointFromIndex(path.getCurrentPathIndex() + 2);
nextPoint = path.getCurrentPathLength() - path.getCurrentPathIndex() <= 2 ? path.getFinalPathPoint()
: path.getPathPointFromIndex(path.getCurrentPathIndex() + 2);
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.xCoord + 0.5, point.yCoord + 0.5, point.zCoord + 0.5,
(nextPoint.xCoord - point.xCoord)/(float)PARTICLE_MOVEMENT_INTERVAL,
(nextPoint.yCoord - point.yCoord)/(float)PARTICLE_MOVEMENT_INTERVAL,
(nextPoint.zCoord - point.zCoord)/(float)PARTICLE_MOVEMENT_INTERVAL,
(int)(1800*durationMultiplier), 0, 1, 0.3f);
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.xCoord + 0.5, point.yCoord + 0.5,
point.zCoord + 0.5, (nextPoint.xCoord - point.xCoord) / (float)PARTICLE_MOVEMENT_INTERVAL,
(nextPoint.yCoord - point.yCoord) / (float)PARTICLE_MOVEMENT_INTERVAL,
(nextPoint.zCoord - point.zCoord) / (float)PARTICLE_MOVEMENT_INTERVAL,
(int)(1800 * durationMultiplier), 0, 1, 0.3f);
path.incrementPathIndex();
path.incrementPathIndex();
@@ -129,9 +141,10 @@ public class Clairvoyance extends Spell {
point = path.getFinalPathPoint();
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.xCoord + 0.5, point.yCoord + 0.5, point.zCoord + 0.5, 0, 0, 0, (int)(1800*durationMultiplier), 1, 1, 1);
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.xCoord + 0.5, point.yCoord + 0.5,
point.zCoord + 0.5, 0, 0, 0, (int)(1800 * durationMultiplier), 1, 1, 1);
}
@SubscribeEvent
public static void onRightClickBlockEvent(PlayerInteractEvent.RightClickBlock event){
@@ -140,7 +153,8 @@ public class Clairvoyance extends Spell {
// The event now has an ItemStack, which greatly simplifies hand-related stuff.
ItemStack wand = event.getItemStack();
if(wand != null && wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Clairvoyance){
if(wand != null && wand.getItem() instanceof ItemWand
&& WandHelper.getCurrentSpell(wand) instanceof Clairvoyance){
WizardData properties = WizardData.get(event.getEntityPlayer());
@@ -151,7 +165,8 @@ public class Clairvoyance extends Spell {
properties.setClairvoyancePoint(pos, event.getWorld().provider.getDimension());
if(!event.getWorld().isRemote){
event.getEntityPlayer().addChatMessage(new TextComponentTranslation("spell.clairvoyance.confirm", Spells.clairvoyance.getNameForTranslationFormatted()));
event.getEntityPlayer().sendMessage(new TextComponentTranslation("spell.clairvoyance.confirm",
Spells.clairvoyance.getNameForTranslationFormatted()));
}
event.setCanceled(true);
@@ -21,10 +21,10 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class Cobwebs extends Spell {
private static final int baseDuration = 400;
public Cobwebs() {
public Cobwebs(){
super(Tier.ADVANCED, 30, Element.EARTH, "cobwebs", SpellType.ATTACK, 70, EnumAction.NONE, false);
}
@@ -34,41 +34,44 @@ public class Cobwebs extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(12*modifiers.get(WizardryItems.range_upgrade), world, caster, true);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(12 * modifiers.get(WizardryItems.range_upgrade), world,
caster, true);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
boolean flag = false;
BlockPos pos = rayTrace.getBlockPos().offset(rayTrace.sideHit);
if(world.isAirBlock(pos)){
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityTimer)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
for(EnumFacing side : EnumFacing.values()){
BlockPos pos1 = pos.offset(side);
if(world.isAirBlock(pos1)){
if(!world.isRemote){
world.setBlockState(pos1, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos1) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos1)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityTimer)world.getTileEntity(pos1))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
}
if(flag){
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_LAVA_EXTINGUISH, 1.0f, 1.0f);
@@ -77,45 +80,48 @@ public class Cobwebs extends Spell {
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
int x = MathHelper.floor_double(target.posX);
int x = MathHelper.floor(target.posX);
int y = (int)target.getEntityBoundingBox().minY;
int z = MathHelper.floor_double(target.posZ);
int z = MathHelper.floor(target.posZ);
boolean flag = false;
BlockPos pos = new BlockPos(x, y, z);
if(world.isAirBlock(pos)){
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityTimer)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
for(EnumFacing side : EnumFacing.values()){
BlockPos pos1 = pos.offset(side);
if(world.isAirBlock(pos1)){
if(!world.isRemote){
world.setBlockState(pos1, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos1) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos1)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityTimer)world.getTileEntity(pos1))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
}
if(flag){
caster.swingArm(hand);
caster.playSound(SoundEvents.BLOCK_LAVA_EXTINGUISH, 1.0f, 1.0f);
@@ -124,7 +130,7 @@ public class Cobwebs extends Spell {
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -11,6 +11,7 @@ import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryParticleType;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
@@ -19,67 +20,49 @@ import net.minecraft.world.World;
public class ConjureArmour extends Spell {
public ConjureArmour() {
public ConjureArmour(){
super(Tier.ADVANCED, 45, Element.HEALING, "conjure_armour", SpellType.DEFENCE, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
ItemStack armour;
boolean flag = false;
// Note that armourInventory is the other way round! Also note that a blank "ench" tag is set to trick
// the renderer into showing the enchantment effect on the actual armour model.
if(caster.inventory.armorInventory[3] == null && !WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_helmet)){
armour = new ItemStack(WizardryItems.spectral_helmet);
IConjuredItem.setDurationMultiplier(armour, modifiers.get(WizardryItems.duration_upgrade));
armour.getTagCompound().setTag("ench", new NBTTagList());
caster.inventory.armorInventory[3] = armour;
flag = true;
}
// A blank "ench" tag is set to trick the renderer into showing the enchantment effect on the actual armour model.
if(caster.inventory.armorInventory[2] == null && !WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_chestplate)){
armour = new ItemStack(WizardryItems.spectral_chestplate);
IConjuredItem.setDurationMultiplier(armour, modifiers.get(WizardryItems.duration_upgrade));
armour.getTagCompound().setTag("ench", new NBTTagList());
caster.inventory.armorInventory[2] = armour;
flag = true;
}
if(caster.inventory.armorInventory[1] == null && !WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_leggings)){
armour = new ItemStack(WizardryItems.spectral_leggings);
IConjuredItem.setDurationMultiplier(armour, modifiers.get(WizardryItems.duration_upgrade));
armour.getTagCompound().setTag("ench", new NBTTagList());
caster.inventory.armorInventory[1] = armour;
flag = true;
}
if(caster.inventory.armorInventory[0] == null && !WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_boots)){
armour = new ItemStack(WizardryItems.spectral_boots);
IConjuredItem.setDurationMultiplier(armour, modifiers.get(WizardryItems.duration_upgrade));
armour.getTagCompound().setTag("ench", new NBTTagList());
caster.inventory.armorInventory[0] = armour;
flag = true;
// Used this rather than getArmorInventoryList because I need to access the slot itself.
for(EntityEquipmentSlot slot : WizardryUtilities.ARMOUR_SLOTS){
if(caster.getItemStackFromSlot(slot).isEmpty() &&
!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.SPECTRAL_ARMOUR_MAP.get(slot))){
armour = new ItemStack(WizardryItems.SPECTRAL_ARMOUR_MAP.get(slot));
IConjuredItem.setDurationMultiplier(armour, modifiers.get(WizardryItems.duration_upgrade));
armour.getTagCompound().setTag("ench", new NBTTagList());
caster.setItemStackToSlot(slot, armour);
flag = true;
}
}
if(flag){
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
}
return flag;
}
}
@@ -18,24 +18,26 @@ import net.minecraft.world.World;
public class ConjureBow extends Spell {
public ConjureBow() {
public ConjureBow(){
super(Tier.APPRENTICE, 40, Element.SORCERY, "conjure_bow", SpellType.UTILITY, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
ItemStack bow = new ItemStack(WizardryItems.spectral_bow);
IConjuredItem.setDurationMultiplier(bow, modifiers.get(WizardryItems.duration_upgrade));
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_bow) && conjureItemInInventory(caster, bow)){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_bow)
&& conjureItemInInventory(caster, bow)){
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
if(world.isRemote){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
@@ -18,24 +18,27 @@ import net.minecraft.world.World;
public class ConjurePickaxe extends Spell {
public ConjurePickaxe() {
public ConjurePickaxe(){
super(Tier.APPRENTICE, 25, Element.SORCERY, "conjure_pickaxe", SpellType.UTILITY, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
ItemStack pickaxe = new ItemStack(WizardryItems.spectral_pickaxe);
IConjuredItem.setDurationMultiplier(pickaxe, modifiers.get(WizardryItems.duration_upgrade));
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_pickaxe) && ConjureBow.conjureItemInInventory(caster, pickaxe)){
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_pickaxe)
&& ConjureBow.conjureItemInInventory(caster, pickaxe)){
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
@@ -44,5 +47,4 @@ public class ConjurePickaxe extends Spell {
return false;
}
}
@@ -18,24 +18,26 @@ import net.minecraft.world.World;
public class ConjureSword extends Spell {
public ConjureSword() {
public ConjureSword(){
super(Tier.APPRENTICE, 25, Element.SORCERY, "conjure_sword", SpellType.UTILITY, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
ItemStack sword = new ItemStack(WizardryItems.spectral_sword);
IConjuredItem.setDurationMultiplier(sword, modifiers.get(WizardryItems.duration_upgrade));
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_sword) && ConjureBow.conjureItemInInventory(caster, sword)){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.spectral_sword)
&& ConjureBow.conjureItemInInventory(caster, sword)){
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
if(world.isRemote){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.7f, 0.9f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
@@ -44,5 +46,4 @@ public class ConjureSword extends Spell {
return false;
}
}
@@ -17,53 +17,58 @@ import net.minecraft.world.World;
public class CureEffects extends Spell {
public CureEffects() {
public CureEffects(){
super(Tier.APPRENTICE, 25, Element.HEALING, "cure_effects", SpellType.DEFENCE, 40, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f);
}
}
if(!caster.getActivePotionEffects().isEmpty()){
caster.clearActivePotions();
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
// Fixes the sound not playing in first person.
if(world.isRemote) WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
if(world.isRemote) WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(!caster.getActivePotionEffects().isEmpty()){
caster.clearActivePotions();
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.6f, 0.6f, 1.0f);
}
}
caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -25,45 +25,54 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class CurseOfSoulbinding extends Spell {
public CurseOfSoulbinding() {
super(Tier.ADVANCED, 35, Element.NECROMANCY, "curse_of_soulbinding", SpellType.ATTACK, 100, EnumAction.NONE, false);
public CurseOfSoulbinding(){
super(Tier.ADVANCED, 35, Element.NECROMANCY, "curse_of_soulbinding", SpellType.ATTACK, 100, EnumAction.NONE,
false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase && WizardData.get(caster) != null){
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase && WizardData.get(caster) != null){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(!WizardData.get(caster).soulbind(target)) return false;
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
//world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.4f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 1.0f, 0.8f, 1.0f);
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
// world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0,
0.4f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0,
0.1f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), 1.0f, 0.8f, 1.0f);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
@SubscribeEvent
public static void onLivingHurtEvent(LivingHurtEvent event){
if(!event.getEntity().worldObj.isRemote && event.getEntityLiving() instanceof EntityPlayer && !event.getSource().isUnblockable()
&& !(event.getSource() instanceof IElementalDamage && ((IElementalDamage)event.getSource()).isRetaliatory())){
if(!event.getEntity().world.isRemote && event.getEntityLiving() instanceof EntityPlayer
&& !event.getSource().isUnblockable() && !(event.getSource() instanceof IElementalDamage
&& ((IElementalDamage)event.getSource()).isRetaliatory())){
WizardData data = WizardData.get((EntityPlayer)event.getEntityLiving());
if(data != null){
data.damageAllSoulboundCreatures(event.getAmount());
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
public class DarknessOrb extends Spell {
public DarknessOrb() {
public DarknessOrb(){
super(Tier.ADVANCED, 20, Element.NECROMANCY, "darkness_orb", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -26,37 +26,40 @@ public class DarknessOrb extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityDarknessOrb darknessorb = new EntityDarknessOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(darknessorb);
world.spawnEntity(darknessorb);
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
caster.swingArm(hand);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityDarknessOrb darknessorb = new EntityDarknessOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE));
EntityDarknessOrb darknessorb = new EntityDarknessOrb(world, caster,
modifiers.get(SpellModifiers.DAMAGE));
darknessorb.directTowards(target, 0.5f);
world.spawnEntityInWorld(darknessorb);
world.spawnEntity(darknessorb);
}
caster.playSound(SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -18,24 +18,27 @@ import net.minecraft.world.World;
public class Darkvision extends Spell {
public Darkvision() {
public Darkvision(){
super(Tier.APPRENTICE, 20, Element.EARTH, "darkvision", SpellType.UTILITY, 40, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, (int)(900*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.0f, 0.4f, 0.7f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.0f, 0.4f, 0.7f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class Dart extends Spell {
public Dart() {
public Dart(){
super(Tier.BASIC, 5, Element.EARTH, "dart", SpellType.ATTACK, 10, EnumAction.NONE, false);
}
@@ -27,34 +27,38 @@ public class Dart extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityDart dart = new EntityDart(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(dart);
EntityDart dart = new EntityDart(world, caster, 2 * modifiers.get(WizardryItems.range_upgrade),
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(dart);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ARROW_SHOOT, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ARROW_SHOOT, 0.5F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityDart dart = new EntityDart(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 2, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(dart);
EntityDart dart = new EntityDart(world, caster, target, 2 * modifiers.get(WizardryItems.range_upgrade),
2, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(dart);
}
caster.swingArm(hand);
caster.playSound(SoundEvents.ENTITY_ARROW_SHOOT, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -30,65 +30,69 @@ public class Decay extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(12*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(12 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
if(world.getBlockState(pos.up()).isNormalCube()) return false;
if(!world.isRemote){
world.spawnEntityInWorld(new EntityDecay(world, pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, caster));
for(int i=0;i<5;i++){
world.spawnEntity(new EntityDecay(world, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, caster));
for(int i = 0; i < 5; i++){
BlockPos pos1 = WizardryUtilities.findNearbyFloorSpace(caster, 2, 6);
if(pos1 == null) break;
world.spawnEntityInWorld(new EntityDecay(world, pos1.getX()+0.5, pos1.getY(), pos1.getZ()+0.5, caster));
world.spawnEntity(
new EntityDecay(world, pos1.getX() + 0.5, pos1.getY(), pos1.getZ() + 0.5, caster));
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
int x = MathHelper.floor_double(target.posX);
int x = MathHelper.floor(target.posX);
int y = (int)(int)target.getEntityBoundingBox().minY;
int z = MathHelper.floor_double(target.posZ);
int z = MathHelper.floor(target.posZ);
if(world.getBlockState(new BlockPos(x, y, z)).isNormalCube()) return false;
if(!world.isRemote){
world.spawnEntityInWorld(new EntityDecay(world, x+0.5, y+1, z+0.5, caster));
for(int i=0;i<5;i++){
world.spawnEntity(new EntityDecay(world, x + 0.5, y + 1, z + 0.5, caster));
for(int i = 0; i < 5; i++){
BlockPos pos = WizardryUtilities.findNearbyFloorSpace(caster, 2, 6);
if(pos == null) break;
world.spawnEntityInWorld(new EntityDecay(world, pos.getX()+0.5, pos.getY(), pos.getZ()+0.5, caster));
world.spawnEntity(new EntityDecay(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, caster));
}
}
caster.playSound(SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -16,12 +16,12 @@ import net.minecraft.world.World;
public class Decoy extends Spell {
public Decoy() {
public Decoy(){
super(Tier.ADVANCED, 40, Element.SORCERY, "decoy", SpellType.UTILITY, 200, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Determines whether the caster moves left and the decoy moves right, or vice versa.
// Uses the synchronised entity id to ensure it is consistent on client and server, but not always the same.
double splitSpeed = caster.getEntityId() % 2 == 0 ? 0.3 : -0.3;
@@ -29,52 +29,56 @@ public class Decoy extends Spell {
if(!world.isRemote){
EntityDecoy decoy = new EntityDecoy(world, caster.posX, caster.posY, caster.posZ, caster, 600);
decoy.setLocationAndAngles(caster.posX, caster.posY, caster.posZ, caster.rotationYaw, caster.rotationPitch);
decoy.addVelocity(-caster.getLookVec().zCoord*splitSpeed, 0, caster.getLookVec().xCoord*splitSpeed);
decoy.addVelocity(-caster.getLookVec().zCoord * splitSpeed, 0, caster.getLookVec().xCoord * splitSpeed);
// Ignores the show names setting, since this would allow a player to easily detect a decoy
decoy.setCustomNameTag(caster.getName());
world.spawnEntityInWorld(decoy);
world.spawnEntity(decoy);
// Tricks any mobs that are targeting the caster into targeting the decoy instead.
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY, caster.posZ, world, EntityLiving.class)){
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY,
caster.posZ, world, EntityLiving.class)){
// More likely to trick mobs the higher the damage multiplier. Starts off at 50%.
if(world.rand.nextInt((int)(6*modifiers.get(SpellModifiers.DAMAGE))) < 3){
if(world.rand.nextInt((int)(6 * modifiers.get(SpellModifiers.DAMAGE))) < 3){
if(creature.getAttackTarget() == caster) creature.setAttackTarget(decoy);
}
}
}
caster.addVelocity(caster.getLookVec().zCoord*splitSpeed, 0, -caster.getLookVec().xCoord*splitSpeed);
caster.addVelocity(caster.getLookVec().zCoord * splitSpeed, 0, -caster.getLookVec().xCoord * splitSpeed);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
// Determines whether the caster moves left and the decoy moves right, or vice versa.
double splitSpeed = world.rand.nextBoolean() ? 0.3 : -0.3;
if(!world.isRemote){
EntityDecoy decoy = new EntityDecoy(world, caster.posX, caster.posY, caster.posZ, caster, 600);
decoy.setLocationAndAngles(caster.posX, caster.posY, caster.posZ, caster.rotationYaw, caster.rotationPitch);
decoy.addVelocity(-caster.getLookVec().zCoord*splitSpeed, 0, caster.getLookVec().xCoord*splitSpeed);
world.spawnEntityInWorld(decoy);
decoy.addVelocity(-caster.getLookVec().zCoord * splitSpeed, 0, caster.getLookVec().xCoord * splitSpeed);
world.spawnEntity(decoy);
// Tricks any mobs that are targeting the caster into targeting the decoy instead.
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY, caster.posZ, world, EntityLiving.class)){
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY,
caster.posZ, world, EntityLiving.class)){
// More likely to trick mobs the higher the damage multiplier. Starts off at 50%.
if(world.rand.nextInt((int)(6*modifiers.get(SpellModifiers.DAMAGE))) < 3){
if(world.rand.nextInt((int)(6 * modifiers.get(SpellModifiers.DAMAGE))) < 3){
if(creature.getAttackTarget() == caster) creature.setAttackTarget(decoy);
}
}
}
caster.addVelocity(caster.getLookVec().zCoord*splitSpeed, 0, -caster.getLookVec().xCoord*splitSpeed);
caster.addVelocity(caster.getLookVec().zCoord * splitSpeed, 0, -caster.getLookVec().xCoord * splitSpeed);
caster.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -23,36 +23,50 @@ import net.minecraft.world.World;
public class Detonate extends Spell {
public Detonate() {
public Detonate(){
super(Tier.ADVANCED, 45, Element.FIRE, "detonate", SpellType.ATTACK, 50, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(16*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
RayTraceResult rayTrace = WizardryUtilities.rayTrace(16 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
if(!world.isRemote){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(3.0d*modifiers.get(WizardryItems.blast_upgrade), (rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5), world);
for(int i=0;i<targets.size();i++){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
3.0d * modifiers.get(WizardryItems.blast_upgrade), (rayTrace.hitVec.xCoord + 0.5),
(rayTrace.hitVec.yCoord + 0.5), (rayTrace.hitVec.zCoord + 0.5), world);
for(int i = 0; i < targets.size(); i++){
targets.get(i).attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.BLAST),
// Damage decreases with distance but cannot be less than 0, naturally.
Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance((rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5))*4, 0) * modifiers.get(SpellModifiers.DAMAGE));
Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance(
(rayTrace.hitVec.xCoord + 0.5), (rayTrace.hitVec.yCoord + 0.5),
(rayTrace.hitVec.zCoord + 0.5)) * 4, 0) * modifiers.get(SpellModifiers.DAMAGE));
}
}
if(world.isRemote){
double dx = (rayTrace.hitVec.xCoord+0.5) - caster.posX;
double dy = (rayTrace.hitVec.yCoord+0.5) - WizardryUtilities.getPlayerEyesPos(caster);
double dz = (rayTrace.hitVec.zCoord+0.5) - caster.posZ;
world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, (rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5), 0, 0, 0);
for(int i=1;i<5;i++){
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
double dx = (rayTrace.hitVec.xCoord + 0.5) - caster.posX;
double dy = (rayTrace.hitVec.yCoord + 0.5) - WizardryUtilities.getPlayerEyesPos(caster);
double dz = (rayTrace.hitVec.zCoord + 0.5) - caster.posZ;
world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, (rayTrace.hitVec.xCoord + 0.5),
(rayTrace.hitVec.yCoord + 0.5), (rayTrace.hitVec.zCoord + 0.5), 0, 0, 0);
for(int i = 1; i < 5; i++){
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
}
}
world.playSound(caster, (rayTrace.hitVec.xCoord+0.5), (rayTrace.hitVec.yCoord+0.5), (rayTrace.hitVec.zCoord+0.5), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
world.playSound(caster, (rayTrace.hitVec.xCoord + 0.5), (rayTrace.hitVec.yCoord + 0.5),
(rayTrace.hitVec.zCoord + 0.5), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F,
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
caster.swingArm(hand);
return true;
}
@@ -60,15 +74,18 @@ public class Detonate extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(3.0d, target.posX, target.posY, target.posZ, world);
for(int i=0;i<targets.size();i++){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(3.0d, target.posX,
target.posY, target.posZ, world);
for(int i = 0; i < targets.size(); i++){
targets.get(i).attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.BLAST),
// Damage decreases with distance but cannot be less than 0, naturally.
Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance(target.posX, target.posY, target.posZ)*4, 0) * modifiers.get(SpellModifiers.DAMAGE));
Math.max(12.0f - (float)((EntityLivingBase)targets.get(i)).getDistance(target.posX,
target.posY, target.posZ) * 4, 0) * modifiers.get(SpellModifiers.DAMAGE));
}
}
@@ -77,13 +94,21 @@ public class Detonate extends Spell {
double dy = target.posY - (caster.posY + caster.getEyeHeight());
double dz = target.posZ - caster.posZ;
world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, target.posX, target.posY, target.posZ, 0, 0, 0);
for(int i=1;i<5;i++){
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
for(int i = 1; i < 5; i++){
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
}
}
// Player is null here because the sound was not caused by a player.
world.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
world.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE,
SoundCategory.BLOCKS, 4.0F,
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
caster.swingArm(hand);
return true;
}
@@ -18,33 +18,36 @@ import net.minecraft.world.World;
public class Diamondflesh extends Spell {
public Diamondflesh() {
public Diamondflesh(){
super(Tier.MASTER, 100, Element.HEALING, "diamondflesh", SpellType.DEFENCE, 300, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 4, false, false));
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 4, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.0f, 0.5f, 1.0f);
x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.0f, 0.5f, 1.0f);
x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.7f, 0.9f);
z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.6f, 0.7f, 0.9f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
}
@@ -18,44 +18,46 @@ import net.minecraft.world.World;
public class Earthquake extends Spell {
public Earthquake() {
public Earthquake(){
super(Tier.MASTER, 75, Element.EARTH, "earthquake", SpellType.ATTACK, 250, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.onGround){
if(!world.isRemote){
world.spawnEntityInWorld(new EntityEarthquake(world, caster.posX, caster.getEntityBoundingBox().minY, caster.posZ,
caster, (int)(20*modifiers.get(WizardryItems.blast_upgrade)), modifiers.get(SpellModifiers.DAMAGE)));
world.spawnEntity(new EntityEarthquake(world, caster.posX, caster.getEntityBoundingBox().minY,
caster.posZ, caster, (int)(20 * modifiers.get(WizardryItems.blast_upgrade)),
modifiers.get(SpellModifiers.DAMAGE)));
}else{
world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX, caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX,
caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0);
double particleX, particleZ;
for(int i=0;i<40;i++){
particleX = caster.posX - 1.0d + 2*world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble();
for(int i = 0; i < 40; i++){
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster);
if(block != null){
world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY,
particleZ, particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block));
particleZ, particleX - caster.posX, 0, particleZ - caster.posZ,
Block.getStateId(block));
}
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_EARTHQUAKE, 2, 1);
caster.swingArm(hand);
return true;
}
return false;
}
}
@@ -24,70 +24,84 @@ import net.minecraft.world.World;
public class Entrapment extends Spell {
public Entrapment() {
public Entrapment(){
super(Tier.ADVANCED, 35, Element.NECROMANCY, "entrapment", SpellType.ATTACK, 75, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase entity = (EntityLivingBase) rayTrace.entityHit;
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase entity = (EntityLivingBase)rayTrace.entityHit;
if(!world.isRemote){
entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE));
EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), true, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(entitybubble);
entity.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
1.0f * modifiers.get(SpellModifiers.DAMAGE));
EntityBubble entitybubble = new EntityBubble(world, entity.posX, entity.posY, entity.posZ, caster,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), true,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(entitybubble);
entity.startRiding(entitybubble);
}
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0,
0.1f, 0.0f, 0.0f);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.3F + 0.7F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F,
world.rand.nextFloat() * 0.3F + 0.7F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 1.0f * modifiers.get(SpellModifiers.DAMAGE));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
1.0f * modifiers.get(SpellModifiers.DAMAGE));
// Deprecated in favour of entity riding method
//entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0));
EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), true, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(entitybubble);
// entity.addPotionEffect(new PotionEffect(Wizardry.bubblePotion, 200, 0));
EntityBubble entitybubble = new EntityBubble(world, target.posX, target.posY, target.posZ, caster,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), true,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(entitybubble);
target.startRiding(entitybubble);
}
if(world.isRemote){
double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target);
for(int i=1; i<25; i+=2){
double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target);
double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f;
for(int i = 1; i < 25; i += 2){
double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
world.spawnParticle(EnumParticleTypes.PORTAL, x1, y1 - 0.5, z1, 0.0d, 0.0d, 0.0d);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
0, 0.1f, 0.0f, 0.0f);
}
}
caster.swingArm(hand);
@@ -97,7 +111,7 @@ public class Entrapment extends Spell {
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -20,47 +20,53 @@ import net.minecraft.world.World;
public class FireResistance extends Spell {
public FireResistance() {
public FireResistance(){
super(Tier.ADVANCED, 20, Element.FIRE, "fire_resistance", SpellType.DEFENCE, 80, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
// Like witches, wizards who have this spell will only cast it if they are on fire.
if(caster.isBurning() && !caster.isPotionActive(MobEffects.FIRE_RESISTANCE)){
caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 0.5f, 0.0f);
}
}
caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
return false;
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class FireSigil extends Spell {
public FireSigil() {
public FireSigil(){
super(Tier.APPRENTICE, 10, Element.FIRE, "fire_sigil", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -27,17 +27,19 @@ public class FireSigil extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){
if(!world.isRemote){
double x = rayTrace.hitVec.xCoord;
double y = rayTrace.hitVec.yCoord;
double z = rayTrace.hitVec.zCoord;
EntityFireSigil firesigil = new EntityFireSigil(world, x, y, z, caster, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(firesigil);
EntityFireSigil firesigil = new EntityFireSigil(world, x, y, z, caster,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(firesigil);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, 1.0F);
@@ -46,5 +48,4 @@ public class FireSigil extends Spell {
return false;
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class Fireball extends Spell {
public Fireball() {
public Fireball(){
super(Tier.APPRENTICE, 10, Element.FIRE, "fireball", SpellType.ATTACK, 15, EnumAction.NONE, false);
// Does 2.5 hearts of damage and 5 seconds of fire, for reference.
}
@@ -28,20 +28,17 @@ public class Fireball extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
if(!world.isRemote){
EntitySmallFireball fireball = new EntitySmallFireball(world, caster, 1, 1, 1);
fireball.setPosition(
caster.posX + look.xCoord,
caster.posY + look.yCoord + 1.3,
caster.posZ + look.zCoord);
fireball.setPosition(caster.posX + look.xCoord, caster.posY + look.yCoord + 1.3, caster.posZ + look.zCoord);
fireball.accelerationX = look.xCoord * 0.1;
fireball.accelerationY = look.yCoord * 0.1;
fireball.accelerationZ = look.zCoord * 0.1;
world.spawnEntityInWorld(fireball);
world.spawnEntity(fireball);
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
@@ -50,27 +47,29 @@ public class Fireball extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntitySmallFireball fireball = new EntitySmallFireball(world, caster, 1, 1, 1);
double dx = target.posX - caster.posX;
double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (caster.posY + (double)(caster.height / 2.0F));
double dz = target.posZ - caster.posZ;
fireball.accelerationX = dx/caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationY = dy/caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationZ = dz/caster.getDistanceToEntity(target) * 0.1;
fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ);
world.spawnEntityInWorld(fireball);
double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F)
- (caster.posY + (double)(caster.height / 2.0F));
double dz = target.posZ - caster.posZ;
fireball.accelerationX = dx / caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationY = dy / caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationZ = dz / caster.getDistanceToEntity(target) * 0.1;
fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ);
world.spawnEntity(fireball);
}
caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
caster.swingArm(hand);
return true;
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
public class Firebolt extends Spell {
public Firebolt() {
public Firebolt(){
super(Tier.APPRENTICE, 10, Element.FIRE, "firebolt", SpellType.ATTACK, 10, EnumAction.NONE, false);
}
@@ -26,40 +26,41 @@ public class Firebolt extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityFirebolt firebolt = new EntityFirebolt(world, caster, modifiers.get(SpellModifiers.DAMAGE));
firebolt.motionX *= 2.5;
firebolt.motionY *= 2.5;
firebolt.motionZ *= 2.5;
world.spawnEntityInWorld(firebolt);
world.spawnEntity(firebolt);
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
caster.swingArm(hand);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityFirebolt firebolt = new EntityFirebolt(world, caster, modifiers.get(SpellModifiers.DAMAGE));
firebolt.directTowards(target, 2.5f);
world.spawnEntityInWorld(firebolt);
world.spawnEntity(firebolt);
}
caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class Firebomb extends Spell {
public Firebomb() {
public Firebomb(){
super(Tier.APPRENTICE, 15, Element.FIRE, "firebomb", SpellType.ATTACK, 25, EnumAction.NONE, false);
}
@@ -27,37 +27,41 @@ public class Firebomb extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntityInWorld(firebomb);
EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntity(firebomb);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
EntityFirebomb firebomb = new EntityFirebomb(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
firebomb.directTowards(target, 1.5f);
world.spawnEntityInWorld(firebomb);
world.spawnEntity(firebomb);
}
caster.swingArm(hand);
caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -18,7 +18,7 @@ import net.minecraft.world.World;
public class Fireskin extends Spell {
public Fireskin() {
public Fireskin(){
super(Tier.ADVANCED, 40, Element.FIRE, "fireskin", SpellType.DEFENCE, 250, EnumAction.BOW, false);
}
@@ -28,40 +28,43 @@ public class Fireskin extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Cannot be cast when it has already been cast
if(!caster.isPotionActive(WizardryPotions.fireskin)){
if(!world.isRemote){
caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0));
caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
// Cannot be cast when it has already been cast
if(!caster.isPotionActive(WizardryPotions.fireskin)){
if(!world.isRemote){
caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0));
caster.addPotionEffect(new PotionEffect(WizardryPotions.fireskin,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
return true;
}
return false;
}
return false;
}
@Override
public boolean canBeCastByNPCs() {
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -25,47 +25,59 @@ import net.minecraft.world.World;
public class Firestorm extends Spell {
public Firestorm() {
public Firestorm(){
super(Tier.MASTER, 15, Element.FIRE, "firestorm", SpellType.ATTACK, 0, EnumAction.NONE, true);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)){
target.setFire(10);
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), 6.0f * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE),
6.0f * modifiers.get(SpellModifiers.DAMAGE));
}else{
if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote && ticksInUse == 1) caster.sendMessage(new TextComponentTranslation("spell.resist",
target.getName(), this.getNameForTranslationFormatted()));
}
}else if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos().offset(rayTrace.sideHit);
if(world.isAirBlock(pos)){
if(!world.isRemote){
world.setBlockState(pos, Blocks.FIRE.getDefaultState());
}
}
}
if(world.isRemote){
for(int i=0; i<40; i++){
for(int i = 0; i < 40; i++){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()*0.6f - 0.3f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()*0.4f - 0.2f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()*0.6f - 0.3f;
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0);
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() * 0.6f - 0.3f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() * 0.4f - 0.2f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() * 0.6f - 0.3f;
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1,
look.xCoord * modifiers.get(WizardryItems.range_upgrade),
look.yCoord * modifiers.get(WizardryItems.range_upgrade),
look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1,
look.xCoord * modifiers.get(WizardryItems.range_upgrade),
look.yCoord * modifiers.get(WizardryItems.range_upgrade),
look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0, 3 + world.rand.nextFloat(), 0, 0);
}
}
if(ticksInUse % 16 == 0){
@@ -75,5 +87,4 @@ public class Firestorm extends Spell {
return true;
}
}
@@ -24,36 +24,48 @@ import net.minecraft.world.World;
public class FlameRay extends Spell {
public FlameRay() {
public FlameRay(){
super(Tier.APPRENTICE, 5, Element.FIRE, "flame_ray", SpellType.ATTACK, 0, EnumAction.NONE, true);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)){
target.setFire(10);
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
}else{
if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote && ticksInUse == 1) caster.sendMessage(new TextComponentTranslation("spell.resist",
target.getName(), this.getNameForTranslationFormatted()));
}
}
if(world.isRemote){
for(int i=0; i<20; i++){
for(int i = 0; i < 20; i++){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 0);
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1,
look.xCoord * modifiers.get(WizardryItems.range_upgrade),
look.yCoord * modifiers.get(WizardryItems.range_upgrade),
look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1,
look.xCoord * modifiers.get(WizardryItems.range_upgrade),
look.yCoord * modifiers.get(WizardryItems.range_upgrade),
look.zCoord * modifiers.get(WizardryItems.range_upgrade), 0);
}
}
if(ticksInUse % 16 == 0){
@@ -62,23 +74,34 @@ public class FlameRay extends Spell {
}
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize();
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ)
.normalize();
if(target != null){
target.setFire(10);
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
}
if(world.isRemote){
for(int i=0; i<20; i++){
double x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 0);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 0);
for(int i = 0; i < 20; i++){
double x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
double z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1,
vec.xCoord * modifiers.get(WizardryItems.range_upgrade),
vec.yCoord * modifiers.get(WizardryItems.range_upgrade),
vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 0);
Wizardry.proxy.spawnParticle(WizardryParticleType.MAGIC_FIRE, world, x1, y1, z1,
vec.xCoord * modifiers.get(WizardryItems.range_upgrade),
vec.yCoord * modifiers.get(WizardryItems.range_upgrade),
vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 0);
}
}
if(ticksInUse % 16 == 0){
@@ -87,7 +110,7 @@ public class FlameRay extends Spell {
}
return true;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,33 +17,34 @@ import net.minecraft.world.World;
public class FlamingAxe extends Spell {
public FlamingAxe() {
public FlamingAxe(){
super(Tier.ADVANCED, 45, Element.FIRE, "flaming_axe", SpellType.UTILITY, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
ItemStack flamingaxe = new ItemStack(WizardryItems.flaming_axe);
IConjuredItem.setDurationMultiplier(flamingaxe, modifiers.get(WizardryItems.duration_upgrade));
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.flaming_axe) && ConjureBow.conjureItemInInventory(caster, flamingaxe)){
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.flaming_axe)
&& ConjureBow.conjureItemInInventory(caster, flamingaxe)){
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
world.spawnParticle(EnumParticleTypes.FLAME, x1, y1, z1, 0, 0, 0);
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
return true;
}
return false;
}
}
@@ -23,45 +23,49 @@ import net.minecraft.world.World;
public class FlamingWeapon extends Spell {
public FlamingWeapon() {
public FlamingWeapon(){
super(Tier.ADVANCED, 35, Element.FIRE, "flaming_weapon", SpellType.UTILITY, 70, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Won't work if the weapon already has the enchantment
if(WizardData.get(caster) != null && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.flaming_weapon) <= 0){
if(WizardData.get(caster) != null
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.flaming_weapon) <= 0){
for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){
if(stack != null){
if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow)
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.flaming_weapon)){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.flaming_weapon,
modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1
: (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)
/ Constants.DAMAGE_INCREASE_PER_TIER + 0.5f));
if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.flaming_weapon)){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.flaming_weapon, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.flaming_weapon,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.flaming_weapon, (int)(900*modifiers.get(WizardryItems.duration_upgrade)));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f);
}
if(world.isRemote){
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f);
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
return true;
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
return true;
}
}
}
return false;
}
}
@@ -20,24 +20,31 @@ public class Flight extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!caster.isInWater() && !caster.isElytraFlying()){
// The division thingy checks if the look direction is the opposite way to the velocity. If this is the
// case then the velocity should be added regardless of the player's current speed.
if((Math.abs(caster.motionX) < 0.6 || caster.motionX/caster.getLookVec().xCoord < 0)
&& (Math.abs(caster.motionZ) < 0.6 || caster.motionZ/caster.getLookVec().zCoord < 0)){
caster.addVelocity(caster.getLookVec().xCoord/20, 0, caster.getLookVec().zCoord/20);
if((Math.abs(caster.motionX) < 0.6 || caster.motionX / caster.getLookVec().xCoord < 0)
&& (Math.abs(caster.motionZ) < 0.6 || caster.motionZ / caster.getLookVec().zCoord < 0)){
caster.addVelocity(caster.getLookVec().xCoord / 20, 0, caster.getLookVec().zCoord / 20);
}
// y velocity is handled separately to stop the player from falling from the sky when they reach maximum horizontal speed.
if(Math.abs(caster.motionY) < 0.6 || caster.motionY/caster.getLookVec().yCoord < 0){
caster.motionY += caster.getLookVec().yCoord/20 + 0.075;
// y velocity is handled separately to stop the player from falling from the sky when they reach maximum
// horizontal speed.
if(Math.abs(caster.motionY) < 0.6 || caster.motionY / caster.getLookVec().yCoord < 0){
caster.motionY += caster.getLookVec().yCoord / 20 + 0.075;
}
caster.fallDistance = 0.0f;
}
if(world.isRemote){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 1 + world.rand.nextDouble()*2, WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(), caster.posZ - 1 + world.rand.nextDouble()*2, 0, -0.1F, 0, 15, 0.8f, 1.0f, 0.5f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 1 + world.rand.nextDouble()*2, WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(), caster.posZ - 1 + world.rand.nextDouble()*2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX - 1 + world.rand.nextDouble() * 2,
WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(),
caster.posZ - 1 + world.rand.nextDouble() * 2, 0, -0.1F, 0, 15, 0.8f, 1.0f, 0.5f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX - 1 + world.rand.nextDouble() * 2,
WizardryUtilities.getPlayerEyesPos(caster) - 0.5f + world.rand.nextDouble(),
caster.posZ - 1 + world.rand.nextDouble() * 2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f);
}
if(ticksInUse % 24 == 0){
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERDRAGON_FLAP, 0.5F, 1.0f);
@@ -45,5 +52,4 @@ public class Flight extends Spell {
return true;
}
}
@@ -20,36 +20,42 @@ import net.minecraft.world.World;
public class FontOfMana extends Spell {
public FontOfMana() {
public FontOfMana(){
super(Tier.MASTER, 100, Element.HEALING, "font_of_mana", SpellType.UTILITY, 250, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
List<EntityPlayer> targets = WizardryUtilities.getEntitiesWithinRadius(5*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world, EntityPlayer.class);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
List<EntityPlayer> targets = WizardryUtilities.getEntitiesWithinRadius(
5 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world,
EntityPlayer.class);
for(EntityPlayer target : targets){
if(WizardryUtilities.isPlayerAlly(caster, target) || target == caster){
// Damage multiplier can only ever be 1 or 1.6 for master spells, so there's little point in actually calculating this.
target.addPotionEffect(new PotionEffect(WizardryPotions.font_of_mana, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE) > 1 ? 1 : 0));
// Damage multiplier can only ever be 1 or 1.6 for master spells, so there's little point in actually
// calculating this.
target.addPotionEffect(new PotionEffect(WizardryPotions.font_of_mana,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE) > 1 ? 1 : 0));
}
}
if(world.isRemote){
for(int i=0;i<100*modifiers.get(WizardryItems.blast_upgrade);i++){
double radius = (1 + world.rand.nextDouble()*4)*modifiers.get(WizardryItems.blast_upgrade);
double angle = world.rand.nextDouble()*Math.PI*2;
float hue = world.rand.nextFloat()*0.4f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + radius*Math.cos(angle), caster.getEntityBoundingBox().minY, caster.posZ + radius*Math.sin(angle),
0, 0.03, 0, 50, 1, 1-hue, 0.6f+hue);
for(int i = 0; i < 100 * modifiers.get(WizardryItems.blast_upgrade); i++){
double radius = (1 + world.rand.nextDouble() * 4) * modifiers.get(WizardryItems.blast_upgrade);
double angle = world.rand.nextDouble() * Math.PI * 2;
float hue = world.rand.nextFloat() * 0.4f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX + radius * Math.cos(angle), caster.getEntityBoundingBox().minY,
caster.posZ + radius * Math.sin(angle), 0, 0.03, 0, 50, 1, 1 - hue, 0.6f + hue);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
}
@@ -18,36 +18,40 @@ import net.minecraft.world.World;
public class FontOfVitality extends Spell {
public FontOfVitality() {
public FontOfVitality(){
super(Tier.MASTER, 75, Element.HEALING, "font_of_vitality", SpellType.DEFENCE, 300, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, (int)(1200*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION,
(int)(1200 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.REGENERATION,
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.6f, 0.7f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 0.6f, 0.7f);
x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.8f, 0.3f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 0.8f, 0.3f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class ForceArrow extends Spell {
public ForceArrow() {
public ForceArrow(){
super(Tier.APPRENTICE, 15, Element.SORCERY, "force_arrow", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -27,36 +27,40 @@ public class ForceArrow extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityForceArrow forceArrow = new EntityForceArrow(world, caster, 1*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(forceArrow);
EntityForceArrow forceArrow = new EntityForceArrow(world, caster,
1 * modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(forceArrow);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_FORCE, 1.0f, 1.2f + world.rand.nextFloat()*0.2f);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_FORCE, 1.0f,
1.2f + world.rand.nextFloat() * 0.2f);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityForceArrow forceArrow = new EntityForceArrow(world, caster, target, 1*modifiers.get(WizardryItems.range_upgrade), 2, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(forceArrow);
EntityForceArrow forceArrow = new EntityForceArrow(world, caster, target,
1 * modifiers.get(WizardryItems.range_upgrade), 2, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(forceArrow);
}
caster.swingArm(hand);
caster.playSound(WizardrySounds.SPELL_FORCE, 1.0f, 1.2f + world.rand.nextFloat()*0.2f);
caster.playSound(WizardrySounds.SPELL_FORCE, 1.0f, 1.2f + world.rand.nextFloat() * 0.2f);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class ForceOrb extends Spell {
public ForceOrb() {
public ForceOrb(){
super(Tier.ADVANCED, 20, Element.SORCERY, "force_orb", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -27,37 +27,41 @@ public class ForceOrb extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntityInWorld(forceOrb);
EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntity(forceOrb);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
EntityForceOrb forceOrb = new EntityForceOrb(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
forceOrb.directTowards(target, 1.5f);
world.spawnEntityInWorld(forceOrb);
world.spawnEntity(forceOrb);
}
caster.swingArm(hand);
caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class Forcefield extends Spell {
public Forcefield() {
public Forcefield(){
super(Tier.ADVANCED, 45, Element.HEALING, "forcefield", SpellType.DEFENCE, 200, EnumAction.BOW, false);
}
@@ -27,43 +27,47 @@ public class Forcefield extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.onGround){
if(!world.isRemote){
EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)));
world.spawnEntityInWorld(forcefield);
EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ, caster,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)));
world.spawnEntity(forcefield);
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION_LARGE, 1.0f, 1.0f);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
// Wizards can no longer cast forcefield when they are inside one
if(caster.onGround && world.getEntitiesWithinAABB(EntityForcefield.class, caster.getEntityBoundingBox()).isEmpty()){
if(caster.onGround
&& world.getEntitiesWithinAABB(EntityForcefield.class, caster.getEntityBoundingBox()).isEmpty()){
if(!world.isRemote){
EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)));
world.spawnEntityInWorld(forcefield);
EntityForcefield forcefield = new EntityForcefield(world, caster.posX, caster.posY, caster.posZ,
caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade)));
world.spawnEntity(forcefield);
}
caster.playSound(WizardrySounds.SPELL_CONJURATION_LARGE, 1.0f, 1.0f);
return true;
}
return false;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -23,42 +23,54 @@ import net.minecraft.world.World;
public class ForestsCurse extends Spell {
public ForestsCurse() {
public ForestsCurse(){
super(Tier.MASTER, 75, Element.EARTH, "forests_curse", SpellType.ATTACK, 200, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(5.0d*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
5.0d * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
for(EntityLivingBase target : targets){
if(WizardryUtilities.isValidTarget(caster, target) && !MagicDamage.isEntityImmune(DamageType.POISON, target)){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), 4.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.POISON, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2));
target.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2));
target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2));
if(WizardryUtilities.isValidTarget(caster, target)
&& !MagicDamage.isEntityImmune(DamageType.POISON, target)){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON),
4.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.POISON,
(int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2));
target.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS,
(int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2));
target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS,
(int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2));
}
}
if(world.isRemote){
for(int i=0;i<50*modifiers.get(WizardryItems.blast_upgrade);i++){
double radius = (1 + world.rand.nextDouble()*4)*modifiers.get(WizardryItems.blast_upgrade);
double angle = world.rand.nextDouble()*Math.PI*2;
float brightness = world.rand.nextFloat()/4;
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, caster.posX + radius*Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius*Math.sin(angle),
0, -0.2, 0, 0, 0.05f+brightness, 0.2f+brightness, 0.0f);
brightness = world.rand.nextFloat()/4;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + radius*Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius*Math.sin(angle),
0, -0.05, 0, 50, 0.1f+brightness, 0.2f+brightness, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, caster.posX + radius*Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius*Math.sin(angle), 0, -0.01, 0, 40 + world.rand.nextInt(12));
for(int i = 0; i < 50 * modifiers.get(WizardryItems.blast_upgrade); i++){
double radius = (1 + world.rand.nextDouble() * 4) * modifiers.get(WizardryItems.blast_upgrade);
double angle = world.rand.nextDouble() * Math.PI * 2;
float brightness = world.rand.nextFloat() / 4;
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
caster.posX + radius * Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5,
caster.posZ + radius * Math.sin(angle), 0, -0.2, 0, 0, 0.05f + brightness, 0.2f + brightness,
0.0f);
brightness = world.rand.nextFloat() / 4;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX + radius * Math.cos(angle), WizardryUtilities.getPlayerEyesPos(caster) + 0.5,
caster.posZ + radius * Math.sin(angle), 0, -0.05, 0, 50, 0.1f + brightness, 0.2f + brightness,
0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, caster.posX + radius * Math.cos(angle),
WizardryUtilities.getPlayerEyesPos(caster) + 0.5, caster.posZ + radius * Math.sin(angle), 0,
-0.01, 0, 40 + world.rand.nextInt(12));
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
}
@@ -30,84 +30,112 @@ import net.minecraft.world.World;
public class Freeze extends Spell {
public Freeze() {
public Freeze(){
super(Tier.BASIC, 5, Element.ICE, "freeze", SpellType.ATTACK, 10, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Entity ray trace is done first because block ray trace passes through entities; if it was the other
// way round, entities would only be hit when there were no blocks in range behind them.
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
if(target instanceof EntityBlaze || target instanceof EntityMagmaCube || target instanceof EntityBlazeMinion){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(target instanceof EntityBlaze || target instanceof EntityMagmaCube
|| target instanceof EntityBlazeMinion){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
}
if(MagicDamage.isEntityImmune(DamageType.FROST, target)){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()));
}else{
target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1));
target.addPotionEffect(new PotionEffect(WizardryPotions.frost,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1));
}
if(target.isBurning()){
target.extinguish();
}
if(world.isRemote){
double dx = target.posX - caster.posX;
double dy = (target.getEntityBoundingBox().minY + target.height/2) - WizardryUtilities.getPlayerEyesPos(caster);
double dy = (target.getEntityBoundingBox().minY + target.height / 2)
- WizardryUtilities.getPlayerEyesPos(caster);
double dz = target.posZ - caster.posZ;
for(int i=1;i<5;i++){
float brightness = 0.5f + (world.rand.nextFloat()/2);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, -0.02, 0, 40 + world.rand.nextInt(10));
for(int i = 1; i < 5; i++){
float brightness = 0.5f + (world.rand.nextFloat() / 2);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, -0.02, 0,
40 + world.rand.nextInt(10));
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.4F + 1.2F);
return true;
}else{
rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, true);
rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, caster, true);
// Gets block the player is looking at and sets to ice or covers with snow as necessary
// Note how the block is set on the server side only (kinda obvious really) but the particles are
// spawned on the client side only.
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
if(world.getBlockState(pos).getBlock() == Blocks.WATER && !world.isRemote){
world.setBlockState(pos, Blocks.ICE.getDefaultState());
}else if(world.getBlockState(pos).getBlock() == Blocks.LAVA && !world.isRemote){
world.setBlockState(pos, Blocks.OBSIDIAN.getDefaultState());
}else if(world.getBlockState(pos).getBlock() == Blocks.FLOWING_LAVA && !world.isRemote){
world.setBlockState(pos, Blocks.COBBLESTONE.getDefaultState());
}else if(rayTrace.sideHit == EnumFacing.UP && !world.isRemote && world.isSideSolid(pos, EnumFacing.UP) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){
}else if(rayTrace.sideHit == EnumFacing.UP && !world.isRemote && world.isSideSolid(pos, EnumFacing.UP)
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())){
world.setBlockState(pos.up(), Blocks.SNOW_LAYER.getDefaultState());
}
if(world.isRemote){
double dx = pos.getX() + 0.5 - caster.posX;
double dy = pos.getY() + 0.5 - WizardryUtilities.getPlayerEyesPos(caster);
double dz = pos.getZ() + 0.5 - caster.posZ;
for(int i=1;i<5;i++){
float brightness = 0.5f + (world.rand.nextFloat()/2);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0.0d, 0.0d, 0.0d, 20 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 20 + world.rand.nextInt(8), 1.0f, 1.0f, 1.0f);
for(int i = 1; i < 5; i++){
float brightness = 0.5f + (world.rand.nextFloat() / 2);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5))
+ world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0.0d, 0.0d, 0.0d,
20 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5))
+ world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0,
20 + world.rand.nextInt(8), 1.0f, 1.0f, 1.0f);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.4F + 1.2F);
return true;
}
}
@@ -115,16 +143,20 @@ public class Freeze extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(target instanceof EntityBlaze || target instanceof EntityMagmaCube || target instanceof EntityBlazeMinion){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
if(target instanceof EntityBlaze || target instanceof EntityMagmaCube
|| target instanceof EntityBlazeMinion){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
}
if(!world.isRemote && !MagicDamage.isEntityImmune(DamageType.FROST, target)){
target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1));
target.addPotionEffect(new PotionEffect(WizardryPotions.frost,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1));
}
if(target.isBurning()){
@@ -133,12 +165,21 @@ public class Freeze extends Spell {
if(world.isRemote){
double dx = target.posX - caster.posX;
double dy = (target.getEntityBoundingBox().minY + target.height/2) - (caster.posY + caster.getEyeHeight());
double dy = (target.getEntityBoundingBox().minY + target.height / 2)
- (caster.posY + caster.getEyeHeight());
double dz = target.posZ - caster.posZ;
for(int i=1;i<5;i++){
float brightness = 0.5f + (world.rand.nextFloat()/2);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, -0.02, 0, 40 + world.rand.nextInt(10));
for(int i = 1; i < 5; i++){
float brightness = 0.5f + (world.rand.nextFloat() / 2);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, -0.02, 0,
40 + world.rand.nextInt(10));
}
}
@@ -146,10 +187,10 @@ public class Freeze extends Spell {
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -23,49 +23,55 @@ import net.minecraft.world.World;
public class FreezingWeapon extends Spell {
/** The NBT tag name for storing the level of frost enchantment in the arrow's tag compound. (There's nothing
* stopping you from using this elsewhere to shoot freezing arrows if you want to...) */
/**
* The NBT tag name for storing the level of frost enchantment in the arrow's tag compound. (There's nothing
* stopping you from using this elsewhere to shoot freezing arrows if you want to...)
*/
public static final String FREEZING_ARROW_NBT_KEY = "frostLevel";
public FreezingWeapon() {
public FreezingWeapon(){
super(Tier.ADVANCED, 35, Element.ICE, "freezing_weapon", SpellType.UTILITY, 70, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Won't work if the weapon already has the enchantment
if(WizardData.get(caster) != null && WizardData.get(caster).getImbuementDuration(WizardryEnchantments.freezing_weapon) <= 0){
if(WizardData.get(caster) != null
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.freezing_weapon) <= 0){
for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){
if(stack != null){
if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow)
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.freezing_weapon)){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.freezing_weapon,
modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1
: (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)
/ Constants.DAMAGE_INCREASE_PER_TIER + 0.5f));
if((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.freezing_weapon)){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.freezing_weapon, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.freezing_weapon,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.freezing_weapon, (int)(900*modifiers.get(WizardryItems.duration_upgrade)));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f);
}
if(world.isRemote){
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f);
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
return true;
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
return true;
}
}
}
return false;
}
}
@@ -18,33 +18,35 @@ import net.minecraft.world.World;
public class FrostAxe extends Spell {
public FrostAxe() {
public FrostAxe(){
super(Tier.ADVANCED, 45, Element.ICE, "frost_axe", SpellType.UTILITY, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
ItemStack frostaxe = new ItemStack(WizardryItems.frost_axe);
IConjuredItem.setDurationMultiplier(frostaxe, modifiers.get(WizardryItems.duration_upgrade));
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.frost_axe) && ConjureBow.conjureItemInInventory(caster, frostaxe)){
if(!WizardryUtilities.doesPlayerHaveItem(caster, WizardryItems.frost_axe)
&& ConjureBow.conjureItemInInventory(caster, frostaxe)){
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0, -0.02d, 0, 40 + world.rand.nextInt(10));
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0, -0.02d, 0,
40 + world.rand.nextInt(10));
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0f, 1.0f);
return true;
}
return false;
}
}
@@ -27,48 +27,64 @@ import net.minecraft.world.World;
public class FrostRay extends Spell {
public FrostRay() {
public FrostRay(){
super(Tier.APPRENTICE, 5, Element.ICE, "frost_ray", SpellType.ATTACK, 0, EnumAction.NONE, true);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(target.isBurning()){
target.extinguish();
}
if(MagicDamage.isEntityImmune(DamageType.FROST, target)){
if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote && ticksInUse == 1) caster.sendMessage(new TextComponentTranslation("spell.resist",
target.getName(), this.getNameForTranslationFormatted()));
}else{
// For frost ray the entity can move slightly, unlike freeze.
target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 0));
target.addPotionEffect(new PotionEffect(WizardryPotions.frost,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 0));
float baseDamage = target instanceof EntityBlaze || target instanceof EntityMagmaCube ? 6.0f : 3.0f;
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), baseDamage * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST),
baseDamage * modifiers.get(SpellModifiers.DAMAGE));
}
}
if(world.isRemote){
for(int i=0; i<20; i++){
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, 0.6f, 1.0f);
for(int i = 0; i < 20; i++){
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1,
look.xCoord * modifiers.get(WizardryItems.range_upgrade),
look.yCoord * modifiers.get(WizardryItems.range_upgrade),
look.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f,
0.6f, 1.0f);
x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, look.xCoord*modifiers.get(WizardryItems.range_upgrade), look.yCoord*modifiers.get(WizardryItems.range_upgrade), look.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, 1.0f, 1.0f);
x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1,
look.xCoord * modifiers.get(WizardryItems.range_upgrade),
look.yCoord * modifiers.get(WizardryItems.range_upgrade),
look.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f,
1.0f, 1.0f);
}
}
@@ -80,11 +96,13 @@ public class FrostRay extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize();
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ)
.normalize();
if(target.isBurning()){
target.extinguish();
@@ -92,24 +110,37 @@ public class FrostRay extends Spell {
if(!MagicDamage.isEntityImmune(DamageType.FROST, target)){
// For frost ray the entity can move slightly, unlike freeze.
target.addPotionEffect(new PotionEffect(WizardryPotions.frost, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 0));
target.addPotionEffect(new PotionEffect(WizardryPotions.frost,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 0));
float baseDamage = target instanceof EntityBlaze || target instanceof EntityMagmaCube ? 6.0f : 3.0f;
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST), baseDamage * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.FROST),
baseDamage * modifiers.get(SpellModifiers.DAMAGE));
}
if(world.isRemote){
for(int i=0; i<20; i++){
double x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f, 0.6f, 1.0f);
for(int i = 0; i < 20; i++){
double x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1,
vec.xCoord * modifiers.get(WizardryItems.range_upgrade),
vec.yCoord * modifiers.get(WizardryItems.range_upgrade),
vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 0.4f,
0.6f, 1.0f);
x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, vec.xCoord*modifiers.get(WizardryItems.range_upgrade), vec.yCoord*modifiers.get(WizardryItems.range_upgrade), vec.zCoord*modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f, 1.0f, 1.0f);
x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1,
vec.xCoord * modifiers.get(WizardryItems.range_upgrade),
vec.yCoord * modifiers.get(WizardryItems.range_upgrade),
vec.zCoord * modifiers.get(WizardryItems.range_upgrade), 8 + world.rand.nextInt(12), 1.0f,
1.0f, 1.0f);
}
}
@@ -117,15 +148,15 @@ public class FrostRay extends Spell {
if(ticksInUse == 0) caster.playSound(WizardrySounds.SPELL_ICE, 0.5F, 1.0f);
caster.playSound(WizardrySounds.SPELL_LOOP_ICE, 0.5F, 1.0f);
}
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs() {
public boolean canBeCastByNPCs(){
return true;
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class FrostSigil extends Spell {
public FrostSigil() {
public FrostSigil(){
super(Tier.APPRENTICE, 10, Element.ICE, "frost_sigil", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -27,17 +27,19 @@ public class FrostSigil extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){
if(!world.isRemote){
double x = rayTrace.hitVec.xCoord;
double y = rayTrace.hitVec.yCoord;
double z = rayTrace.hitVec.zCoord;
EntityFrostSigil frostsigil = new EntityFrostSigil(world, x, y, z, caster, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(frostsigil);
EntityFrostSigil frostsigil = new EntityFrostSigil(world, x, y, z, caster,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(frostsigil);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F);
@@ -46,5 +48,4 @@ public class FrostSigil extends Spell {
return false;
}
}
@@ -15,32 +15,37 @@ import net.minecraft.world.World;
public class Glide extends Spell {
public Glide() {
public Glide(){
super(Tier.ADVANCED, 5, Element.EARTH, "glide", SpellType.UTILITY, 0, EnumAction.NONE, true);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.motionY < -0.1 && !caster.isInWater()){
caster.motionY = -0.1;
if(Math.abs(caster.motionX) < 0.4 && Math.abs(caster.motionZ) < 0.4){
caster.addVelocity(caster.getLookVec().xCoord/8, 0, caster.getLookVec().zCoord/8);
//entityplayer.moveEntity(entityplayer.motionX*10, 0, entityplayer.motionZ*10);
caster.addVelocity(caster.getLookVec().xCoord / 8, 0, caster.getLookVec().zCoord / 8);
// entityplayer.moveEntity(entityplayer.motionX*10, 0, entityplayer.motionZ*10);
}
caster.fallDistance = 0.0f;
}
if(world.isRemote){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 0.25d + world.rand.nextDouble()/2, WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(), caster.posZ - 0.25d + world.rand.nextDouble()/2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world, caster.posX - 0.25d + world.rand.nextDouble()/2, WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(), caster.posZ - 0.25d + world.rand.nextDouble()/2, 0, -0.03, 0, 20);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX - 0.25d + world.rand.nextDouble() / 2,
WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(),
caster.posZ - 0.25d + world.rand.nextDouble() / 2, 0, -0.1F, 0, 15, 1.0f, 1.0f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.LEAF, world,
caster.posX - 0.25d + world.rand.nextDouble() / 2,
WizardryUtilities.getPlayerEyesPos(caster) - 1.5f + world.rand.nextDouble(),
caster.posZ - 0.25d + world.rand.nextDouble() / 2, 0, -0.03, 0, 20);
}
if(ticksInUse % 24 == 0){
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_ELYTRA_FLYING, 0.5F, 1.0f);
}
return true;
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class GreaterFireball extends Spell {
public GreaterFireball() {
public GreaterFireball(){
super(Tier.ADVANCED, 20, Element.FIRE, "greater_fireball", SpellType.ATTACK, 30, EnumAction.NONE, false);
}
@@ -27,20 +27,17 @@ public class GreaterFireball extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
if(!world.isRemote){
EntityLargeFireball fireball = new EntityLargeFireball(world, caster, 1, 1, 1);
fireball.setPosition(
caster.posX + look.xCoord,
caster.posY + look.yCoord + 1.3,
caster.posZ + look.zCoord);
fireball.setPosition(caster.posX + look.xCoord, caster.posY + look.yCoord + 1.3, caster.posZ + look.zCoord);
fireball.accelerationX = look.xCoord * 0.1;
fireball.accelerationY = look.yCoord * 0.1;
fireball.accelerationZ = look.zCoord * 0.1;
world.spawnEntityInWorld(fireball);
world.spawnEntity(fireball);
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
@@ -49,25 +46,27 @@ public class GreaterFireball extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityLargeFireball fireball = new EntityLargeFireball(world, caster, 1, 1, 1);
double dx = target.posX - caster.posX;
double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (caster.posY + (double)(caster.height / 2.0F));
double dz = target.posZ - caster.posZ;
fireball.accelerationX = dx/caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationY = dy/caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationZ = dz/caster.getDistanceToEntity(target) * 0.1;
fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ);
world.spawnEntityInWorld(fireball);
double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F)
- (caster.posY + (double)(caster.height / 2.0F));
double dz = target.posZ - caster.posZ;
fireball.accelerationX = dx / caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationY = dy / caster.getDistanceToEntity(target) * 0.1;
fireball.accelerationZ = dz / caster.getDistanceToEntity(target) * 0.1;
fireball.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ);
world.spawnEntity(fireball);
}
caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
@@ -17,46 +17,51 @@ import net.minecraft.world.World;
public class GreaterHeal extends Spell {
public GreaterHeal() {
public GreaterHeal(){
super(Tier.ADVANCED, 15, Element.HEALING, "greater_heal", SpellType.DEFENCE, 40, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.shouldHeal()){
caster.heal((int)(8*modifiers.get(SpellModifiers.DAMAGE)));
caster.heal((int)(8 * modifiers.get(SpellModifiers.DAMAGE)));
if(world.isRemote){
for(int i=0; i<10; i++){
double dx = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double dy = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double dz = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
for(int i = 0; i < 10; i++){
double dx = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double dy = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double dz = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(caster.getHealth() < caster.getMaxHealth()){
caster.heal((int)(8*modifiers.get(SpellModifiers.DAMAGE)));
caster.heal((int)(8 * modifiers.get(SpellModifiers.DAMAGE)));
if(world.isRemote){
for(int i=0; i<10; i++){
double dx = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double dx = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double dy = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double dz = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
double dz = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
}
}
caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
return false;
}
@@ -20,16 +20,17 @@ import net.minecraft.world.World;
public class GroupHeal extends Spell {
public GroupHeal() {
public GroupHeal(){
super(Tier.ADVANCED, 35, Element.HEALING, "group_heal", SpellType.DEFENCE, 150, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
boolean flag = false;
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(5*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
5 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
for(EntityLivingBase target : targets){
@@ -39,43 +40,50 @@ public class GroupHeal extends Spell {
if(((EntityPlayer)target).shouldHeal()){
target.heal((int)(6*modifiers.get(SpellModifiers.DAMAGE)));
target.heal((int)(6 * modifiers.get(SpellModifiers.DAMAGE)));
if(world.isRemote){
for(int i=0; i<10; i++){
double d0 = (double)((float)target.posX + world.rand.nextFloat()*2 - 1.0F);
double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target) - 0.5F + world.rand.nextFloat());
double d2 = (double)((float)target.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
for(int i = 0; i < 10; i++){
double d0 = (double)((float)target.posX + world.rand.nextFloat() * 2 - 1.0F);
double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target)
- 0.5F + world.rand.nextFloat());
double d2 = (double)((float)target.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F,
0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
flag = true;
}
}
// Now also works on summoned creatures
// Now also works on summoned creatures
}else if(target instanceof ISummonedCreature){
EntityLivingBase summoner = ((ISummonedCreature)target).getCaster();
if(summoner == caster || (summoner instanceof EntityPlayer && WizardryUtilities.isPlayerAlly(caster, (EntityPlayer)summoner))){
if(summoner == caster || (summoner instanceof EntityPlayer
&& WizardryUtilities.isPlayerAlly(caster, (EntityPlayer)summoner))){
if(target.getHealth() < target.getMaxHealth()){
target.heal((int)(6*modifiers.get(SpellModifiers.DAMAGE)));
target.heal((int)(6 * modifiers.get(SpellModifiers.DAMAGE)));
if(world.isRemote){
for(int i=0; i<10; i++){
double d0 = (double)((float)target.posX + world.rand.nextFloat()*2 - 1.0F);
double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target) - 0.5F + world.rand.nextFloat());
double d2 = (double)((float)target.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
for(int i = 0; i < 10; i++){
double d0 = (double)((float)target.posX + world.rand.nextFloat() * 2 - 1.0F);
double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos((EntityPlayer)target)
- 0.5F + world.rand.nextFloat());
double d2 = (double)((float)target.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F,
0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
flag = true;
}
}
@@ -85,5 +93,4 @@ public class GroupHeal extends Spell {
return flag;
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class GrowthAura extends Spell {
public GrowthAura() {
public GrowthAura(){
super(Tier.APPRENTICE, 20, Element.EARTH, "growth_aura", SpellType.UTILITY, 50, EnumAction.NONE, false);
}
@@ -27,16 +27,17 @@ public class GrowthAura extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
boolean flag = false;
for(int i=-2; i<1; i++){
for(int i = -2; i < 1; i++){
for(int j=-1; j<2; j++){
for(int j = -1; j < 2; j++){
int x = (int)caster.posX + i;
int y = WizardryUtilities.getNearestFloorLevelC(world, new BlockPos(caster.posX + i, caster.posY, caster.posZ + j), 2) - 1;
int y = WizardryUtilities.getNearestFloorLevelC(world,
new BlockPos(caster.posX + i, caster.posY, caster.posZ + j), 2) - 1;
int z = (int)caster.posZ + j;
BlockPos pos = new BlockPos(x, y, z);
@@ -67,9 +68,9 @@ public class GrowthAura extends Spell {
}
}
if(flag) WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
if(flag) WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return flag;
}
}
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
public class Hailstorm extends Spell {
public Hailstorm() {
public Hailstorm(){
super(Tier.MASTER, 75, Element.ICE, "hailstorm", SpellType.ATTACK, 300, EnumAction.NONE, false);
}
@@ -26,26 +26,30 @@ public class Hailstorm extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
if(!world.isRemote){
double x = rayTrace.hitVec.xCoord;
double y = rayTrace.hitVec.yCoord;
double z = rayTrace.hitVec.zCoord;
// Moves the entity back towards the caster a bit, so the area of effect is better centred on the position.
// Moves the entity back towards the caster a bit, so the area of effect is better centred on the
// position.
// 3.0d is the distance to move the entity back towards the caster.
double dx = caster.posX - x;
double dz = caster.posZ - z;
double distRatio = 3.0d/Math.sqrt(dx*dx + dz*dz);
x += dx*distRatio;
z += dz*distRatio;
EntityHailstorm hailstorm = new EntityHailstorm(world, x, y + 5, z, caster, (int)(120*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE));
double distRatio = 3.0d / Math.sqrt(dx * dx + dz * dz);
x += dx * distRatio;
z += dz * distRatio;
EntityHailstorm hailstorm = new EntityHailstorm(world, x, y + 5, z, caster,
(int)(120 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
hailstorm.rotationYaw = caster.rotationYawHead;
world.spawnEntityInWorld(hailstorm);
world.spawnEntity(hailstorm);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F);
@@ -17,50 +17,56 @@ import net.minecraft.world.World;
public class Heal extends Spell {
public Heal() {
public Heal(){
super(Tier.BASIC, 5, Element.HEALING, "heal", SpellType.DEFENCE, 20, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.shouldHeal()){
caster.heal((int)(4*modifiers.get(SpellModifiers.DAMAGE)));
caster.heal((int)(4 * modifiers.get(SpellModifiers.DAMAGE)));
if(world.isRemote){
for(int i=0; i<10; i++){
double d0 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
// Apparently the client side spawns the particles 1 block higher than it should... hence the - 0.5F.
double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double d2 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
for(int i = 0; i < 10; i++){
double d0 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
// Apparently the client side spawns the particles 1 block higher than it should... hence the -
// 0.5F.
double d1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double d2 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(caster.getHealth() < caster.getMaxHealth()){
caster.heal((int)(4*modifiers.get(SpellModifiers.DAMAGE)));
caster.heal((int)(4 * modifiers.get(SpellModifiers.DAMAGE)));
if(world.isRemote){
for(int i=0; i<10; i++){
double dx = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double dx = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double dy = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double dz = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
double dz = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, dx, dy, dz, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
}
}
caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
return false;
}
@@ -18,30 +18,34 @@ import net.minecraft.world.World;
public class HealAlly extends Spell {
public HealAlly() {
public HealAlly(){
super(Tier.APPRENTICE, 10, Element.HEALING, "heal_ally", SpellType.DEFENCE, 20, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 8.0f);
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade), 8.0f);
if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(target.getHealth() < target.getMaxHealth()){
target.heal((int)(5*modifiers.get(SpellModifiers.DAMAGE)));
target.heal((int)(5 * modifiers.get(SpellModifiers.DAMAGE)));
if(world.isRemote){
for(int i=0; i<10; i++){
double d0 = (double)((float)target.posX + world.rand.nextFloat()*2 - 1.0F);
// Apparently the client side spawns the particles 1 block higher than it should... hence the - 0.5F.
double d1 = (double)((float)target.getEntityBoundingBox().minY + target.height - 0.5f + world.rand.nextFloat());
double d2 = (double)((float)target.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
for(int i = 0; i < 10; i++){
double d0 = (double)((float)target.posX + world.rand.nextFloat() * 2 - 1.0F);
// Apparently the client side spawns the particles 1 block higher than it should... hence the -
// 0.5F.
double d1 = (double)((float)target.getEntityBoundingBox().minY + target.height - 0.5f
+ world.rand.nextFloat());
double d2 = (double)((float)target.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, d0, d1, d2, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 1.0f, 0.3f);
}
}
caster.swingArm(hand);
target.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
return true;
@@ -50,5 +54,4 @@ public class HealAlly extends Spell {
return false;
}
}
@@ -15,7 +15,7 @@ import net.minecraft.world.World;
public class HealingAura extends Spell {
public HealingAura() {
public HealingAura(){
super(Tier.ADVANCED, 35, Element.HEALING, "healing_aura", SpellType.DEFENCE, 150, EnumAction.BOW, false);
}
@@ -25,37 +25,43 @@ public class HealingAura extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.onGround){
if(!world.isRemote){
EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(healaura);
EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(healaura);
}
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(caster.onGround && world.getEntitiesWithinAABB(EntityHealAura.class, caster.getEntityBoundingBox()).isEmpty()){
if(caster.onGround
&& world.getEntitiesWithinAABB(EntityHealAura.class, caster.getEntityBoundingBox()).isEmpty()){
if(!world.isRemote){
EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(healaura);
EntityHealAura healaura = new EntityHealAura(world, caster.posX, caster.posY, caster.posZ, caster,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(healaura);
}
return true;
}
return false;
}
return false;
}
@Override
public boolean canBeCastByNPCs() {
public boolean canBeCastByNPCs(){
return true;
}
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
public class HomingSpark extends Spell {
public HomingSpark() {
public HomingSpark(){
super(Tier.APPRENTICE, 10, Element.LIGHTNING, "homing_spark", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -26,35 +26,37 @@ public class HomingSpark extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntitySpark spark = new EntitySpark(world, caster, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(spark);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
world.spawnEntity(spark);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
}
caster.swingArm(hand);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntitySpark spark = new EntitySpark(world, caster, modifiers.get(SpellModifiers.DAMAGE));
spark.directTowards(target, 0.5f);
world.spawnEntityInWorld(spark);
world.spawnEntity(spark);
caster.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
}
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -24,10 +24,10 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class IceAge extends Spell {
private static final int baseDuration = 1200;
public IceAge() {
public IceAge(){
super(Tier.MASTER, 70, Element.ICE, "ice_age", SpellType.ATTACK, 250, EnumAction.BOW, false);
}
@@ -37,73 +37,90 @@ public class IceAge extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(7*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
7 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
for(EntityLivingBase target : targets){
if(WizardryUtilities.isValidTarget(caster, target)){
if(!world.isRemote){
if(target instanceof EntityBlaze || target instanceof EntityMagmaCube){
// These have been removed for the time being because they cause the entity to sink into the floor when it breaks out.
//target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 8.0f * modifiers.get(SpellModifiers.DAMAGE));
// These have been removed for the time being because they cause the entity to sink into the
// floor when it breaks out.
// target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 8.0f *
// modifiers.get(SpellModifiers.DAMAGE));
}else{
//target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 4.0f * modifiers.get(SpellModifiers.DAMAGE));
// target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 4.0f *
// modifiers.get(SpellModifiers.DAMAGE));
}
if(target.isBurning()){
target.extinguish();
}
if(target instanceof EntityBlaze) caster.addStat(WizardryAchievements.freeze_blaze, 1);
if(target instanceof EntityLiving){
// Stops the entity looking red while frozen and the resulting z-fighting
target.hurtTime = 0;
BlockPos pos = new BlockPos(target);
// Short mobs such as spiders and pigs
if((target.height < 1.2 || target.isChild()) && WizardryUtilities.canBlockBeReplaced(world, pos)){
if((target.height < 1.2 || target.isChild())
&& WizardryUtilities.canBlockBeReplaced(world, pos)){
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving) target, 1, 1);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1,
1);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime(
(int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
target.setDead();
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
}
// Normal sized mobs like zombies and skeletons
else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){
else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos)
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())){
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving) target, 1, 2);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1,
2);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime(
(int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos.up()) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos.up())).setCreatureAndPart((EntityLiving) target, 2, 2);
((TileEntityStatue)world.getTileEntity(pos.up()))
.setCreatureAndPart((EntityLiving)target, 2, 2);
}
target.setDead();
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
}
// Tall mobs like endermen
else if(WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up()) && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){
else if(WizardryUtilities.canBlockBeReplaced(world, pos)
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())
&& WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving) target, 1, 3);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1,
3);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime(
(int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos.up()) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos.up())).setCreatureAndPart((EntityLiving) target, 2, 3);
((TileEntityStatue)world.getTileEntity(pos.up()))
.setCreatureAndPart((EntityLiving)target, 2, 3);
}
world.setBlockState(pos.up(2), WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos.up(2)) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos.up(2))).setCreatureAndPart((EntityLiving) target, 3, 3);
((TileEntityStatue)world.getTileEntity(pos.up(2)))
.setCreatureAndPart((EntityLiving)target, 3, 3);
}
target.setDead();
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
@@ -113,19 +130,19 @@ public class IceAge extends Spell {
}
}
if(!world.isRemote){
for(int i=-7; i<8; i++){
for(int j=-7; j<8; j++){
for(int i = -7; i < 8; i++){
for(int j = -7; j < 8; j++){
BlockPos pos = new BlockPos(caster).add(i, 0, j);
int y = WizardryUtilities.getNearestFloorLevelB(world, new BlockPos(pos), 7);
pos = new BlockPos(pos.getX(), y, pos.getZ());
double dist = caster.getDistance((int)caster.posX + i, y, (int)caster.posZ + j);
// Randomised with weighting so that the nearer the block the more likely it is to be snowed.
if(y != -1 && world.rand.nextInt((int)dist*2 + 1) < 7 && dist < 8){
if(y != -1 && world.rand.nextInt((int)dist * 2 + 1) < 7 && dist < 8){
if(world.getBlockState(pos.down()) == Blocks.WATER.getDefaultState()){
world.setBlockState(pos.down(), Blocks.ICE.getDefaultState());
}else if(world.getBlockState(pos.down()) == Blocks.LAVA.getDefaultState()){
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class IceCharge extends Spell {
public IceCharge() {
public IceCharge(){
super(Tier.ADVANCED, 20, Element.ICE, "ice_charge", SpellType.ATTACK, 30, EnumAction.NONE, false);
}
@@ -27,37 +27,41 @@ public class IceCharge extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntityInWorld(icecharge);
EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntity(icecharge);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.4F + 1.4F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
EntityIceCharge icecharge = new EntityIceCharge(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
icecharge.directTowards(target, 1.5f);
world.spawnEntityInWorld(icecharge);
world.spawnEntity(icecharge);
}
caster.swingArm(hand);
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class IceLance extends Spell {
public IceLance() {
public IceLance(){
super(Tier.ADVANCED, 20, Element.ICE, "ice_lance", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -27,34 +27,38 @@ public class IceLance extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityIceLance iceLance = new EntityIceLance(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(iceLance);
EntityIceLance iceLance = new EntityIceLance(world, caster, 2 * modifiers.get(WizardryItems.range_upgrade),
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(iceLance);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.4F + 0.8F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityIceLance iceLance = new EntityIceLance(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(iceLance);
EntityIceLance iceLance = new EntityIceLance(world, caster, target,
2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(iceLance);
}
caster.swingArm(hand);
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class IceShard extends Spell {
public IceShard() {
public IceShard(){
super(Tier.APPRENTICE, 10, Element.ICE, "ice_shard", SpellType.ATTACK, 10, EnumAction.NONE, false);
}
@@ -27,34 +27,38 @@ public class IceShard extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityIceShard iceShard = new EntityIceShard(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(iceShard);
EntityIceShard iceShard = new EntityIceShard(world, caster, 2 * modifiers.get(WizardryItems.range_upgrade),
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(iceShard);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.4F + 1.4F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityIceShard iceShard = new EntityIceShard(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(iceShard);
EntityIceShard iceShard = new EntityIceShard(world, caster, target,
2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(iceShard);
}
caster.swingArm(hand);
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -18,7 +18,7 @@ import net.minecraft.world.World;
public class IceShroud extends Spell {
public IceShroud() {
public IceShroud(){
super(Tier.ADVANCED, 40, Element.ICE, "ice_shroud", SpellType.DEFENCE, 250, EnumAction.BOW, false);
}
@@ -28,39 +28,43 @@ public class IceShroud extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Cannot be cast when it has already been cast
if(!caster.isPotionActive(WizardryPotions.ice_shroud)){
if(!world.isRemote){
caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0));
caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.4F + 1.4F);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
// Cannot be cast when it has already been cast
if(!caster.isPotionActive(WizardryPotions.ice_shroud)){
if(!world.isRemote){
caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0));
caster.addPotionEffect(new PotionEffect(WizardryPotions.ice_shroud,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.4F);
return true;
}
return false;
}
return false;
}
@Override
public boolean canBeCastByNPCs() {
public boolean canBeCastByNPCs(){
return true;
}
@@ -21,7 +21,7 @@ import net.minecraft.world.World;
public class IceSpikes extends Spell {
public IceSpikes() {
public IceSpikes(){
super(Tier.ADVANCED, 30, Element.ICE, "ice_spikes", SpellType.ATTACK, 75, EnumAction.NONE, false);
}
@@ -31,64 +31,70 @@ public class IceSpikes extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){
if(!world.isRemote){
double x = rayTrace.hitVec.xCoord;
double y = rayTrace.hitVec.yCoord;
double z = rayTrace.hitVec.zCoord;
for(int i=0; i<(int)(18*modifiers.get(WizardryItems.blast_upgrade)); i++){
float angle = (float)(world.rand.nextFloat()*Math.PI*2);
double radius = 0.5 + world.rand.nextDouble()*2*modifiers.get(WizardryItems.blast_upgrade);
double x1 = x + radius*MathHelper.sin(angle);
double z1 = z + radius*MathHelper.cos(angle);
double y1 = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(MathHelper.floor_double(x1), (int)y, MathHelper.floor_double(z1)), 2) - 1;
for(int i = 0; i < (int)(18 * modifiers.get(WizardryItems.blast_upgrade)); i++){
float angle = (float)(world.rand.nextFloat() * Math.PI * 2);
double radius = 0.5 + world.rand.nextDouble() * 2 * modifiers.get(WizardryItems.blast_upgrade);
double x1 = x + radius * MathHelper.sin(angle);
double z1 = z + radius * MathHelper.cos(angle);
double y1 = WizardryUtilities.getNearestFloorLevel(world,
new BlockPos(MathHelper.floor(x1), (int)y, MathHelper.floor(z1)), 2) - 1;
if(y1 > -1){
EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster, 30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(icespike);
EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster,
30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(icespike);
}
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, 1.0F);
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
double x = target.posX;
double y = target.posY;
double z = target.posZ;
for(int i=0; i<(int)(18*modifiers.get(WizardryItems.blast_upgrade)); i++){
float angle = (float)(world.rand.nextFloat()*Math.PI*2);
double radius = 0.5 + world.rand.nextDouble()*2*modifiers.get(WizardryItems.blast_upgrade);
double x1 = x + radius*MathHelper.sin(angle);
double z1 = z + radius*MathHelper.cos(angle);
double y1 = WizardryUtilities.getNearestFloorLevel(world, new BlockPos(MathHelper.floor_double(x1), (int)y, MathHelper.floor_double(z1)), 2) - 1;
for(int i = 0; i < (int)(18 * modifiers.get(WizardryItems.blast_upgrade)); i++){
float angle = (float)(world.rand.nextFloat() * Math.PI * 2);
double radius = 0.5 + world.rand.nextDouble() * 2 * modifiers.get(WizardryItems.blast_upgrade);
double x1 = x + radius * MathHelper.sin(angle);
double z1 = z + radius * MathHelper.cos(angle);
double y1 = WizardryUtilities.getNearestFloorLevel(world,
new BlockPos(MathHelper.floor(x1), (int)y, MathHelper.floor(z1)), 2) - 1;
if(y1 > -1){
EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster, 30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(icespike);
EntityIceSpike icespike = new EntityIceSpike(world, x1, y1, z1, caster,
30 + world.rand.nextInt(15), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(icespike);
}
}
}
@@ -96,13 +102,13 @@ public class IceSpikes extends Spell {
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, 1.0F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -26,27 +26,29 @@ public class IceStatue extends Spell {
private static final int baseDuration = 400;
public IceStatue() {
public IceStatue(){
super(Tier.APPRENTICE, 15, Element.ICE, "ice_statue", SpellType.ATTACK, 40, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLiving && !world.isRemote){
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLiving && !world.isRemote){
EntityLiving target = (EntityLiving)rayTrace.entityHit;
EntityLiving target = (EntityLiving) rayTrace.entityHit;
BlockPos pos = new BlockPos(target);
if(target.isBurning()){
target.extinguish();
}
// Stops the entity looking red while frozen and the resulting z-fighting
target.hurtTime = 0;
@@ -57,17 +59,20 @@ public class IceStatue extends Spell {
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 1);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
target.setDead();
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
}
// Normal sized mobs like zombies and skeletons
else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){
else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos)
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())){
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 2);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState());
@@ -78,11 +83,14 @@ public class IceStatue extends Spell {
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
}
// Tall mobs like endermen and iron golems
else if(WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up()) && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){
else if(WizardryUtilities.canBlockBeReplaced(world, pos)
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())
&& WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 3);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState());
@@ -99,22 +107,25 @@ public class IceStatue extends Spell {
}
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
float brightness = 0.5f + (world.rand.nextFloat()/2);
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
float brightness = 0.5f + (world.rand.nextFloat() / 2);
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0.0d, -0.02d, 0.0d, 20 + world.rand.nextInt(10));
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), brightness, brightness + 0.1f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x1, y1, z1, 0.0d, -0.02d, 0.0d,
20 + world.rand.nextInt(10));
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.4F + 1.2F);
return true;
}
}
@@ -23,48 +23,64 @@ import net.minecraft.world.World;
public class Ignite extends Spell {
public Ignite() {
public Ignite(){
super(Tier.BASIC, 5, Element.FIRE, "ignite", SpellType.ATTACK, 10, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Entity ray trace is done first because block ray trace passes through entities; if it was the other
// way round, entities would only be hit when there were no blocks in range behind them.
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(MagicDamage.isEntityImmune(DamageType.FIRE, target)){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()));
}else{
target.setFire((int)(10*modifiers.get(WizardryItems.duration_upgrade)));
target.setFire((int)(10 * modifiers.get(WizardryItems.duration_upgrade)));
}
if(world.isRemote){
double dx = target.posX - caster.posX;
double dy = (target.getEntityBoundingBox().minY + target.height/2) - WizardryUtilities.getPlayerEyesPos(caster);
double dy = (target.getEntityBoundingBox().minY + target.height / 2)
- WizardryUtilities.getPlayerEyesPos(caster);
double dz = target.posZ - caster.posZ;
// i starts at 1 so that particles are not spawned in the player's head.
for(int i=1;i<5;i++){
//WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
//WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
for(int i = 1; i < 5; i++){
// WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5))
// + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ +
// (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
// WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5))
// + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ +
// (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F,
world.rand.nextFloat() * 0.4F + 0.8F);
return true;
}else{
rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world, caster,
false);
// Gets block the player is looking at and sets the appropriate surrounding air block to fire.
// Note how the block is set on the server side only (kinda obvious really) but the particles are
@@ -77,21 +93,30 @@ public class Ignite extends Spell {
if(!world.isRemote){
world.setBlockState(pos, Blocks.FIRE.getDefaultState());
}
if(world.isRemote){
double dx = pos.getX() + 0.5 - caster.posX;
double dy = pos.getY() + 0.5 - WizardryUtilities.getPlayerEyesPos(caster);
double dz = pos.getZ() + 0.5 - caster.posZ;
for(int i=1;i<5;i++){
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, WizardryUtilities.getPlayerEyesPos(caster) + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
for(int i = 1; i < 5; i++){
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5))
+ world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
WizardryUtilities.getPlayerEyesPos(caster) + (i * (dy / 5))
+ world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ITEM_FLINTANDSTEEL_USE, 1.0F,
world.rand.nextFloat() * 0.4F + 0.8F);
return true;
}
}
@@ -100,22 +125,35 @@ public class Ignite extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!MagicDamage.isEntityImmune(DamageType.FIRE, target)) target.setFire((int)(10*modifiers.get(WizardryItems.duration_upgrade)));
if(!MagicDamage.isEntityImmune(DamageType.FIRE, target))
target.setFire((int)(10 * modifiers.get(WizardryItems.duration_upgrade)));
if(world.isRemote){
double dx = target.posX - caster.posX;
double dy = (target.getEntityBoundingBox().minY + target.height/2) - (caster.posY + caster.getEyeHeight());
double dy = (target.getEntityBoundingBox().minY + target.height / 2)
- (caster.posY + caster.getEyeHeight());
double dz = target.posZ - caster.posZ;
// i starts at 1 so that particles are not spawned in the player's head.
for(int i=1;i<5;i++){
//WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
//WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME, caster.posX + (i*(dx/5)) + world.rand.nextFloat()/5, caster.posY + caster.getEyeHeight() + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ + (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0);
for(int i = 1; i < 5; i++){
// WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5))
// + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ +
// (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
// WizardryUtilities.spawnParticleAndNotify(world, EnumParticleTypes.FLAME, caster.posX + (i*(dx/5))
// + world.rand.nextFloat()/5, caster.posY + (i*(dy/5)) + world.rand.nextFloat()/5, caster.posZ +
// (i*(dz/5)) + world.rand.nextFloat()/5, 0, 0, 0, 0, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
world.spawnParticle(EnumParticleTypes.FLAME,
caster.posX + (i * (dx / 5)) + world.rand.nextFloat() / 5,
caster.posY + caster.getEyeHeight() + (i * (dy / 5)) + world.rand.nextFloat() / 5,
caster.posZ + (i * (dz / 5)) + world.rand.nextFloat() / 5, 0, 0, 0);
}
}
@@ -23,54 +23,62 @@ import net.minecraft.world.World;
public class ImbueWeapon extends Spell {
public ImbueWeapon() {
public ImbueWeapon(){
super(Tier.APPRENTICE, 20, Element.SORCERY, "imbue_weapon", SpellType.UTILITY, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Won't work if the weapon already has the enchantment
if(WizardData.get(caster) != null){
for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){
if(stack != null){
if(stack.getItem() instanceof ItemSword
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_sword)
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_sword) <= 0){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.magic_sword, modifiers.get(SpellModifiers.DAMAGE) == 1.0f
? 1
: (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f) / Constants.DAMAGE_INCREASE_PER_TIER
+ 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_sword,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)));
if(stack.getItem() instanceof ItemSword && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_sword)
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_sword) <= 0){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.magic_sword, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_sword, (int)(900*modifiers.get(WizardryItems.duration_upgrade)));
}else if(stack.getItem() instanceof ItemBow
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_bow)
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_bow) <= 0){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.magic_bow, modifiers.get(SpellModifiers.DAMAGE) == 1.0f
? 1
: (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f) / Constants.DAMAGE_INCREASE_PER_TIER
+ 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_bow,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)));
}else if(stack.getItem() instanceof ItemBow && !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_bow)
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_bow) <= 0){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.magic_bow, modifiers.get(SpellModifiers.DAMAGE) == 1.0f ? 1 : (int)((modifiers.get(SpellModifiers.DAMAGE) - 1.0f)/Constants.DAMAGE_INCREASE_PER_TIER + 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_bow, (int)(900*modifiers.get(WizardryItems.duration_upgrade)));
}else{
continue;
}
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
return true;
}else{
continue;
}
if(world.isRemote){
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.9f, 0.7f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
return true;
}
}
return false;
}
}
@@ -35,16 +35,18 @@ public class Intimidate extends Spell {
/** The NBT tag name for storing the feared entity's UUID in the target's tag compound. */
public static final String NBT_KEY = "fearedEntity";
public Intimidate() {
public Intimidate(){
super(Tier.APPRENTICE, 20, Element.NECROMANCY, "intimidate", SpellType.ATTACK, 100, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
List<EntityCreature> entities = WizardryUtilities.getEntitiesWithinRadius(8*modifiers.get(WizardryItems.range_upgrade), caster.posX, caster.posY, caster.posZ, world, EntityCreature.class);
List<EntityCreature> entities = WizardryUtilities.getEntitiesWithinRadius(
8 * modifiers.get(WizardryItems.range_upgrade), caster.posX, caster.posY, caster.posZ, world,
EntityCreature.class);
for(EntityCreature target : entities){
@@ -53,16 +55,17 @@ public class Intimidate extends Spell {
NBTTagCompound entityNBT = target.getEntityData();
if(entityNBT != null) entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID());
((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.fear, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0));
((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.fear,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
}else{
for(int i=0; i<30; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, caster.posX - 1 + world.rand.nextDouble()*2,
caster.getEntityBoundingBox().minY + 1.5 + world.rand.nextDouble()*0.5,
caster.posZ - 1 + world.rand.nextDouble()*2,
0, 0, 0, 0, 0.9f, 0.1f, 0.0f);
for(int i = 0; i < 30; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
caster.posX - 1 + world.rand.nextDouble() * 2,
caster.getEntityBoundingBox().minY + 1.5 + world.rand.nextDouble() * 0.5,
caster.posZ - 1 + world.rand.nextDouble() * 2, 0, 0, 0, 0, 0.9f, 0.1f, 0.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERDRAGON_GROWL, 1.0f, 1.0f);
@@ -72,6 +75,7 @@ public class Intimidate extends Spell {
/**
* Finds a random position away from the caster and sets the given target's AI path to that location. Defined here
* so it can be used both in the spell itself and in the potion effect (event handler).
*
* @param target The entity running away
* @param caster The entity that is being run away from
* @return True if a new path was found and set, false if not.
@@ -80,15 +84,17 @@ public class Intimidate extends Spell {
if(target.getDistanceToEntity(caster) < 16){
Vec3d Vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(target, 16, 7, new Vec3d(caster.posX, caster.posY, caster.posZ));
Vec3d Vec3d = RandomPositionGenerator.findRandomTargetBlockAwayFrom(target, 16, 7,
new Vec3d(caster.posX, caster.posY, caster.posZ));
if (Vec3d == null){
if(Vec3d == null){
return false;
}else{
// In both cases it is necessary to check if the entity already has a path so it doesn't change direction
// In both cases it is necessary to check if the entity already has a path so it doesn't change
// direction
// every tick, unless that path is towards the caster.
//Path path = target.getNavigator().getPathToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord);
// Path path = target.getNavigator().getPathToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord);
boolean flag = true;
@@ -99,24 +105,25 @@ public class Intimidate extends Spell {
// Has a built in mind trick effect because for whatever reason this makes it work with skeletons.
target.setAttackTarget(null);
if(flag) return target.getNavigator().tryMoveToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord, 1.25);//target.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
if(flag) return target.getNavigator().tryMoveToXYZ(Vec3d.xCoord, Vec3d.yCoord, Vec3d.zCoord, 1.25);// target.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
}
}
return false;
}
@SubscribeEvent
public static void onLivingUpdateEvent(LivingUpdateEvent event){
if(event.getEntityLiving().isPotionActive(WizardryPotions.fear) && event.getEntityLiving() instanceof EntityCreature){
if(event.getEntityLiving().isPotionActive(WizardryPotions.fear)
&& event.getEntityLiving() instanceof EntityCreature){
NBTTagCompound entityNBT = event.getEntityLiving().getEntityData();
EntityCreature creature = (EntityCreature)event.getEntityLiving();
if(entityNBT != null && entityNBT.hasKey(NBT_KEY)){
Entity caster = WizardryUtilities.getEntityByUUID(creature.worldObj, entityNBT.getUniqueId(NBT_KEY));
Entity caster = WizardryUtilities.getEntityByUUID(creature.world, entityNBT.getUniqueId(NBT_KEY));
if(caster instanceof EntityLivingBase){
Intimidate.runAway(creature, (EntityLivingBase)caster);
@@ -20,35 +20,40 @@ import net.minecraft.world.World;
public class InvigoratingPresence extends Spell {
public InvigoratingPresence() {
super(Tier.APPRENTICE, 30, Element.HEALING, "invigorating_presence", SpellType.UTILITY, 60, EnumAction.BOW, false);
public InvigoratingPresence(){
super(Tier.APPRENTICE, 30, Element.HEALING, "invigorating_presence", SpellType.UTILITY, 60, EnumAction.BOW,
false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
List<EntityPlayer> targets = WizardryUtilities.getEntitiesWithinRadius(5*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world, EntityPlayer.class);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
List<EntityPlayer> targets = WizardryUtilities.getEntitiesWithinRadius(
5 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world,
EntityPlayer.class);
for(EntityPlayer target : targets){
if(WizardryUtilities.isPlayerAlly(caster, target) || target == caster){
// Strength 2 for 45 seconds.
target.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, (int)(900*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
target.addPotionEffect(new PotionEffect(MobEffects.STRENGTH,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
}
}
if(world.isRemote){
for(int i=0;i<50*modifiers.get(WizardryItems.blast_upgrade);i++){
double radius = (1 + world.rand.nextDouble()*4)*modifiers.get(WizardryItems.blast_upgrade);
double angle = world.rand.nextDouble()*Math.PI*2;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX + radius*Math.cos(angle), caster.getEntityBoundingBox().minY, caster.posZ + radius*Math.sin(angle),
0, 0.03, 0, 50, 1, 0.2f, 0.2f);
for(int i = 0; i < 50 * modifiers.get(WizardryItems.blast_upgrade); i++){
double radius = (1 + world.rand.nextDouble() * 4) * modifiers.get(WizardryItems.blast_upgrade);
double angle = world.rand.nextDouble() * Math.PI * 2;
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX + radius * Math.cos(angle), caster.getEntityBoundingBox().minY,
caster.posZ + radius * Math.sin(angle), 0, 0.03, 0, 50, 1, 0.2f, 0.2f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
}
@@ -20,40 +20,46 @@ import net.minecraft.world.World;
public class Invisibility extends Spell {
public Invisibility() {
public Invisibility(){
super(Tier.ADVANCED, 35, Element.SORCERY, "invisibility", SpellType.UTILITY, 200, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(!caster.isPotionActive(MobEffects.INVISIBILITY)){
caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.7f, 1.0f, 1.0f);
}
}
caster.playSound(WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
@@ -18,27 +18,27 @@ import net.minecraft.world.World;
public class InvokeWeather extends Spell {
public InvokeWeather() {
public InvokeWeather(){
super(Tier.ADVANCED, 30, Element.LIGHTNING, "invoke_weather", SpellType.UTILITY, 100, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.dimension == 0){
if(!world.isRemote){
// TODO: Backport these changes.
int standardWeatherTime = (300 + (new Random()).nextInt(600)) * 20;
if(world.isRaining()){
caster.addChatComponentMessage(new TextComponentTranslation("spell.invoke_weather.sun"));
caster.sendMessage(new TextComponentTranslation("spell.invoke_weather.sun"));
world.getWorldInfo().setCleanWeatherTime(standardWeatherTime);
world.getWorldInfo().setRainTime(0);
world.getWorldInfo().setThunderTime(0);
world.getWorldInfo().setRaining(false);
world.getWorldInfo().setThundering(false);
}else{
caster.addChatComponentMessage(new TextComponentTranslation("spell.invoke_weather.rain"));
caster.sendMessage(new TextComponentTranslation("spell.invoke_weather.rain"));
world.getWorldInfo().setCleanWeatherTime(0);
world.getWorldInfo().setRainTime(standardWeatherTime);
world.getWorldInfo().setThunderTime(standardWeatherTime);
@@ -47,21 +47,22 @@ public class InvokeWeather extends Spell {
world.getWorldInfo().setThundering(world.rand.nextInt(3) == 0);
}
}
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.5f, 0.7f, 1.0f);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.5f, 0.7f, 1.0f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_LIGHTNING_THUNDER, 0.5F, 1.0f);
return true;
}
return false;
}
}
@@ -20,41 +20,47 @@ import net.minecraft.world.World;
public class Ironflesh extends Spell {
public Ironflesh() {
public Ironflesh(){
super(Tier.ADVANCED, 30, Element.HEALING, "ironflesh", SpellType.DEFENCE, 100, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 2, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 2, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(!caster.isPotionActive(MobEffects.RESISTANCE)){
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 2, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 2, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.4f, 0.5f, 0.6f);
}
}
@@ -14,34 +14,33 @@ import net.minecraft.world.World;
public class Leap extends Spell {
public Leap() {
public Leap(){
super(Tier.BASIC, 10, Element.EARTH, "leap", SpellType.UTILITY, 20, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.onGround){
caster.motionY = 0.65 * modifiers.get(SpellModifiers.DAMAGE);
caster.addVelocity(caster.getLookVec().xCoord*0.3, 0, caster.getLookVec().zCoord*0.3);
caster.addVelocity(caster.getLookVec().xCoord * 0.3, 0, caster.getLookVec().zCoord * 0.3);
if(world.isRemote){
for(int i=0; i<10; i++){
for(int i = 0; i < 10; i++){
double x = (double)(caster.posX + world.rand.nextFloat() - 0.5F);
double y = (double)(caster.getEntityBoundingBox().minY);
double z = (double)(caster.posZ + world.rand.nextFloat() - 0.5F);
world.spawnParticle(EnumParticleTypes.CLOUD, x, y, z, 0, 0, 0);
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERDRAGON_FLAP, 0.5F, 1.0f);
caster.swingArm(hand);
return true;
}
return false;
}
}
@@ -20,14 +20,17 @@ public class Levitation extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.fallDistance = 0;
caster.motionY = caster.motionY < 0.5d ? caster.motionY + 0.1d : caster.motionY;
if(world.isRemote){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, caster.posX - 0.25d + world.rand.nextDouble()/2, WizardryUtilities.getPlayerEyesPos(caster) - 1.5f, caster.posZ - 0.25d + world.rand.nextDouble()/2, 0, -0.1F, 0, 15, 0.5f, 1.0f, 0.7f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world,
caster.posX - 0.25d + world.rand.nextDouble() / 2,
WizardryUtilities.getPlayerEyesPos(caster) - 1.5f,
caster.posZ - 0.25d + world.rand.nextDouble() / 2, 0, -0.1F, 0, 15, 0.5f, 1.0f, 0.7f);
}
if(ticksInUse % 24 == 0 && world.isRemote){
Wizardry.proxy.playMovingSound(caster, WizardrySounds.SPELL_LOOP_SPARKLE, 0.5F, 1.0f, false);
@@ -35,5 +38,4 @@ public class Levitation extends Spell {
return true;
}
}
@@ -22,37 +22,44 @@ import net.minecraft.world.World;
public class LifeDrain extends Spell {
public LifeDrain() {
public LifeDrain(){
super(Tier.APPRENTICE, 10, Element.NECROMANCY, "life_drain", SpellType.ATTACK, 0, EnumAction.NONE, true);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
if(ticksInUse % 12 == 0){
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 2.0f * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
2.0f * modifiers.get(SpellModifiers.DAMAGE));
caster.heal(1);
}
}
if(world.isRemote){
for(int i=5; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
for(int i = 5; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
//world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
// world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
if(i % 5 == 0){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
0, 0.1f, 0.0f, 0.0f);
}
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05*look.xCoord*i, -0.05*look.yCoord*i, -0.05*look.zCoord*i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05 * look.xCoord * i,
-0.05 * look.yCoord * i, -0.05 * look.zCoord * i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f);
}
}
if(ticksInUse % 18 == 0){
@@ -63,39 +70,46 @@ public class LifeDrain extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize();
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ)
.normalize();
if(target != null){
if(ticksInUse % 12 == 0){
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC), 2.0f * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
2.0f * modifiers.get(SpellModifiers.DAMAGE));
caster.heal(1);
}
}
if(world.isRemote){
for(int i=5; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
for(int i = 5; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + vec.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + vec.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
//world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
double x1 = caster.posX + vec.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + vec.yCoord * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
double z1 = caster.posZ + vec.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
// world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
if(i % 5 == 0){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
0, 0.1f, 0.0f, 0.0f);
}
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05*vec.xCoord*i, -0.05*vec.yCoord*i, -0.05*vec.zCoord*i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, -0.05 * vec.xCoord * i,
-0.05 * vec.yCoord * i, -0.05 * vec.zCoord * i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f);
}
}
if(ticksInUse % 18 == 0){
if(ticksInUse == 0) caster.playSound(WizardrySounds.SPELL_SUMMONING, 1.0F, 0.6f);
caster.playSound(WizardrySounds.SPELL_LOOP_CRACKLE, 2.0F, 1.0f);
}
return true;
}
@Override
public boolean canBeCastByNPCs() {
public boolean canBeCastByNPCs(){
return true;
}
@@ -18,7 +18,7 @@ import net.minecraft.world.World;
public class Light extends Spell {
public Light() {
public Light(){
super(Tier.BASIC, 5, Element.SORCERY, "light", SpellType.UTILITY, 15, EnumAction.NONE, false);
}
@@ -28,41 +28,43 @@ public class Light extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(4, world, caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos().offset(rayTrace.sideHit);
if(world.isAirBlock(pos)){
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.magic_light.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(600*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityTimer)world.getTileEntity(pos))
.setLifetime((int)(600 * modifiers.get(WizardryItems.duration_upgrade)));
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
return true;
}
}else{
int x = (int) (Math.floor(caster.posX) + caster.getLookVec().xCoord*4);
int y = (int) (Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord*4);
int z = (int) (Math.floor(caster.posZ) + caster.getLookVec().zCoord*4);
int x = (int)(Math.floor(caster.posX) + caster.getLookVec().xCoord * 4);
int y = (int)(Math.floor(caster.posY) + caster.eyeHeight + caster.getLookVec().yCoord * 4);
int z = (int)(Math.floor(caster.posZ) + caster.getLookVec().zCoord * 4);
BlockPos pos = new BlockPos(x, y, z);
if(world.isAirBlock(pos)){
//world.playSound(x, y, z, "sound.ambient.cave.cave", 1.0f, 1.5f, false);
// world.playSound(x, y, z, "sound.ambient.cave.cave", 1.0f, 1.5f, false);
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.magic_light.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos)).setLifetime((int)(600*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityTimer)world.getTileEntity(pos))
.setLifetime((int)(600 * modifiers.get(WizardryItems.duration_upgrade)));
}
}
caster.swingArm(hand);
@@ -73,5 +75,4 @@ public class Light extends Spell {
return false;
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class LightningArrow extends Spell {
public LightningArrow() {
public LightningArrow(){
super(Tier.APPRENTICE, 15, Element.LIGHTNING, "lightning_arrow", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -27,36 +27,40 @@ public class LightningArrow extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(lightningArrow);
EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster,
2 * modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(lightningArrow);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 1.3F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F,
world.rand.nextFloat() * 0.3F + 1.3F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(lightningArrow);
EntityLightningArrow lightningArrow = new EntityLightningArrow(world, caster, target,
2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(lightningArrow);
}
caster.swingArm(hand);
caster.playSound(WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 1.3F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -24,11 +24,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class LightningBolt extends Spell {
/** The NBT key used to store the UUID of the player that summoned the lightning bolt. Used for achievements. */
public static final String NBT_KEY = "summoningPlayer";
public LightningBolt() {
public LightningBolt(){
super(Tier.ADVANCED, 40, Element.LIGHTNING, "lightning_bolt", SpellType.ATTACK, 80, EnumAction.NONE, false);
}
@@ -38,72 +38,75 @@ public class LightningBolt extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(200, world, caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
// Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly.
// Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly.
// TODO: Remove this requirement?
if(world.canBlockSeeSky(pos.up())){
if(!world.isRemote){
EntityLightningBolt entitylightning = new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), false);
world.addWeatherEffect(entitylightning);
// Code for eventhandler recognition; for achievements and such like. Left in for future use.
NBTTagCompound entityNBT = entitylightning.getEntityData();
entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID());
}
caster.swingArm(hand);
return true;
}
}
return false;
if(world.canBlockSeeSky(pos.up())){
if(!world.isRemote){
EntityLightningBolt entitylightning = new EntityLightningBolt(world, pos.getX(), pos.getY(),
pos.getZ(), false);
world.addWeatherEffect(entitylightning);
// Code for eventhandler recognition; for achievements and such like. Left in for future use.
NBTTagCompound entityNBT = entitylightning.getEntityData();
entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID());
}
caster.swingArm(hand);
return true;
}
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
int x = (int)target.posX;
int y = (int)target.posY;
int z = (int)target.posZ;
int y = (int)target.posY;
int z = (int)target.posZ;
// Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly.
// Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly.
// TODO: Remove this requirement?
if(world.canBlockSeeSky(new BlockPos(x, y, z))){
if(!world.isRemote){
EntityLightningBolt entitylightning = new EntityLightningBolt(world, x, y, z, false);
world.addWeatherEffect(entitylightning);
}
caster.swingArm(hand);
return true;
}
if(world.canBlockSeeSky(new BlockPos(x, y, z))){
if(!world.isRemote){
EntityLightningBolt entitylightning = new EntityLightningBolt(world, x, y, z, false);
world.addWeatherEffect(entitylightning);
}
caster.swingArm(hand);
return true;
}
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
@SubscribeEvent
public static void onEntityStruckByLightningEvent(EntityStruckByLightningEvent event){
if(event.getLightning().getEntityData() != null && event.getLightning().getEntityData().hasKey(NBT_KEY)){
EntityPlayer player = (EntityPlayer)WizardryUtilities.getEntityByUUID(event.getLightning().worldObj, event.getLightning().getEntityData().getUniqueId("summoningPlayer"));
EntityPlayer player = (EntityPlayer)WizardryUtilities.getEntityByUUID(event.getLightning().world,
event.getLightning().getEntityData().getUniqueId("summoningPlayer"));
if(event.getEntity() instanceof EntityCreeper){
player.addStat(WizardryAchievements.charge_creeper);
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
public class LightningDisc extends Spell {
public LightningDisc() {
public LightningDisc(){
super(Tier.ADVANCED, 25, Element.LIGHTNING, "lightning_disc", SpellType.ATTACK, 60, EnumAction.NONE, false);
}
@@ -26,37 +26,41 @@ public class LightningDisc extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(lightningdisc);
EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(lightningdisc);
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 0.8F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F,
world.rand.nextFloat() * 0.3F + 0.8F);
caster.swingArm(hand);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster, modifiers.get(SpellModifiers.DAMAGE));
EntityLightningDisc lightningdisc = new EntityLightningDisc(world, caster,
modifiers.get(SpellModifiers.DAMAGE));
lightningdisc.directTowards(target, 1.2f);
world.spawnEntityInWorld(lightningdisc);
world.spawnEntity(lightningdisc);
}
caster.playSound(WizardrySounds.SPELL_LIGHTNING, 1.0F, world.rand.nextFloat() * 0.3F + 0.8F);
caster.swingArm(hand);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class LightningHammer extends Spell {
public LightningHammer() {
public LightningHammer(){
super(Tier.MASTER, 100, Element.LIGHTNING, "lightning_hammer", SpellType.ATTACK, 300, EnumAction.BOW, false);
}
@@ -27,35 +27,37 @@ public class LightningHammer extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(40*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(40 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
// Not sure why it is +1 but it has to be to work properly.
if(world.canBlockSeeSky(pos.up())){
// Not sure why it is +1 but it has to be to work properly.
if(world.canBlockSeeSky(pos.up())){
if(!world.isRemote){
EntityHammer hammer = new EntityHammer(world, pos.getX()+0.5, pos.getY()+50, pos.getZ()+0.5, caster, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), modifiers.get(SpellModifiers.DAMAGE));
EntityHammer hammer = new EntityHammer(world, pos.getX() + 0.5, pos.getY() + 50, pos.getZ() + 0.5,
caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
hammer.motionX = 0;
hammer.motionY = -2;
hammer.motionZ = 0;
world.spawnEntityInWorld(hammer);
world.spawnEntity(hammer);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 3.0f, 1.0f);
return true;
}
}
}
return false;
}
}
@@ -23,7 +23,7 @@ import net.minecraft.world.World;
public class LightningPulse extends Spell {
public LightningPulse() {
public LightningPulse(){
super(Tier.ADVANCED, 25, Element.LIGHTNING, "lightning_pulse", SpellType.ATTACK, 75, EnumAction.NONE, false);
}
@@ -33,26 +33,28 @@ public class LightningPulse extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.onGround){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(3.0d*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
3.0d * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
for(EntityLivingBase target : targets){
if(WizardryUtilities.isValidTarget(caster, target)){
// Damage is 4 hearts no matter where the target is.
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 8 * modifiers.get(SpellModifiers.DAMAGE));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
8 * modifiers.get(SpellModifiers.DAMAGE));
if(!world.isRemote){
double dx = target.posX - caster.posX;
double dz = target.posZ - caster.posZ;
// Normalises the velocity.
double vectorLength = MathHelper.sqrt_double(dx*dx + dz*dz);
double vectorLength = MathHelper.sqrt(dx * dx + dz * dz);
dx /= vectorLength;
dz /= vectorLength;
target.motionX = 0.8 * dx;
target.motionY = 0;
target.motionZ = 0.8 * dz;
@@ -65,8 +67,10 @@ public class LightningPulse extends Spell {
}
}
if(!world.isRemote){
EntityLightningPulse lightningpulse = new EntityLightningPulse(world, caster.posX, caster.getEntityBoundingBox().minY, caster.posZ, caster, 7, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(lightningpulse);
EntityLightningPulse lightningpulse = new EntityLightningPulse(world, caster.posX,
caster.getEntityBoundingBox().minY, caster.posZ, caster, 7,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(lightningpulse);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0f, 1.0f);
@@ -76,5 +80,4 @@ public class LightningPulse extends Spell {
return false;
}
}
@@ -24,114 +24,131 @@ import net.minecraft.world.World;
public class LightningRay extends Spell {
public LightningRay() {
public LightningRay(){
super(Tier.APPRENTICE, 5, Element.LIGHTNING, "lightning_ray", SpellType.ATTACK, 0, EnumAction.NONE, true);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 2.0f);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade), 2.0f);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
Entity target = rayTrace.entityHit;
if(!world.isRemote){
// This statement means the arc only spawns every other tick.
if(ticksInUse % 2 == 0){
EntityArc arc = new EntityArc(world);
// The look vec stuff performs a translation on the start point to line it up with the wand.
// EDIT: removed due to 1st/3rd person render differences.
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ,
target.posX, target.posY + target.height/2, target.posZ);
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, target.posX,
target.posY + target.height / 2, target.posZ);
arc.lifetime = 1;
world.spawnEntityInWorld(arc);
world.spawnEntity(arc);
}
if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){
if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote && ticksInUse == 1)
caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()));
}else{
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
}
}else{
for(int i=0;i<5;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
}
for(int i = 0; i < 5; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
}
}
if(ticksInUse == 1){
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, 1.0f);
}else if(ticksInUse > 0 && ticksInUse % 20 == 0){
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f);
}
return true;
}else{
if(!world.isRemote){
// This statement means the arc only spawns every other tick.
if(ticksInUse % 2 == 0){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ,
caster.posX + caster.getLookVec().xCoord * 8, caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8, caster.posZ + caster.getLookVec().zCoord * 8);
caster.posX + caster.getLookVec().xCoord * 8,
caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8,
caster.posZ + caster.getLookVec().zCoord * 8);
arc.lifetime = 1;
world.spawnEntityInWorld(arc);
world.spawnEntity(arc);
}
}
if(ticksInUse == 1){
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LIGHTNING, 1.0F, 1.0f);
}else if(ticksInUse > 0 && ticksInUse % 20 == 0){
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f);
}
return true;
}
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
// This statement means the arc only spawns every other tick.
if(ticksInUse % 2 == 0){
EntityArc arc = new EntityArc(world);
// The look vec stuff performs a translation on the start point to line it up with the wand.
// EDIT: removed due to 1st/3rd person render differences.
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ,
target.posX, target.posY + target.height/2, target.posZ);
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, target.posX,
target.posY + target.height / 2, target.posZ);
arc.lifetime = 1;
world.spawnEntityInWorld(arc);
world.spawnEntity(arc);
}
WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
WizardryUtilities.attackEntityWithoutKnockback(target,
MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
}else{
for(int i=0;i<5;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
}
for(int i = 0; i < 5; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
}
}
if(ticksInUse == 1){
caster.playSound(WizardrySounds.SPELL_LIGHTNING, 1.0F, 1.0f);
}else if(ticksInUse > 0 && ticksInUse % 20 == 0){
caster.playSound(WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f);
}
return true;
}
return false;
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class LightningSigil extends Spell {
public LightningSigil() {
public LightningSigil(){
super(Tier.APPRENTICE, 10, Element.LIGHTNING, "lightning_sigil", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@@ -27,20 +27,22 @@ public class LightningSigil extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(10 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && rayTrace.sideHit == EnumFacing.UP){
if(!world.isRemote){
double x = rayTrace.hitVec.xCoord;
double y = rayTrace.hitVec.yCoord;
double z = rayTrace.hitVec.zCoord;
EntityLightningSigil lightningsigil = new EntityLightningSigil(world, x, y, z, caster, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(lightningsigil);
EntityLightningSigil lightningsigil = new EntityLightningSigil(world, x, y, z, caster,
modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(lightningsigil);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 0.3F);
return true;
@@ -48,5 +50,4 @@ public class LightningSigil extends Spell {
return false;
}
}
@@ -25,56 +25,65 @@ import net.minecraft.world.World;
public class LightningWeb extends Spell {
public LightningWeb() {
public LightningWeb(){
super(Tier.MASTER, 15, Element.LIGHTNING, "lightning_web", SpellType.ATTACK, 0, EnumAction.NONE, true);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade), 2.0f);
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade), 2.0f);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
Entity target = rayTrace.entityHit;
if(!world.isRemote){
// This statement means the arc only spawns every other tick.
if(ticksInUse % 2 == 0){
EntityArc arc = new EntityArc(world);
// The look vec stuff performs a translation on the start point to line it up with the wand.
// EDIT: removed due to 1st/3rd person render differences.
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ,
target.posX, target.posY + target.height/2, target.posZ);
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ, target.posX,
target.posY + target.height / 2, target.posZ);
arc.lifetime = 1;
world.spawnEntityInWorld(arc);
world.spawnEntity(arc);
}
if(MagicDamage.isEntityImmune(DamageType.SHOCK, target)){
if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote && ticksInUse == 1)
caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()));
}else{
// This motion stuff removes knockback, which is desirable for continuous spells.
double motionX = target.motionX;
double motionY = target.motionY;
double motionZ = target.motionZ;
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 5.0f * modifiers.get(SpellModifiers.DAMAGE));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
5.0f * modifiers.get(SpellModifiers.DAMAGE));
target.motionX = motionX;
target.motionY = motionY;
target.motionZ = motionZ;
}
}else{
for(int i=0;i<5;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, target.posX + world.rand.nextFloat() - 0.5, target.getEntityBoundingBox().minY + target.height/2 + world.rand.nextFloat()*2 - 1, target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
for(int i = 0; i < 5; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
target.posX + world.rand.nextFloat() - 0.5,
target.getEntityBoundingBox().minY + target.height / 2 + world.rand.nextFloat() * 2 - 1,
target.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
}
}
// Secondary chaining effect
double seekerRange = 5.0d;
List<EntityLivingBase> secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, target.posX, target.posY + target.height/2, target.posZ, world);
List<EntityLivingBase> secondaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange,
target.posX, target.posY + target.height / 2, target.posZ, world);
// This is a MUCH better way of filtering the secondary targets!
secondaryTargets.remove(target);
if(secondaryTargets.size() > 5) secondaryTargets = secondaryTargets.subList(0, 5);
@@ -87,35 +96,45 @@ public class LightningWeb extends Spell {
// This statement means the arc only spawns every other tick.
if(ticksInUse % 2 == 0){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(target.posX, target.posY + 1.2, target.posZ,
secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ);
arc.setEndpointCoords(target.posX, target.posY + 1.2, target.posZ, secondaryTarget.posX,
secondaryTarget.posY + secondaryTarget.height / 2, secondaryTarget.posZ);
arc.lifetime = 1;
world.spawnEntityInWorld(arc);
world.spawnEntity(arc);
}
if(MagicDamage.isEntityImmune(DamageType.SHOCK, secondaryTarget)){
if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", secondaryTarget.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote && ticksInUse == 1)
caster.sendMessage(new TextComponentTranslation("spell.resist",
secondaryTarget.getName(), this.getNameForTranslationFormatted()));
}else{
// This motion stuff removes knockback, which is desirable for continuous spells.
double motionX = secondaryTarget.motionX;
double motionY = secondaryTarget.motionY;
double motionZ = secondaryTarget.motionZ;
secondaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 4.0f * modifiers.get(SpellModifiers.DAMAGE));
secondaryTarget.attackEntityFrom(
MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
4.0f * modifiers.get(SpellModifiers.DAMAGE));
secondaryTarget.motionX = motionX;
secondaryTarget.motionY = motionY;
secondaryTarget.motionZ = motionZ;
}
}else{
for(int i=0;i<5;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, secondaryTarget.posX + world.rand.nextFloat() - 0.5, secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height/2 + world.rand.nextFloat()*2 - 1, secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
for(int i = 0; i < 5; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
secondaryTarget.posX + world.rand.nextFloat() - 0.5,
secondaryTarget.getEntityBoundingBox().minY + secondaryTarget.height / 2
+ world.rand.nextFloat() * 2 - 1,
secondaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
}
}
// Tertiary chaining effect
List<EntityLivingBase> tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height/2, secondaryTarget.posZ, world);
List<EntityLivingBase> tertiaryTargets = WizardryUtilities.getEntitiesWithinRadius(seekerRange,
secondaryTarget.posX, secondaryTarget.posY + secondaryTarget.height / 2,
secondaryTarget.posZ, world);
tertiaryTargets.remove(target);
tertiaryTargets.removeAll(secondaryTargets);
if(tertiaryTargets.size() > 2) tertiaryTargets = tertiaryTargets.subList(0, 2);
@@ -128,29 +147,38 @@ public class LightningWeb extends Spell {
// This statement means the arc only spawns every other tick.
if(ticksInUse % 2 == 0){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(secondaryTarget.posX, secondaryTarget.posY + 1.2, secondaryTarget.posZ,
tertiaryTarget.posX, tertiaryTarget.posY + tertiaryTarget.height/2, tertiaryTarget.posZ);
arc.setEndpointCoords(secondaryTarget.posX, secondaryTarget.posY + 1.2,
secondaryTarget.posZ, tertiaryTarget.posX,
tertiaryTarget.posY + tertiaryTarget.height / 2, tertiaryTarget.posZ);
arc.lifetime = 1;
world.spawnEntityInWorld(arc);
world.spawnEntity(arc);
}
if(MagicDamage.isEntityImmune(DamageType.SHOCK, tertiaryTarget)){
if(!world.isRemote && ticksInUse == 1) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", tertiaryTarget.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote && ticksInUse == 1)
caster.sendMessage(new TextComponentTranslation("spell.resist",
tertiaryTarget.getName(), this.getNameForTranslationFormatted()));
}else{
// This motion stuff removes knockback, which is desirable for continuous spells.
double motionX = tertiaryTarget.motionX;
double motionY = tertiaryTarget.motionY;
double motionZ = tertiaryTarget.motionZ;
tertiaryTarget.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK), 3.0f * modifiers.get(SpellModifiers.DAMAGE));
tertiaryTarget.attackEntityFrom(
MagicDamage.causeDirectMagicDamage(caster, DamageType.SHOCK),
3.0f * modifiers.get(SpellModifiers.DAMAGE));
tertiaryTarget.motionX = motionX;
tertiaryTarget.motionY = motionY;
tertiaryTarget.motionZ = motionZ;
}
}else{
for(int i=0;i<5;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world, tertiaryTarget.posX + world.rand.nextFloat() - 0.5, tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height/2 + world.rand.nextFloat()*2 - 1, tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
for(int i = 0; i < 5; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARK, world,
tertiaryTarget.posX + world.rand.nextFloat() - 0.5,
tertiaryTarget.getEntityBoundingBox().minY + tertiaryTarget.height / 2
+ world.rand.nextFloat() * 2 - 1,
tertiaryTarget.posZ + world.rand.nextFloat() - 0.5, 0, 0, 0, 3);
}
}
}
@@ -163,7 +191,7 @@ public class LightningWeb extends Spell {
}else if(ticksInUse > 0 && ticksInUse % 20 == 0){
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_LIGHTNING, 1.0F, 1.0f);
}
return true;
}else{
@@ -172,10 +200,12 @@ public class LightningWeb extends Spell {
if(ticksInUse % 2 == 0){
EntityArc arc = new EntityArc(world);
arc.setEndpointCoords(caster.posX, caster.posY + 1.2, caster.posZ,
caster.posX + caster.getLookVec().xCoord * 8, caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8, caster.posZ + caster.getLookVec().zCoord * 8);
caster.posX + caster.getLookVec().xCoord * 8,
caster.posY + caster.eyeHeight + caster.getLookVec().yCoord * 8,
caster.posZ + caster.getLookVec().zCoord * 8);
arc.lifetime = 1;
//arc.setOffset(entityplayer.getLookVec().zCoord * 0.5, entityplayer.getLookVec().xCoord * 0.5);
world.spawnEntityInWorld(arc);
// arc.setOffset(entityplayer.getLookVec().zCoord * 0.5, entityplayer.getLookVec().xCoord * 0.5);
world.spawnEntity(arc);
}
}
@@ -189,5 +219,4 @@ public class LightningWeb extends Spell {
}
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class MagicMissile extends Spell {
public MagicMissile() {
public MagicMissile(){
super(Tier.BASIC, 5, Element.MAGIC, "magic_missile", SpellType.ATTACK, 10, EnumAction.NONE, false);
}
@@ -27,41 +27,45 @@ public class MagicMissile extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster, 2*modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(magicMissile);
EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster,
2 * modifiers.get(WizardryItems.range_upgrade), modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(magicMissile);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_MAGIC, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_MAGIC, 1.0F,
world.rand.nextFloat() * 0.4F + 1.2F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster, target, 2*modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntityInWorld(magicMissile);
EntityMagicMissile magicMissile = new EntityMagicMissile(world, caster, target,
2 * modifiers.get(WizardryItems.range_upgrade), 4, modifiers.get(SpellModifiers.DAMAGE));
world.spawnEntity(magicMissile);
}
caster.swingArm(hand);
caster.playSound(WizardrySounds.SPELL_MAGIC, 1.0F, world.rand.nextFloat() * 0.4F + 1.2F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
}
@@ -18,7 +18,7 @@ import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.SkeletonType;
import net.minecraft.entity.monster.EntityWitherSkeleton;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
@@ -33,93 +33,84 @@ import net.minecraft.world.World;
public class Metamorphosis extends Spell {
public Metamorphosis() {
public Metamorphosis(){
super(Tier.APPRENTICE, 15, Element.NECROMANCY, "metamorphosis", SpellType.UTILITY, 30, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){
Entity entityHit = rayTrace.entityHit;
double xPos = entityHit.posX;
double yPos = entityHit.posY;
double zPos = entityHit.posZ;
EntityLiving newEntity = null;
boolean flag = false;
// IDEA: Interaction with husks/strays?
// TODO: Replace with a bimap or something.
if(entityHit instanceof EntityPig){
newEntity = new EntityPigZombie(world);
}
else if(entityHit instanceof EntityPigZombie){
}else if(entityHit instanceof EntityPigZombie){
newEntity = new EntityPig(world);
}
else if(entityHit instanceof EntitySkeleton){
// IDEA: Interaction with husks/strays?
if(((EntitySkeleton)entityHit).getSkeletonType() == SkeletonType.NORMAL){
((EntitySkeleton)entityHit).setSkeletonType(SkeletonType.WITHER);
}else{
((EntitySkeleton)entityHit).setSkeletonType(SkeletonType.NORMAL);
}
flag = true;
}
else if(entityHit instanceof EntityCow && !(entityHit instanceof EntityMooshroom)){
}else if(entityHit instanceof EntitySkeleton){
newEntity = new EntityWitherSkeleton(world);
}else if(entityHit instanceof EntityWitherSkeleton){
newEntity = new EntitySkeleton(world);
}else if(entityHit instanceof EntityCow && !(entityHit instanceof EntityMooshroom)){
newEntity = new EntityMooshroom(world);
}
else if(entityHit instanceof EntityMooshroom){
}else if(entityHit instanceof EntityMooshroom){
newEntity = new EntityCow(world);
}
else if(entityHit instanceof EntityChicken){
}else if(entityHit instanceof EntityChicken){
newEntity = new EntityBat(world);
}
else if(entityHit instanceof EntityBat){
}else if(entityHit instanceof EntityBat){
newEntity = new EntityChicken(world);
}
else if(entityHit instanceof EntitySlime && !(entityHit instanceof EntityMagmaCube)){
}else if(entityHit instanceof EntitySlime && !(entityHit instanceof EntityMagmaCube)){
newEntity = new EntityMagmaCube(world);
}
else if(entityHit instanceof EntityMagmaCube){
}else if(entityHit instanceof EntityMagmaCube){
newEntity = new EntitySlime(world);
}
else if(entityHit instanceof EntitySpider && !(entityHit instanceof EntityCaveSpider)){
}else if(entityHit instanceof EntitySpider && !(entityHit instanceof EntityCaveSpider)){
newEntity = new EntityCaveSpider(world);
}
else if(entityHit instanceof EntityCaveSpider){
}else if(entityHit instanceof EntityCaveSpider){
newEntity = new EntitySpider(world);
}
if(newEntity != null || flag){
if(newEntity != null){
if(!world.isRemote && newEntity != null){
//Transfers attributes from the old entity to the new one.
newEntity.setHealth(((EntityLiving)entityHit).getHealth());
//newEntity.writeToNBT(entityHit.getEntityData());
entityHit.setDead();
newEntity.setPosition(xPos, yPos, zPos);
world.spawnEntityInWorld(newEntity);
// Transfers attributes from the old entity to the new one.
newEntity.setHealth(((EntityLiving)entityHit).getHealth());
// newEntity.writeToNBT(entityHit.getEntityData());
entityHit.setDead();
newEntity.setPosition(xPos, yPos, zPos);
world.spawnEntity(newEntity);
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
//world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.2f, 0.0f, 0.1f);
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
// world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), 0.2f, 0.0f, 0.1f);
}
for(int i = 0; i < 5; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, xPos, yPos, zPos, 0.0d,
0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f);
}
for(int i=0;i<5;i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, xPos, yPos, zPos, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.0f, 0.0f);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_DEFLECTION, 0.5F, 0.8f);
return true;
@@ -128,5 +119,4 @@ public class Metamorphosis extends Spell {
return false;
}
}
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class Meteor extends Spell {
public Meteor() {
public Meteor(){
super(Tier.MASTER, 100, Element.FIRE, "meteor", SpellType.ATTACK, 200, EnumAction.NONE, false);
}
@@ -27,29 +27,30 @@ public class Meteor extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
RayTraceResult rayTrace = WizardryUtilities.rayTrace(40*modifiers.get(WizardryItems.range_upgrade), world, caster, false);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(40 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
// Not sure why it is +1 but it has to be to work properly.
if(world.canBlockSeeSky(pos.up())){
// Not sure why it is +1 but it has to be to work properly.
if(world.canBlockSeeSky(pos.up())){
if(!world.isRemote){
EntityMeteor meteor = new EntityMeteor(world, pos.getX(), pos.getY() + 50, pos.getZ(), modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntityInWorld(meteor);
EntityMeteor meteor = new EntityMeteor(world, pos.getX(), pos.getY() + 50, pos.getZ(),
modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntity(meteor);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 3.0f, 1.0f);
return true;
}
}
}
return false;
}
}
@@ -26,26 +26,29 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class MindControl extends Spell {
/** The NBT tag name for storing the controlling entity's UUID in the target's tag compound. Defined here in case
* it changes. */
/**
* The NBT tag name for storing the controlling entity's UUID in the target's tag compound. Defined here in case it
* changes.
*/
public static final String NBT_KEY = "controllingEntity";
public MindControl() {
public MindControl(){
super(Tier.ADVANCED, 40, Element.NECROMANCY, "mind_control", SpellType.ATTACK, 150, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
8 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){
@@ -54,7 +57,8 @@ public class MindControl extends Spell {
if(!world.isRemote){
if(!canControl(target)){
// Adds a message saying that the player/boss entity/wizard resisted mind control
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist",
target.getName(), this.getNameForTranslationFormatted()));
}else if(target instanceof EntityLiving){
@@ -66,18 +70,21 @@ public class MindControl extends Spell {
NBTTagCompound entityNBT = target.getEntityData();
if(entityNBT != null) entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID());
((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0));
((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
}else{
for(int i=0; i<10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
0, 0, 0, 0, 0.2f, 0.04f, 0.25f);
for(int i = 0; i < 10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
+ world.rand.nextDouble() * 0.5,
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
+ world.rand.nextDouble() * 0.5,
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.2f, 0.04f, 0.25f);
}
}
target.playSound(WizardrySounds.SPELL_SUMMONING, 1.0f, 1.0f);
@@ -88,7 +95,8 @@ public class MindControl extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
@@ -102,18 +110,21 @@ public class MindControl extends Spell {
NBTTagCompound entityNBT = target.getEntityData();
if(entityNBT != null) entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID());
((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 0));
((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
}else{
for(int i=0; i<10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
0, 0, 0, 0, 0.2f, 0.04f, 0.25f);
for(int i = 0; i < 10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
+ world.rand.nextDouble() * 0.5,
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
+ world.rand.nextDouble() * 0.5,
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.2f, 0.04f, 0.25f);
}
}
target.playSound(WizardrySounds.SPELL_SUMMONING, 1.0f, 1.0f);
@@ -135,9 +146,10 @@ public class MindControl extends Spell {
}
/**
* Finds the nearest creature to the given target which it is allowed to attack according to the given caster
* and sets it as the target's attack target. Handles both new and old AI and takes follow range into account.
* Defined here so it can be used both in the spell itself and in the potion effect (event handler).
* Finds the nearest creature to the given target which it is allowed to attack according to the given caster and
* sets it as the target's attack target. Handles both new and old AI and takes follow range into account. Defined
* here so it can be used both in the spell itself and in the potion effect (event handler).
*
* @param target The entity being mind controlled
* @param caster The entity doing the controlling
* @param world The world to look for targets in
@@ -179,7 +191,8 @@ public class MindControl extends Spell {
public static void onLivingUpdateEvent(LivingUpdateEvent event){
// This was added because something got changed in the AI classes which means LivingSetAttackTargetEvent doesn't
// get fired when I want it to... so I'm firing it myself.
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) && event.getEntityLiving() instanceof EntityLiving
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control)
&& event.getEntityLiving() instanceof EntityLiving
&& ((EntityLiving)event.getEntityLiving()).getAttackTarget() != null
&& !((EntityLiving)event.getEntityLiving()).getAttackTarget().isEntityAlive())
((EntityLiving)event.getEntityLiving()).setAttackTarget(null); // Causes the event to be fired
@@ -188,20 +201,23 @@ public class MindControl extends Spell {
@SubscribeEvent
public static void onLivingSetAttackTargetEvent(LivingSetAttackTargetEvent event){
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control) && MindControl.canControl(event.getEntityLiving())){
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_control)
&& MindControl.canControl(event.getEntityLiving())){
NBTTagCompound entityNBT = event.getEntityLiving().getEntityData();
if(entityNBT != null && entityNBT.hasKey(MindControl.NBT_KEY + "Most")){
Entity caster = WizardryUtilities.getEntityByUUID(event.getEntity().worldObj, entityNBT.getUniqueId(MindControl.NBT_KEY));
Entity caster = WizardryUtilities.getEntityByUUID(event.getEntity().world,
entityNBT.getUniqueId(MindControl.NBT_KEY));
// If the target that the event tried to set is already a valid mind control target, nothing happens.
if(event.getTarget() != null && WizardryUtilities.isValidTarget(caster, event.getTarget())) return;
if(caster instanceof EntityLivingBase){
if(MindControl.findMindControlTarget((EntityLiving)event.getEntityLiving(), (EntityLivingBase)caster, event.getEntity().worldObj)){
if(MindControl.findMindControlTarget((EntityLiving)event.getEntityLiving(),
(EntityLivingBase)caster, event.getEntity().world)){
// If it worked, skip setting the target to null.
return;
}
@@ -27,14 +27,15 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class MindTrick extends Spell {
public MindTrick() {
public MindTrick(){
super(Tier.BASIC, 10, Element.NECROMANCY, "mind_trick", SpellType.ATTACK, 40, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
8 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){
@@ -44,19 +45,22 @@ public class MindTrick extends Spell {
if(target instanceof EntityPlayer){
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA,
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}else if(target instanceof EntityLiving){
((EntityLiving)target).setAttackTarget(null);
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick,
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
}else{
for(int i=0; i<10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
for(int i = 0; i < 10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
+ world.rand.nextDouble() * 0.5,
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
}
}
@@ -68,26 +72,30 @@ public class MindTrick extends Spell {
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
if(target instanceof EntityPlayer){
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA,
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}else if(target instanceof EntityLiving){
((EntityLiving)target).setAttackTarget(null);
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick,
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
}else{
for(int i=0; i<10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
for(int i = 0; i < 10; i++){
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
+ world.rand.nextDouble() * 0.5,
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
}
}
@@ -99,7 +107,7 @@ public class MindTrick extends Spell {
}
@Override
public boolean canBeCastByNPCs() {
public boolean canBeCastByNPCs(){
return true;
}
@@ -107,7 +115,8 @@ public class MindTrick extends Spell {
public static void onLivingAttackEvent(LivingAttackEvent event){
if(event.getSource() != null && event.getSource().getEntity() instanceof EntityLivingBase){
// Cancels the mind trick effect if the creature takes damage
// This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it doesn't
// This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it
// doesn't
// crash the game with a ConcurrentModificationException. If you think about it, mind trick only ought to be
// cancelled if something attacks the entity since potions, drowning, cacti etc. don't affect the targeting.
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)){
@@ -120,7 +129,9 @@ public class MindTrick extends Spell {
public static void onLivingSetAttackTargetEvent(LivingSetAttackTargetEvent event){
// Mind trick
// If the target is null already, no need to set it to null, or infinite loops will occur.
if((event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick) || event.getEntityLiving().isPotionActive(WizardryPotions.fear)) && event.getEntityLiving() instanceof EntityLiving && event.getTarget() != null){
if((event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)
|| event.getEntityLiving().isPotionActive(WizardryPotions.fear))
&& event.getEntityLiving() instanceof EntityLiving && event.getTarget() != null){
((EntityLiving)event.getEntityLiving()).setAttackTarget(null);
}
}
@@ -9,12 +9,14 @@ import net.minecraft.item.EnumAction;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
/** This class represents a blank spell used to fill empty slots on wands. It is unobtainable in-game, except via
/**
* This class represents a blank spell used to fill empty slots on wands. It is unobtainable in-game, except via
* commands, and does nothing when the player attempts to cast it. Its instance can be referenced directly using
* {@link electroblob.wizardry.registry.Spells#none WizardryRegistry.none}*/
* {@link electroblob.wizardry.registry.Spells#none WizardryRegistry.none}
*/
public class None extends Spell {
public None() {
public None(){
super(Tier.BASIC, 0, Element.MAGIC, "none", SpellType.UTILITY, 0, EnumAction.NONE, false);
}
@@ -24,9 +26,8 @@ public class None extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
return false;
}
}
@@ -20,41 +20,47 @@ import net.minecraft.world.World;
public class Oakflesh extends Spell {
public Oakflesh() {
public Oakflesh(){
super(Tier.APPRENTICE, 20, Element.HEALING, "oakflesh", SpellType.DEFENCE, 50, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(!caster.isPotionActive(MobEffects.RESISTANCE)){
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, (int)(600*modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
caster.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE,
(int)(600 * modifiers.get(WizardryItems.duration_upgrade)), 1, false, false));
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)caster.posY + caster.getEyeHeight() - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 0.6f, 0.5f, 0.4f);
}
}
@@ -21,49 +21,56 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class Petrify extends Spell {
private static final int baseDuration = 900;
/** The NBT tag name for storing the petrified flag in the target's tag compound. Defined here in case it changes. */
/**
* The NBT tag name for storing the petrified flag in the target's tag compound. Defined here in case it changes.
*/
public static final String NBT_KEY = "petrified";
public Petrify() {
public Petrify(){
super(Tier.ADVANCED, 40, Element.SORCERY, "petrify", SpellType.ATTACK, 100, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLiving && !world.isRemote){
EntityLiving target = (EntityLiving)rayTrace.entityHit;
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLiving && !world.isRemote){
EntityLiving target = (EntityLiving) rayTrace.entityHit;
if(target.deathTime > 0) return false;
BlockPos pos = new BlockPos(target);
target.extinguish();
//Short mobs such as spiders and pigs
// Short mobs such as spiders and pigs
if((target.height < 1.2 || target.isChild()) && WizardryUtilities.canBlockBeReplaced(world, pos)){
world.setBlockState(pos, WizardryBlocks.petrified_stone.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 1);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
target.getEntityData().setBoolean(NBT_KEY, true);
target.setDead();
}
//Normal sized mobs like zombies and skeletons
else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up())){
// Normal sized mobs like zombies and skeletons
else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos)
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())){
world.setBlockState(pos, WizardryBlocks.petrified_stone.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 2);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
world.setBlockState(pos.up(), WizardryBlocks.petrified_stone.getDefaultState());
@@ -73,12 +80,15 @@ public class Petrify extends Spell {
target.getEntityData().setBoolean(NBT_KEY, true);
target.setDead();
}
//Tall mobs like endermen
else if(WizardryUtilities.canBlockBeReplaced(world, pos) && WizardryUtilities.canBlockBeReplaced(world, pos.up()) && WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){
// Tall mobs like endermen
else if(WizardryUtilities.canBlockBeReplaced(world, pos)
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())
&& WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){
world.setBlockState(pos, WizardryBlocks.petrified_stone.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityStatue){
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart(target, 1, 3);
((TileEntityStatue)world.getTileEntity(pos)).setLifetime((int)(baseDuration*modifiers.get(WizardryItems.duration_upgrade)));
((TileEntityStatue)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
world.setBlockState(pos.up(), WizardryBlocks.petrified_stone.getDefaultState());
@@ -95,20 +105,23 @@ public class Petrify extends Spell {
}
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
//world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.1f, 0.1f, 0.1f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.2f, 0.2f, 0.2f);
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
// world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0,
0.1f, 0.1f, 0.1f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), 0.2f, 0.2f, 0.2f);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SPAWN, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
}
@@ -19,62 +19,69 @@ import net.minecraft.world.World;
public class PhaseStep extends Spell {
public PhaseStep() {
public PhaseStep(){
super(Tier.ADVANCED, 35, Element.SORCERY, "phase_step", SpellType.UTILITY, 40, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Phase step does not gain range from range multiplier, instead it increases the thickness
// of the wall you can teleport through.
RayTraceResult rayTrace = WizardryUtilities.rayTrace(5, world, caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = new BlockPos(rayTrace.getBlockPos().getX(), (int)caster.posY, rayTrace.getBlockPos().getZ());
// The maximum wall thickness as determined by the range multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
int maxThickness = 1 + (int)((modifiers.get(WizardryItems.range_upgrade) - 1)/Constants.RANGE_INCREASE_PER_LEVEL + 0.5f);
int maxThickness = 1
+ (int)((modifiers.get(WizardryItems.range_upgrade) - 1) / Constants.RANGE_INCREASE_PER_LEVEL
+ 0.5f);
if(rayTrace.sideHit.getAxis().isHorizontal()){
// i represents how far the player needs to teleport to get through the wall
for(int i = 0; i <= maxThickness; i++){
BlockPos pos1 = pos.offset(rayTrace.sideHit.getOpposite(), i);
// Prevents the player from teleporting through unbreakable blocks, so they cannot cheat in other mods' mazes and dungeons.
if((WizardryUtilities.isBlockUnbreakable(world, pos1) || WizardryUtilities.isBlockUnbreakable(world, pos1.up())) && !Wizardry.settings.teleportThroughUnbreakableBlocks) return false;
if(!world.getBlockState(pos1).getMaterial().blocksMovement() && !world.getBlockState(pos1.up()).getMaterial().blocksMovement()){
BlockPos pos1 = pos.offset(rayTrace.sideHit.getOpposite(), i);
// Prevents the player from teleporting through unbreakable blocks, so they cannot cheat in other
// mods' mazes and dungeons.
if((WizardryUtilities.isBlockUnbreakable(world, pos1)
|| WizardryUtilities.isBlockUnbreakable(world, pos1.up()))
&& !Wizardry.settings.teleportThroughUnbreakableBlocks)
return false;
if(!world.getBlockState(pos1).getMaterial().blocksMovement()
&& !world.getBlockState(pos1.up()).getMaterial().blocksMovement()){
if(!world.isRemote){
caster.setPositionAndUpdate(pos1.getX() + 0.5, caster.posY, pos1.getZ() + 0.5);
}
caster.swingArm(hand);
return true;
}
}
}
}
// This is here because the conditions are false on the client for whatever reason. (see the Javadoc for cast()
// for an explanation)
if(world.isRemote){
for(int i=0;i<10;i++){
for(int i = 0; i < 10; i++){
double dx1 = caster.posX;
double dy1 = WizardryUtilities.getPlayerEyesPos(caster) - 1.5 + 2*world.rand.nextFloat();
double dy1 = WizardryUtilities.getPlayerEyesPos(caster) - 1.5 + 2 * world.rand.nextFloat();
double dz1 = caster.posZ;
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
world.spawnParticle(EnumParticleTypes.PORTAL, dx1, dy1, dz1, world.rand.nextDouble() - 0.5,
world.rand.nextDouble() - 0.5, world.rand.nextDouble() - 0.5);
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0f);
}
return false;
}
}
@@ -26,47 +26,53 @@ import net.minecraft.world.World;
public class PlagueOfDarkness extends Spell {
public PlagueOfDarkness() {
public PlagueOfDarkness(){
super(Tier.MASTER, 75, Element.NECROMANCY, "plague_of_darkness", SpellType.ATTACK, 200, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(5.0d*modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
5.0d * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
for(EntityLivingBase target : targets){
if(WizardryUtilities.isValidTarget(caster, target) && !MagicDamage.isEntityImmune(DamageType.WITHER, target)){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER), 8.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, (int)(140*modifiers.get(WizardryItems.duration_upgrade)), 2));
if(WizardryUtilities.isValidTarget(caster, target)
&& !MagicDamage.isEntityImmune(DamageType.WITHER, target)){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.WITHER),
8.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.WITHER,
(int)(140 * modifiers.get(WizardryItems.duration_upgrade)), 2));
}
}
if(world.isRemote){
double particleX, particleZ;
for(int i=0;i<40*modifiers.get(WizardryItems.blast_upgrade);i++){
particleX = caster.posX - 1.0d + 2*world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble();
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, particleX, WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ,
particleX - caster.posX, 0, particleZ - caster.posZ, 0, 0.1f, 0.0f, 0.0f);
particleX = caster.posX - 1.0d + 2*world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble();
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX, WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ,
particleX - caster.posX, 0, particleZ - caster.posZ, 30, 0.1f, 0.0f, 0.05f);
particleX = caster.posX - 1.0d + 2*world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2*world.rand.nextDouble();
for(int i = 0; i < 40 * modifiers.get(WizardryItems.blast_upgrade); i++){
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, particleX,
WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, particleX - caster.posX, 0,
particleZ - caster.posZ, 0, 0.1f, 0.0f, 0.0f);
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, particleX,
WizardryUtilities.getPlayerEyesPos(caster) - 1.5, particleZ, particleX - caster.posX, 0,
particleZ - caster.posZ, 30, 0.1f, 0.0f, 0.05f);
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster);
if(block != null){
world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY, particleZ,
particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block));
world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY,
particleZ, particleX - caster.posX, 0, particleZ - caster.posZ, Block.getStateId(block));
}
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_DEATH, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_DEATH, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
}
@@ -16,57 +16,57 @@ import net.minecraft.world.World;
public class PocketFurnace extends Spell {
public PocketFurnace() {
public PocketFurnace(){
super(Tier.APPRENTICE, 30, Element.FIRE, "pocket_furnace", SpellType.UTILITY, 40, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
int usesLeft = 5;
ItemStack stack, result;
for(int i=0; i<caster.inventory.getSizeInventory() && usesLeft > 0; i++){
for(int i = 0; i < caster.inventory.getSizeInventory() && usesLeft > 0; i++){
stack = caster.inventory.getStackInSlot(i);
if(stack != null){
if(!stack.isEmpty()){
result = FurnaceRecipes.instance().getSmeltingResult(stack);
if(result != null){
if(stack.stackSize <= usesLeft){
ItemStack stack2 = new ItemStack(result.getItem(), stack.stackSize, result.getItemDamage());
if(stack.getCount() <= usesLeft){
ItemStack stack2 = new ItemStack(result.getItem(), stack.getCount(), result.getItemDamage());
if(WizardryUtilities.doesPlayerHaveItem(caster, result.getItem())){
caster.inventory.addItemStackToInventory(stack2);
caster.inventory.setInventorySlotContents(i, null);
}else{
caster.inventory.setInventorySlotContents(i, stack2);
}
usesLeft -= stack.stackSize;
usesLeft -= stack.getCount();
}else{
caster.inventory.decrStackSize(i, usesLeft);
caster.inventory.addItemStackToInventory(new ItemStack(result.getItem(), usesLeft, result.getItemDamage()));
caster.inventory.addItemStackToInventory(
new ItemStack(result.getItem(), usesLeft, result.getItemDamage()));
usesLeft = 0;
}
}
}
}
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, 1, 0.75f);
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
world.spawnParticle(EnumParticleTypes.FLAME, x1, y1, z1, 0, 0.01F, 0);
}
}
return usesLeft < 5;
}
}
@@ -15,7 +15,7 @@ import net.minecraft.world.World;
public class PocketWorkbench extends Spell {
public PocketWorkbench() {
public PocketWorkbench(){
super(Tier.APPRENTICE, 30, Element.SORCERY, "pocket_workbench", SpellType.UTILITY, 40, EnumAction.BOW, false);
}
@@ -25,11 +25,12 @@ public class PocketWorkbench extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// TODO: Investigate possible item duplication bug with this spell. So far I have been unable to recreate it.
if(!world.isRemote){
caster.openGui(Wizardry.instance, WizardryGuiHandler.PORTABLE_CRAFTING, world, (int)caster.posX, (int)caster.posY, (int)caster.posZ);
caster.openGui(Wizardry.instance, WizardryGuiHandler.PORTABLE_CRAFTING, world, (int)caster.posX,
(int)caster.posY, (int)caster.posZ);
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1, 1);
@@ -25,70 +25,85 @@ import net.minecraft.world.World;
public class Poison extends Spell {
public Poison() {
public Poison(){
super(Tier.APPRENTICE, 10, Element.EARTH, "poison", SpellType.ATTACK, 20, EnumAction.NONE, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 10*modifiers.get(WizardryItems.range_upgrade));
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
10 * modifiers.get(WizardryItems.range_upgrade));
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY && rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase) rayTrace.entityHit;
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.ENTITY
&& rayTrace.entityHit instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)rayTrace.entityHit;
// Has no effect on undead or spiders.
if(MagicDamage.isEntityImmune(DamageType.POISON, target)){
if(!world.isRemote) caster.addChatComponentMessage(new TextComponentTranslation("spell.resist", target.getName(), this.getNameForTranslationFormatted()));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()));
}else{
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), 1.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.POISON, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON),
1.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.POISON,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1));
}
}
if(world.isRemote){
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
double x1 = caster.posX + look.xCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + look.zCoord*i/2 + world.rand.nextFloat()/5 - 0.1f;
//world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.3f, 0.7f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f);
double x1 = caster.posX + look.xCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = WizardryUtilities.getPlayerEyesPos(caster) - 0.4f + look.yCoord * i / 2
+ world.rand.nextFloat() / 5 - 0.1f;
double z1 = caster.posZ + look.zCoord * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
// world.spawnParticle("mobSpell", x1, y1, z1, -1*look.xCoord, -1*look.yCoord, -1*look.zCoord);
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0,
0.3f, 0.7f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f);
}
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
// Has no effect on undead or spiders.
if(!MagicDamage.isEntityImmune(DamageType.POISON, target) && !world.isRemote){
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON), 1.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.POISON, (int)(200*modifiers.get(WizardryItems.duration_upgrade)), 1));
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.POISON),
1.0f * modifiers.get(SpellModifiers.DAMAGE));
target.addPotionEffect(new PotionEffect(MobEffects.POISON,
(int)(200 * modifiers.get(WizardryItems.duration_upgrade)), 1));
}
if(world.isRemote){
double dx = (target.posX - caster.posX)/caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY)/caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ)/caster.getDistanceToEntity(target);
for(int i=1; i<(int)(25*modifiers.get(WizardryItems.range_upgrade)); i+=2){
double x1 = caster.posX + dx*i/2 + world.rand.nextFloat()/5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy*i/2 + world.rand.nextFloat()/5 - 0.1f;
double z1 = caster.posZ + dz*i/2 + world.rand.nextFloat()/5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 0, 0.3f, 0.7f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d, 12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f);
if(world.isRemote){
double dx = (target.posX - caster.posX) / caster.getDistanceToEntity(target);
double dy = (target.posY - caster.posY) / caster.getDistanceToEntity(target);
double dz = (target.posZ - caster.posZ) / caster.getDistanceToEntity(target);
for(int i = 1; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
double x1 = caster.posX + dx * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
double y1 = caster.posY + caster.getEyeHeight() - 0.4f + dy * i / 2 + world.rand.nextFloat() / 5
- 0.1f;
double z1 = caster.posZ + dz * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
0, 0.3f, 0.7f, 0.0f);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0.0d, 0.0d, 0.0d,
12 + world.rand.nextInt(8), 0.1f, 0.4f, 0.0f);
}
}
@@ -96,10 +111,10 @@ public class Poison extends Spell {
caster.playSound(WizardrySounds.SPELL_ICE, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -17,7 +17,7 @@ import net.minecraft.world.World;
public class PoisonBomb extends Spell {
public PoisonBomb() {
public PoisonBomb(){
super(Tier.APPRENTICE, 15, Element.EARTH, "poison_bomb", SpellType.ATTACK, 25, EnumAction.NONE, false);
}
@@ -27,37 +27,41 @@ public class PoisonBomb extends Spell {
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(!world.isRemote){
EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntityInWorld(poisonbomb);
EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
world.spawnEntity(poisonbomb);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
if(!world.isRemote){
EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE), modifiers.get(WizardryItems.blast_upgrade));
EntityPoisonBomb poisonbomb = new EntityPoisonBomb(world, caster, modifiers.get(SpellModifiers.DAMAGE),
modifiers.get(WizardryItems.blast_upgrade));
poisonbomb.directTowards(target, 1.5f);
world.spawnEntityInWorld(poisonbomb);
world.spawnEntity(poisonbomb);
}
caster.swingArm(hand);
caster.playSound(SoundEvents.ENTITY_SNOWBALL_THROW, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@@ -15,30 +15,32 @@ import net.minecraft.world.World;
public class ReplenishHunger extends Spell {
public ReplenishHunger() {
public ReplenishHunger(){
super(Tier.APPRENTICE, 10, Element.HEALING, "replenish_hunger", SpellType.UTILITY, 30, EnumAction.BOW, false);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.getFoodStats().needFood()){
int foodAmount = (int)(6*modifiers.get(SpellModifiers.DAMAGE));
int foodAmount = (int)(6 * modifiers.get(SpellModifiers.DAMAGE));
// Fixed issue #6: Changed to addStats, since setFoodLevel is client-side only
caster.getFoodStats().addStats(foodAmount, foodAmount*0.1f);
caster.getFoodStats().addStats(foodAmount, foodAmount * 0.1f);
if(world.isRemote){
for(int i=0; i<10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat()*2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F + world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat()*2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0, 48 + world.rand.nextInt(12), 1.0f, 0.7f, 0.3f);
for(int i = 0; i < 10; i++){
double x1 = (double)((float)caster.posX + world.rand.nextFloat() * 2 - 1.0F);
double y1 = (double)((float)WizardryUtilities.getPlayerEyesPos(caster) - 0.5F
+ world.rand.nextFloat());
double z1 = (double)((float)caster.posZ + world.rand.nextFloat() * 2 - 1.0F);
Wizardry.proxy.spawnParticle(WizardryParticleType.SPARKLE, world, x1, y1, z1, 0, 0.1F, 0,
48 + world.rand.nextInt(12), 1.0f, 0.7f, 0.3f);
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F, world.rand.nextFloat() * 0.4F + 1.0F);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_HEAL, 0.7F,
world.rand.nextFloat() * 0.4F + 1.0F);
return true;
}
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More