mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 12:07:38 +01:00
Extend horse modifiers to save saddle and armor
This commit is contained in:
parent
8fd93f82af
commit
53c975cce8
@ -5,12 +5,14 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.MobEntityController;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.HorseModifiers;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_6_R2.EntityHorse;
|
||||
import net.minecraft.server.v1_6_R2.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftHorse;
|
||||
@ -27,6 +29,12 @@ public class HorseController extends MobEntityController {
|
||||
return (Horse) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawn(Location at, NPC npc) {
|
||||
npc.getTrait(HorseModifiers.class);
|
||||
super.spawn(at, npc);
|
||||
}
|
||||
|
||||
public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
|
||||
private int jumpTicks;
|
||||
private final CitizensNPC npc;
|
||||
|
@ -7,12 +7,17 @@ import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Color;
|
||||
import org.bukkit.entity.Horse.Style;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HorseModifiers extends Trait {
|
||||
@Persist("armor")
|
||||
private ItemStack armor = null;
|
||||
@Persist("carryingChest")
|
||||
private boolean carryingChest;
|
||||
@Persist("color")
|
||||
private Color color = Color.CREAMY;
|
||||
@Persist("saddle")
|
||||
private ItemStack saddle = null;
|
||||
@Persist("style")
|
||||
private Style style = Style.NONE;
|
||||
@Persist("type")
|
||||
@ -39,6 +44,15 @@ public class HorseModifiers extends Trait {
|
||||
updateModifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (npc.getBukkitEntity() instanceof Horse) {
|
||||
Horse horse = (Horse) npc.getBukkitEntity();
|
||||
saddle = horse.getInventory().getSaddle();
|
||||
armor = horse.getInventory().getArmor();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCarryingChest(boolean carryingChest) {
|
||||
this.carryingChest = carryingChest;
|
||||
updateModifiers();
|
||||
@ -66,6 +80,8 @@ public class HorseModifiers extends Trait {
|
||||
horse.setColor(color);
|
||||
horse.setStyle(style);
|
||||
horse.setVariant(type);
|
||||
horse.getInventory().setArmor(armor);
|
||||
horse.getInventory().setSaddle(saddle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user