That's one heck of a commit you've got there...
I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package electroblob.wizardry.entity.construct;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electroblob.wizardry.registry.Spells;
|
||||
import electroblob.wizardry.spell.Earthquake;
|
||||
import electroblob.wizardry.util.MagicDamage;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
@@ -13,8 +13,11 @@ import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.network.play.server.SPacketEntityVelocity;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityEarthquake extends EntityMagicConstruct {
|
||||
|
||||
public EntityEarthquake(World world){
|
||||
@@ -27,21 +30,20 @@ public class EntityEarthquake extends EntityMagicConstruct {
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
double speed = Spells.earthquake.getProperty(Earthquake.SPREAD_SPEED).doubleValue();
|
||||
|
||||
if(!world.isRemote){
|
||||
|
||||
double speed = 0.4;
|
||||
|
||||
// The further the earthquake is going to spread, the finer the angle increments.
|
||||
for(double angle = 0; angle < 2 * Math.PI; angle += Math.PI / (lifetime * 1.5)){
|
||||
for(float angle = 0; angle < 2 * Math.PI; angle += Math.PI / (lifetime * 1.5)){
|
||||
|
||||
// Calculates coordinates for the block to be moved. The radius increases with time. The +1.5 is to
|
||||
// leave
|
||||
// blocks in the centre untouched.
|
||||
int x = this.posX < 0 ? (int)(this.posX + ((this.ticksExisted * speed) + 1.5) * Math.sin(angle) - 1)
|
||||
: (int)(this.posX + ((this.ticksExisted * speed) + 1.5) * Math.sin(angle));
|
||||
// leave blocks in the centre untouched.
|
||||
int x = this.posX < 0 ? (int)(this.posX + ((this.ticksExisted * speed) + 1.5) * MathHelper.sin(angle) - 1)
|
||||
: (int)(this.posX + ((this.ticksExisted * speed) + 1.5) * MathHelper.sin(angle));
|
||||
int y = (int)(this.posY - 0.5);
|
||||
int z = this.posZ < 0 ? (int)(this.posZ + ((this.ticksExisted * speed) + 1.5) * Math.cos(angle) - 1)
|
||||
: (int)(this.posZ + ((this.ticksExisted * speed) + 1.5) * Math.cos(angle));
|
||||
int z = this.posZ < 0 ? (int)(this.posZ + ((this.ticksExisted * speed) + 1.5) * MathHelper.cos(angle) - 1)
|
||||
: (int)(this.posZ + ((this.ticksExisted * speed) + 1.5) * MathHelper.cos(angle));
|
||||
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
@@ -58,50 +60,53 @@ public class EntityEarthquake extends EntityMagicConstruct {
|
||||
}
|
||||
}
|
||||
|
||||
List<EntityLivingBase> targets = WizardryUtilities
|
||||
.getEntitiesWithinRadius((this.ticksExisted * speed) + 1.5, this.posX, this.posY, this.posZ, world);
|
||||
}
|
||||
|
||||
// In this particular instance, the caster is completely unaffected because they will always be in the
|
||||
// centre.
|
||||
targets.remove(this.getCaster());
|
||||
List<EntityLivingBase> targets = WizardryUtilities
|
||||
.getEntitiesWithinRadius((this.ticksExisted * speed) + 1.5, this.posX, this.posY, this.posZ, world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
// In this particular instance, the caster is completely unaffected because they will always be in the
|
||||
// centre.
|
||||
targets.remove(this.getCaster());
|
||||
|
||||
// Searches in a 1 wide ring.
|
||||
if(this.getDistance(target) > (this.ticksExisted * speed) + 0.5 && target.posY < this.posY + 1
|
||||
&& target.posY > this.posY - 1){
|
||||
for(EntityLivingBase target : targets){
|
||||
|
||||
// Knockback must be removed in this instance, or the target will fall into the floor.
|
||||
double motionX = target.motionX;
|
||||
double motionZ = target.motionZ;
|
||||
// Searches in a 1 wide ring.
|
||||
if(this.getDistance(target) > (this.ticksExisted * speed) + 0.5 && target.posY < this.posY + 1
|
||||
&& target.posY > this.posY - 1){
|
||||
|
||||
if(this.isValidTarget(target)){
|
||||
target.attackEntityFrom(
|
||||
MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.BLAST),
|
||||
10 * this.damageMultiplier);
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 400, 1));
|
||||
}
|
||||
// Knockback must be removed in this instance, or the target will fall into the floor.
|
||||
double motionX = target.motionX;
|
||||
double motionZ = target.motionZ;
|
||||
|
||||
// All targets are thrown, even those immune to the damage, so they don't fall into the ground.
|
||||
target.motionX = motionX;
|
||||
target.motionY = 0.8; // Throws target into the air.
|
||||
target.motionZ = motionZ;
|
||||
if(this.isValidTarget(target)){
|
||||
target.attackEntityFrom(
|
||||
MagicDamage.causeIndirectMagicDamage(this, this.getCaster(), DamageType.BLAST),
|
||||
10 * this.damageMultiplier);
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 400, 1));
|
||||
}
|
||||
|
||||
// Player motion is handled on that player's client so needs packets
|
||||
if(target instanceof EntityPlayerMP){
|
||||
((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target));
|
||||
}
|
||||
// All targets are thrown, even those immune to the damage, so they don't fall into the ground.
|
||||
target.motionX = motionX;
|
||||
target.motionY = 0.8; // Throws target into the air.
|
||||
target.motionZ = motionZ;
|
||||
|
||||
// Player motion is handled on that player's client so needs packets
|
||||
if(target instanceof EntityPlayerMP){
|
||||
((EntityPlayerMP)target).connection.sendPacket(new SPacketEntityVelocity(target));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// Constant 15 blocks for now
|
||||
List<EntityPlayer> targets = WizardryUtilities.getEntitiesWithinRadius(15, posX, posY, posZ, world, EntityPlayer.class);
|
||||
}
|
||||
|
||||
float magnitude = 6f * ((float)(this.lifetime - this.ticksExisted))/(float)this.lifetime;
|
||||
if(!world.isRemote){
|
||||
// Constant 15 blocks for now
|
||||
List<EntityPlayer> targets2 = WizardryUtilities.getEntitiesWithinRadius(15, posX, posY, posZ, world, EntityPlayer.class);
|
||||
|
||||
float magnitude = 10f * ((float)(this.lifetime - this.ticksExisted))/(float)this.lifetime;
|
||||
|
||||
// Makes the screen shake
|
||||
for(EntityPlayer target : targets){
|
||||
target.rotationPitch = this.ticksExisted % 2 == 0 ? magnitude : -magnitude;
|
||||
for(EntityPlayer target : targets2){
|
||||
target.rotationPitch += this.ticksExisted % 2 == 0 ? magnitude : -magnitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user