Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EntityDataSwordman extends EntityDataGeneric {
- public EntityDataSwordman(World world) {
- super(world);
- Minecraft.getMinecraft().thePlayer.sendChatMessage("Constructing swordman at World#isRemote:" + world.isRemote);
- // this.tasks.addTask(0, new EntityAISwimming(this));
- this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityMob.class, 1, true));
- this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true));
- // this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
- // this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityMob.class, 8.0F));
- // this.tasks.addTask(8, new EntityAILookIdle(this));
- this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
- this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMob.class, 0, true));
- this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword));
- this.setCustomNameTag("Data Swordsman");
- this.setAlwaysRenderNameTag(true);
- this.getNavigator().setAvoidsWater(true);
- this.setEntityProperties();
- }
- @Override
- protected void setEntityProperties() {
- }
- @Override
- public void applyEntityAttributes() {
- super.applyEntityAttributes();
- this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
- this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
- this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5);
- this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20);
- this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1);
- }
- @Override
- public void entityInit() {
- super.entityInit();
- }
- @Override
- public void readEntityFromNBT(NBTTagCompound p_70037_1_) {
- // TODO Auto-generated method stub
- super.readEntityFromNBT(p_70037_1_);
- }
- @Override
- public void writeEntityToNBT(NBTTagCompound p_70014_1_) {
- // TODO Auto-generated method stub
- super.writeEntityToNBT(p_70014_1_);
- }
- @Override
- public boolean attackEntityAsMob(Entity entityTarget) {
- float attackDamage = EntityProperties.getEntityAttackDamage(this);
- int knockbackModifier = 0;
- boolean isTargetHurt = false;
- EntityLivingBase entity;
- this.worldObj.setEntityState(this, (byte) 4);
- if (entityTarget instanceof EntityLivingBase) {
- entity = (EntityLivingBase) entityTarget;
- attackDamage += EnchantmentHelper.getEnchantmentModifierLiving(this, entity);
- knockbackModifier += EnchantmentHelper.getKnockbackModifier(this, entity);
- EnchantmentHelper.func_151384_a(entity, this);
- isTargetHurt = entityTarget.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage);
- if (isTargetHurt) {
- if (knockbackModifier > 0) {
- entityTarget.addVelocity((double)(-MathHelper.sin(rotationYaw *
- (float)Math.PI / 180.0F) * (float)knockbackModifier * 0.5F),
- 0.1D, (double)(MathHelper.cos(rotationYaw *
- (float)Math.PI / 180.0F) * (float)knockbackModifier * 0.5F));
- motionX *= 0.6D;
- motionZ *= 0.6D;
- }
- int fireModifier = EnchantmentHelper.getFireAspectModifier(this);
- if (fireModifier > 0)
- {
- entityTarget.setFire(fireModifier * 4);
- }
- EnchantmentHelper.func_151385_b(this, entityTarget);
- }
- }
- return isTargetHurt;
- }
- @Override
- public boolean canDespawn() {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement