2016-03-16 17:49:28 +03:00
|
|
|
package emt.entity;
|
2015-12-13 21:24:42 +03:00
|
|
|
|
2015-12-26 22:50:59 +03:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
2015-12-13 21:24:42 +03:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
import ic2.core.IC2;
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.command.IEntitySelector;
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.IProjectile;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
2015-12-26 22:50:59 +03:00
|
|
|
public class EntityShield extends Entity {
|
2015-12-16 14:47:38 +03:00
|
|
|
public EntityPlayer owner;
|
2015-12-26 22:50:59 +03:00
|
|
|
public boolean needCheck = true;
|
2015-12-13 21:24:42 +03:00
|
|
|
|
|
|
|
|
public EntityShield(World world) {
|
2015-12-26 22:50:59 +03:00
|
|
|
super(world);
|
|
|
|
|
this.ignoreFrustumCheck = true;
|
2015-12-13 21:24:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EntityShield(World world, EntityPlayer player) {
|
|
|
|
|
super(world);
|
|
|
|
|
this.setSize(4, 4);
|
|
|
|
|
owner = player;
|
2015-12-26 22:50:59 +03:00
|
|
|
this.dataWatcher.updateObject(11, owner.getDisplayName());
|
2015-12-13 21:24:42 +03:00
|
|
|
this.setPosition(player.posX, player.posY, player.posZ);
|
|
|
|
|
this.ignoreFrustumCheck = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void entityInit() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-12-26 22:50:59 +03:00
|
|
|
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
2015-12-13 21:24:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-12-26 22:50:59 +03:00
|
|
|
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
2015-12-13 21:24:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AxisAlignedBB getBoundingBox() {
|
|
|
|
|
return this.boundingBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canBePushed() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-01-01 23:26:52 +03:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canBeCollidedWith() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-12-13 21:24:42 +03:00
|
|
|
|
|
|
|
|
public void setPosition(double x, double y, double z) {
|
|
|
|
|
this.posX = x;
|
|
|
|
|
this.posY = y + 0.5f;
|
|
|
|
|
this.posZ = z;
|
|
|
|
|
float f = this.width / 2.0F;
|
|
|
|
|
float f1 = this.height;
|
|
|
|
|
this.boundingBox.setBounds(x - (double) f, y - (double) this.yOffset - 2 + (double) this.ySize, z - (double) f, x + (double) f, y - (double) this.yOffset - 2 + (double) this.ySize + (double) f1, z + (double) f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onUpdate() {
|
|
|
|
|
super.onUpdate();
|
2015-12-26 22:50:59 +03:00
|
|
|
|
|
|
|
|
if(needCheck && owner == null) {
|
|
|
|
|
owner = this.worldObj.getPlayerEntityByName(dataWatcher.getWatchableObjectString(11));
|
|
|
|
|
needCheck = false;
|
|
|
|
|
}
|
2015-12-28 18:31:36 +03:00
|
|
|
if(!needCheck && owner == null){
|
2015-12-26 22:50:59 +03:00
|
|
|
this.setDead();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.worldObj.isRemote && owner != null) {
|
2015-12-13 21:24:42 +03:00
|
|
|
this.setPosition(owner.posX, owner.posY, owner.posZ);
|
|
|
|
|
if (!owner.isUsingItem()) {
|
|
|
|
|
this.setDead();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-14 19:32:25 +03:00
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public int getBrightnessForRender(float p_70070_1_){
|
|
|
|
|
return 240;
|
|
|
|
|
}
|
2015-12-13 21:24:42 +03:00
|
|
|
|
|
|
|
|
public void applyEntityCollision(Entity entity) {
|
|
|
|
|
if (entity.riddenByEntity != this && entity.ridingEntity != this) {
|
|
|
|
|
double ePosX = entity.posX - this.posX;
|
|
|
|
|
double ePosZ = entity.posZ - this.posZ;
|
2015-12-28 18:31:36 +03:00
|
|
|
entity.addVelocity(ePosX / 5D, 0.0D, ePosZ / 5D);
|
2015-12-13 21:24:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isInRangeToRender3d(double x, double y, double z) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|