Browse Source

prevent TraitCatcher from picking up mobs killed without a weapon with the trait, fixes #177

pull/5/head 1.3.3
Giovanni Harting 3 years ago
parent
commit
804a02d3fd
Signed by: anonfunc GPG Key ID: 597FC6BA3AA9A919
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      src/main/java/com/sosnitzka/taiga/traits/TraitCatcher.java

+ 8
- 0
src/main/java/com/sosnitzka/taiga/traits/TraitCatcher.java View File

@ -42,16 +42,24 @@ public class TraitCatcher extends AbstractTrait {
return;
if (event.getEntityLiving() instanceof EntityPlayer || event.getEntityLiving() instanceof EntityPlayerMP)
return;
World w = event.getSource().getTrueSource().getEntityWorld();
EntityPlayer p = (EntityPlayer) event.getSource().getTrueSource();
if (!TinkerUtil.hasTrait(TagUtil.getTagSafe(p.getHeldItemMainhand()), identifier))
return;
EntityLivingBase target = event.getEntityLiving();
NBTTagCompound tag = TagUtil.getExtraTag(p.getHeldItemMainhand());
Data data = Data.read(tag);
if (!data.mobClass.isEmpty())
return;
if (!w.isRemote && random.nextInt((int) target.getMaxHealth()) <= chance && target instanceof EntityLiving) {
event.setCanceled(true);
target.setDropItemsWhenDead(false);
if (data.mobClass.isEmpty()) {
data.mobClass = target.getClass().getName();
data.mobName = target.getName();


Loading…
Cancel
Save