Fix giants, equipping (partially)

This commit is contained in:
fullwall 2016-03-02 00:51:21 +08:00
parent b48940f1e4
commit e93000acdb
4 changed files with 41 additions and 13 deletions

View File

@ -13,7 +13,7 @@ import net.citizensnpcs.util.Messages;
public class GenericEquipper implements Equipper {
@Override
public void equip(Player equipper, NPC toEquip) {
ItemStack hand = equipper.getItemInHand();
ItemStack hand = equipper.getInventory().getItemInMainHand();
Equipment trait = toEquip.getTrait(Equipment.class);
EquipmentSlot slot = EquipmentSlot.HAND;
Material type = hand == null ? Material.AIR : hand.getType();
@ -27,41 +27,49 @@ public class GenericEquipper implements Equipper {
case GOLD_HELMET:
case IRON_HELMET:
case DIAMOND_HELMET:
if (!equipper.isSneaking())
if (!equipper.isSneaking()) {
slot = EquipmentSlot.HELMET;
}
break;
case LEATHER_CHESTPLATE:
case CHAINMAIL_CHESTPLATE:
case GOLD_CHESTPLATE:
case IRON_CHESTPLATE:
case DIAMOND_CHESTPLATE:
if (!equipper.isSneaking())
if (!equipper.isSneaking()) {
slot = EquipmentSlot.CHESTPLATE;
}
break;
case LEATHER_LEGGINGS:
case CHAINMAIL_LEGGINGS:
case GOLD_LEGGINGS:
case IRON_LEGGINGS:
case DIAMOND_LEGGINGS:
if (!equipper.isSneaking())
if (!equipper.isSneaking()) {
slot = EquipmentSlot.LEGGINGS;
}
break;
case LEATHER_BOOTS:
case CHAINMAIL_BOOTS:
case GOLD_BOOTS:
case IRON_BOOTS:
case DIAMOND_BOOTS:
if (!equipper.isSneaking())
if (!equipper.isSneaking()) {
slot = EquipmentSlot.BOOTS;
}
break;
case AIR:
for (int i = 0; i < 5; i++) {
if (trait.get(i) != null && trait.get(i).getType() != Material.AIR) {
equipper.getWorld().dropItemNaturally(toEquip.getEntity().getLocation(), trait.get(i));
trait.set(i, null);
if (equipper.isSneaking()) {
for (int i = 0; i < 5; i++) {
if (trait.get(i) != null && trait.get(i).getType() != Material.AIR) {
equipper.getWorld().dropItemNaturally(toEquip.getEntity().getLocation(), trait.get(i));
trait.set(i, null);
}
}
Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_ALL_ITEMS_REMOVED, toEquip.getName());
} else {
return;
}
Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_ALL_ITEMS_REMOVED, toEquip.getName());
break;
default:
break;
@ -79,7 +87,7 @@ public class GenericEquipper implements Equipper {
clone.setAmount(1);
trait.set(slot, clone);
hand.setAmount(hand.getAmount() - 1);
equipper.setItemInHand(hand);
equipper.getInventory().setItemInMainHand(hand);
}
}
}

View File

@ -171,6 +171,14 @@ public class GiantController extends MobEntityController {
}
}
@Override
public void M() {
super.M();
if (npc != null) {
npc.update();
}
}
@Override
public boolean n_() {
if (npc == null || !npc.isFlyable()) {

View File

@ -16,6 +16,7 @@ import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.EntityAIBodyControl;
import net.minecraft.server.v1_9_R1.EntityShulker;
import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.MinecraftKey;
@ -180,6 +181,13 @@ public class ShulkerController extends MobEntityController {
}
}
@Override
public void n() {
if (npc == null) {
super.n();
}
}
@Override
public boolean n_() {
if (npc == null || !npc.isFlyable()) {
@ -189,6 +197,11 @@ public class ShulkerController extends MobEntityController {
}
}
@Override
protected EntityAIBodyControl s() {
return new EntityAIBodyControl(this);
}
@Override
public void setSize(float f, float f1) {
if (npc == null) {

View File

@ -72,8 +72,7 @@ public class VillagerController extends MobEntityController {
@Override
public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
return npc == null || !blockTrades ? super.a(entityhuman) : false; // block
// trades
return npc == null || !blockTrades ? super.a(entityhuman) : false; // block trades
}
@Override