Skip to content

Commit

Permalink
fixing what animals eat
Browse files Browse the repository at this point in the history
  • Loading branch information
matt404 committed Nov 26, 2017
1 parent 051a6ed commit 52b265e
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 24 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ max-spawns:
skeleton-horse: 0
snow-golem: 0
spider: 0
squid: 0
witch: 0
wolf: 1
zombie: 0
zombie-horse: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public void initEntity() {
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.SEEDS && distance <= 49;
return player.isAlive() && !player.closed &&
(player.getInventory().getItemInHand().getId() == Item.SEEDS ||
player.getInventory().getItemInHand().getId() == Item.BEETROOT_SEEDS ||
player.getInventory().getItemInHand().getId() == Item.MELON_SEEDS ||
player.getInventory().getItemInHand().getId() == Item.PUMPKIN_SEEDS
)&& distance <= 49;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void initEntity() {
this.setMaxHealth(10);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ public void initEntity() {
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.SEEDS && distance <= 49;
return player.spawned && player.isAlive() && !player.closed
&& (player.getInventory().getItemInHand().getId() == Item.WHEAT ||
player.getInventory().getItemInHand().getId() == Item.APPLE ||
player.getInventory().getItemInHand().getId() == Item.HAY_BALE ||
player.getInventory().getItemInHand().getId() == Item.GOLDEN_APPLE ||
player.getInventory().getItemInHand().getId() == Item.SUGAR ||
player.getInventory().getItemInHand().getId() == Item.BREAD ||
player.getInventory().getItemInHand().getId() == Item.GOLDEN_CARROT)
&& distance <= 49;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
package de.kniffo80.mobplugin.entities.animal.walking;

import cn.nukkit.Player;
import cn.nukkit.entity.EntityCreature;
import cn.nukkit.event.entity.EntityDamageByEntityEvent;
import cn.nukkit.item.Item;
import cn.nukkit.level.format.FullChunk;
Expand Down Expand Up @@ -46,6 +48,23 @@ public void initEntity() {
this.setMaxHealth(15);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed
&& (player.getInventory().getItemInHand().getId() == Item.WHEAT ||
player.getInventory().getItemInHand().getId() == Item.APPLE ||
player.getInventory().getItemInHand().getId() == Item.HAY_BALE ||
player.getInventory().getItemInHand().getId() == Item.GOLDEN_APPLE ||
player.getInventory().getItemInHand().getId() == Item.SUGAR ||
player.getInventory().getItemInHand().getId() == Item.BREAD ||
player.getInventory().getItemInHand().getId() == Item.GOLDEN_CARROT)
&& distance <= 49;
}
return false;
}

@Override
public Item[] getDrops() {
if (this.lastDamageCause instanceof EntityDamageByEntityEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void initEntity() {
this.setMaxHealth(10);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ public void initEntity() {
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.SEEDS && distance <= 49;
return player.spawned && player.isAlive() && !player.closed
&& (player.getInventory().getItemInHand().getId() == Item.WHEAT ||
player.getInventory().getItemInHand().getId() == Item.APPLE ||
player.getInventory().getItemInHand().getId() == Item.HAY_BALE ||
player.getInventory().getItemInHand().getId() == Item.GOLDEN_APPLE ||
player.getInventory().getItemInHand().getId() == Item.SUGAR ||
player.getInventory().getItemInHand().getId() == Item.BREAD ||
player.getInventory().getItemInHand().getId() == Item.GOLDEN_CARROT)
&& distance <= 49;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected void initEntity() {
this.setMaxHealth(10);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ public void initEntity() {
this.setMaxHealth(10);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.CARROT && distance <= 49;
return player.spawned && player.isAlive() && !player.closed &&
(player.getInventory().getItemInHand().getId() == Item.CARROT ||
player.getInventory().getItemInHand().getId() == Item.POTATO ||
player.getInventory().getItemInHand().getId() == Item.BEETROOT
)
&& distance <= 49;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ public void initEntity() {
this.setMaxHealth(3);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.SEEDS && distance <= 49;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.CARROT && distance <= 49;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void initEntity() {
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.SEEDS && distance <= 49;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.WHEAT && distance <= 49;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ public void initEntity() {
this.setMaxHealth(15);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.SEEDS && distance <= 49;
}
return false;
}

@Override
public Item[] getDrops() {
if (this.lastDamageCause instanceof EntityDamageByEntityEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ public void initEntity() {
this.setMaxHealth(15);
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
if (creature instanceof Player) {
Player player = (Player) creature;
return player.spawned && player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.SEEDS && distance <= 49;
}
return false;
}

@Override
public Item[] getDrops() {
if (this.lastDamageCause instanceof EntityDamageByEntityEvent) {
Expand Down

0 comments on commit 52b265e

Please sign in to comment.