Basic sigils implementation
This commit is contained in:
parent
ae85224003
commit
5dff08380d
61 changed files with 1394 additions and 106 deletions
|
@ -0,0 +1,174 @@
|
|||
package WayofTime.bloodmagic.entity.projectile;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import net.minecraftforge.fml.common.registry.IThrowableEntity;
|
||||
|
||||
public class EntityBloodLight extends EntityThrowable implements IThrowableEntity, IEntityAdditionalSpawnData {
|
||||
|
||||
public EntityLivingBase shootingEntity;
|
||||
protected int ticksInAir = 0;
|
||||
protected int maxTicksInAir = 600;
|
||||
|
||||
public EntityBloodLight(World world) {
|
||||
super(world);
|
||||
this.setSize(0.5F, 0.5F);
|
||||
}
|
||||
|
||||
public EntityBloodLight(World world, double x, double y, double z) {
|
||||
super(world);
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
public EntityBloodLight(World world, EntityLivingBase player) {
|
||||
super(world, player);
|
||||
shootingEntity = player;
|
||||
float par3 = 0.8F;
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setLocationAndAngles(player.posX, player.posY + player.getEyeHeight(), player.posZ, player.rotationYaw, player.rotationPitch);
|
||||
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||
posY -= 0.2D;
|
||||
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||
this.setPosition(posX, posY, posZ);
|
||||
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
|
||||
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
|
||||
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
|
||||
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getGravityVelocity() {
|
||||
return 0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getVelocity() {
|
||||
return 1F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) {
|
||||
float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
|
||||
var1 /= var9;
|
||||
var3 /= var9;
|
||||
var5 /= var9;
|
||||
var1 += rand.nextGaussian() * 0.007499999832361937D * var8;
|
||||
var3 += rand.nextGaussian() * 0.007499999832361937D * var8;
|
||||
var5 += rand.nextGaussian() * 0.007499999832361937D * var8;
|
||||
var1 *= var7;
|
||||
var3 *= var7;
|
||||
var5 *= var7;
|
||||
motionX = var1;
|
||||
motionY = var3;
|
||||
motionZ = var5;
|
||||
float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
|
||||
prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI);
|
||||
prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (this.ticksExisted > this.maxTicksInAir) {
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition mop) {
|
||||
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) {
|
||||
if (mop.entityHit == shootingEntity) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.onImpact(mop.entityHit);
|
||||
}
|
||||
else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
EnumFacing sideHit = mop.sideHit;
|
||||
BlockPos blockPos = mop.getBlockPos().offset(sideHit);
|
||||
|
||||
if (worldObj.isAirBlock(blockPos)) {
|
||||
worldObj.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
protected void onImpact(Entity mop) {
|
||||
if (mop == shootingEntity && ticksInAir > 3) {
|
||||
shootingEntity.attackEntityFrom(DamageSource.causeMobDamage(shootingEntity), 1);
|
||||
this.setDead();
|
||||
}
|
||||
else {
|
||||
if (mop instanceof EntityLivingBase) {
|
||||
((EntityLivingBase) mop).setRevengeTarget(shootingEntity);
|
||||
doDamage(1, mop);
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.isAirBlock(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ))) {
|
||||
worldObj.setBlockState(new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), Blocks.fire.getDefaultState());
|
||||
}
|
||||
|
||||
// spawnHitParticles("magicCrit", 8);
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
protected void doDamage(int i, Entity mop) {
|
||||
mop.attackEntityFrom(this.getDamageSource(), i);
|
||||
}
|
||||
|
||||
public DamageSource getDamageSource() {
|
||||
return DamageSource.causeMobDamage(shootingEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(ByteBuf data) {
|
||||
data.writeByte(this.ticksInAir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData(ByteBuf data) {
|
||||
this.ticksInAir = data.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
super.writeEntityToNBT(nbt);
|
||||
nbt.setInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR, ticksInAir);
|
||||
nbt.setInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR, maxTicksInAir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
super.readEntityFromNBT(nbt);
|
||||
ticksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_TICKS_IN_AIR);
|
||||
maxTicksInAir = nbt.getInteger(Constants.NBT.PROJECTILE_MAX_TICKS_IN_AIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThrower(Entity entity) {
|
||||
if (entity instanceof EntityLivingBase) this.shootingEntity = (EntityLivingBase) entity;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue