Skip to content

Commit

Permalink
now hostile!
Browse files Browse the repository at this point in the history
  • Loading branch information
baguchi committed Nov 15, 2023
1 parent 86aac4d commit b36ca7a
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package baguchan.better_with_aquatic.entity;

import net.minecraft.core.entity.Entity;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.util.helper.DamageType;
import net.minecraft.core.world.World;

public class EntityAnglerFish extends EntityBaseFish {
Expand All @@ -8,7 +11,7 @@ public EntityAnglerFish(World world) {
this.highestSkinVariant = -1;
this.setSize(0.5F, 0.45F);
this.setPos(this.x, this.y, this.z);

this.health = 5;
this.skinName = "angler_fish";
}

Expand All @@ -27,4 +30,27 @@ public String getDefaultEntityTexture() {
protected float getBlockPathWeight(int x, int y, int z) {
return 0.5f - this.world.getLightBrightness(x, y, z);
}

@Override
protected Entity findPlayerToAttack() {
EntityPlayer entityplayer = this.world.getClosestPlayerToEntity(this, 16.0);
if (entityplayer != null && this.canEntityBeSeen(entityplayer) && entityplayer.getGamemode().areMobsHostile) {
return entityplayer;
}
return null;
}

@Override
public boolean hurt(Entity entity, int i, DamageType type) {
if (super.hurt(entity, i, type)) {
if (this.passenger == entity || this.vehicle == entity) {
return true;
}
if (entity != this) {
this.entityToAttack = entity;
}
return true;
}
return false;
}
}

0 comments on commit b36ca7a

Please sign in to comment.