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 { public class GenericEquipper implements Equipper {
@Override @Override
public void equip(Player equipper, NPC toEquip) { public void equip(Player equipper, NPC toEquip) {
ItemStack hand = equipper.getItemInHand(); ItemStack hand = equipper.getInventory().getItemInMainHand();
Equipment trait = toEquip.getTrait(Equipment.class); Equipment trait = toEquip.getTrait(Equipment.class);
EquipmentSlot slot = EquipmentSlot.HAND; EquipmentSlot slot = EquipmentSlot.HAND;
Material type = hand == null ? Material.AIR : hand.getType(); Material type = hand == null ? Material.AIR : hand.getType();
@ -27,41 +27,49 @@ public class GenericEquipper implements Equipper {
case GOLD_HELMET: case GOLD_HELMET:
case IRON_HELMET: case IRON_HELMET:
case DIAMOND_HELMET: case DIAMOND_HELMET:
if (!equipper.isSneaking()) if (!equipper.isSneaking()) {
slot = EquipmentSlot.HELMET; slot = EquipmentSlot.HELMET;
}
break; break;
case LEATHER_CHESTPLATE: case LEATHER_CHESTPLATE:
case CHAINMAIL_CHESTPLATE: case CHAINMAIL_CHESTPLATE:
case GOLD_CHESTPLATE: case GOLD_CHESTPLATE:
case IRON_CHESTPLATE: case IRON_CHESTPLATE:
case DIAMOND_CHESTPLATE: case DIAMOND_CHESTPLATE:
if (!equipper.isSneaking()) if (!equipper.isSneaking()) {
slot = EquipmentSlot.CHESTPLATE; slot = EquipmentSlot.CHESTPLATE;
}
break; break;
case LEATHER_LEGGINGS: case LEATHER_LEGGINGS:
case CHAINMAIL_LEGGINGS: case CHAINMAIL_LEGGINGS:
case GOLD_LEGGINGS: case GOLD_LEGGINGS:
case IRON_LEGGINGS: case IRON_LEGGINGS:
case DIAMOND_LEGGINGS: case DIAMOND_LEGGINGS:
if (!equipper.isSneaking()) if (!equipper.isSneaking()) {
slot = EquipmentSlot.LEGGINGS; slot = EquipmentSlot.LEGGINGS;
}
break; break;
case LEATHER_BOOTS: case LEATHER_BOOTS:
case CHAINMAIL_BOOTS: case CHAINMAIL_BOOTS:
case GOLD_BOOTS: case GOLD_BOOTS:
case IRON_BOOTS: case IRON_BOOTS:
case DIAMOND_BOOTS: case DIAMOND_BOOTS:
if (!equipper.isSneaking()) if (!equipper.isSneaking()) {
slot = EquipmentSlot.BOOTS; slot = EquipmentSlot.BOOTS;
}
break; break;
case AIR: case AIR:
for (int i = 0; i < 5; i++) { if (equipper.isSneaking()) {
if (trait.get(i) != null && trait.get(i).getType() != Material.AIR) { for (int i = 0; i < 5; i++) {
equipper.getWorld().dropItemNaturally(toEquip.getEntity().getLocation(), trait.get(i)); if (trait.get(i) != null && trait.get(i).getType() != Material.AIR) {
trait.set(i, null); 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; break;
default: default:
break; break;
@ -79,7 +87,7 @@ public class GenericEquipper implements Equipper {
clone.setAmount(1); clone.setAmount(1);
trait.set(slot, clone); trait.set(slot, clone);
hand.setAmount(hand.getAmount() - 1); 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 @Override
public boolean n_() { public boolean n_() {
if (npc == null || !npc.isFlyable()) { 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.NMS;
import net.citizensnpcs.util.Util; import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_9_R1.BlockPosition; 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.EntityShulker;
import net.minecraft.server.v1_9_R1.IBlockData; import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.MinecraftKey; 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 @Override
public boolean n_() { public boolean n_() {
if (npc == null || !npc.isFlyable()) { if (npc == null || !npc.isFlyable()) {
@ -189,6 +197,11 @@ public class ShulkerController extends MobEntityController {
} }
} }
@Override
protected EntityAIBodyControl s() {
return new EntityAIBodyControl(this);
}
@Override @Override
public void setSize(float f, float f1) { public void setSize(float f, float f1) {
if (npc == null) { if (npc == null) {

View File

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