Move screen shaking effect into a proper method in the client proxy, fix earthquake's version not working and add screen shake to meteor, lightning hammer and shockwave

This commit is contained in:
Electroblob77
2020-02-19 00:11:33 +00:00
parent 0328f41564
commit 794085660e
8 changed files with 61 additions and 22 deletions
@@ -7,7 +7,6 @@ import electroblob.wizardry.util.MagicDamage.DamageType;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.MobEffects;
import net.minecraft.network.play.server.SPacketEntityVelocity;
@@ -97,18 +96,6 @@ public class EntityEarthquake extends EntityMagicConstruct {
}
}
}
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 : targets2){
target.rotationPitch += this.ticksExisted % 2 == 0 ? magnitude : -magnitude;
}
}
}
}
@@ -169,6 +169,7 @@ public class EntityHammer extends EntityMagicConstruct {
public void fall(float distance, float damageMultiplier){
if(world.isRemote){
for(int i = 0; i < 40; i++){
double particleX = this.posX - 1.0d + 2 * rand.nextDouble();
double particleZ = this.posZ - 1.0d + 2 * rand.nextDouble();
@@ -180,6 +181,12 @@ public class EntityHammer extends EntityMagicConstruct {
particleX - this.posX, 0, particleZ - this.posZ, Block.getStateId(block));
}
}
if(this.fallDistance > 10){
WizardryUtilities.getEntitiesWithinRadius(10, posX, posY, posZ, world, EntityPlayer.class)
.forEach(p -> Wizardry.proxy.shakeScreen(p, 6));
}
}else{
// Just to check the hammer has actually fallen from the sky, rather than the block under it being broken.
if(this.fallDistance > 10){