Adjust /npc wither charged -> invulnerable, add arrow-shield
This commit is contained in:
parent
a70ca4fe8b
commit
1ccc2eae6d
|
@ -2804,7 +2804,7 @@ public class NPCCommands {
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "wither (--charged [charged])",
|
usage = "wither (--invulnerable [true|false]) (--arrow-shield [true|false])",
|
||||||
desc = "Sets wither modifiers",
|
desc = "Sets wither modifiers",
|
||||||
modifiers = { "wither" },
|
modifiers = { "wither" },
|
||||||
min = 1,
|
min = 1,
|
||||||
|
@ -2812,11 +2812,14 @@ public class NPCCommands {
|
||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.wither")
|
permission = "citizens.npc.wither")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER })
|
||||||
public void wither(CommandContext args, CommandSender sender, NPC npc, @Flag("charged") Boolean charged)
|
public void wither(CommandContext args, CommandSender sender, NPC npc, @Flag("invulnerable") Boolean invulnerable,
|
||||||
throws CommandException {
|
@Flag("arrow-shield") Boolean arrows) throws CommandException {
|
||||||
WitherTrait trait = npc.getOrAddTrait(WitherTrait.class);
|
WitherTrait trait = npc.getOrAddTrait(WitherTrait.class);
|
||||||
if (charged != null) {
|
if (invulnerable != null) {
|
||||||
trait.setCharged(charged);
|
trait.setInvulnerable(invulnerable);
|
||||||
|
}
|
||||||
|
if (arrows != null) {
|
||||||
|
trait.setBlocksArrows(arrows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,26 +14,41 @@ import net.citizensnpcs.util.NMS;
|
||||||
*/
|
*/
|
||||||
@TraitName("withertrait")
|
@TraitName("withertrait")
|
||||||
public class WitherTrait extends Trait {
|
public class WitherTrait extends Trait {
|
||||||
|
@Persist("arrowshield")
|
||||||
|
private Boolean arrowShield;
|
||||||
@Persist("charged")
|
@Persist("charged")
|
||||||
private boolean charged = false;
|
private Boolean invulnerable;
|
||||||
|
|
||||||
public WitherTrait() {
|
public WitherTrait() {
|
||||||
super("withertrait");
|
super("withertrait");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCharged() {
|
public Boolean blocksArrows() {
|
||||||
return charged;
|
return arrowShield;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInvulnerable() {
|
||||||
|
return invulnerable == null ? npc.isProtected() : invulnerable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (npc.getEntity() instanceof Wither) {
|
if (!(npc.getEntity() instanceof Wither))
|
||||||
Wither wither = (Wither) npc.getEntity();
|
return;
|
||||||
NMS.setWitherCharged(wither, charged);
|
Wither wither = (Wither) npc.getEntity();
|
||||||
|
NMS.setWitherInvulnerable(wither, invulnerable == null ? npc.isProtected() : invulnerable);
|
||||||
|
if (arrowShield != null) {
|
||||||
|
npc.data().set("wither-arrow-shield", arrowShield);
|
||||||
|
} else {
|
||||||
|
npc.data().remove("wither-arrow-shield");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCharged(boolean charged) {
|
public void setBlocksArrows(boolean arrowShield) {
|
||||||
this.charged = charged;
|
this.arrowShield = arrowShield;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvulnerable(boolean invulnerable) {
|
||||||
|
this.invulnerable = invulnerable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,7 +607,7 @@ public class NMS {
|
||||||
BRIDGE.setVerticalMovement(bukkitEntity, d);
|
BRIDGE.setVerticalMovement(bukkitEntity, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setWitherCharged(Wither wither, boolean charged) {
|
public static void setWitherInvulnerable(Wither wither, boolean charged) {
|
||||||
BRIDGE.setWitherCharged(wither, charged);
|
BRIDGE.setWitherCharged(wither, charged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,12 @@ public class WitherController extends MobEntityController {
|
||||||
return npc == null ? super.d(save) : false;
|
return npc == null ? super.d(save) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean df() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.df()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
|
|
|
@ -64,6 +64,12 @@ public class WitherController extends MobEntityController {
|
||||||
return npc == null ? super.d(save) : false;
|
return npc == null ? super.d(save) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean di() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.di()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
|
|
|
@ -65,6 +65,12 @@ public class WitherController extends MobEntityController {
|
||||||
return npc == null ? super.d(save) : false;
|
return npc == null ? super.d(save) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dn() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.dn()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
|
|
|
@ -73,6 +73,12 @@ public class WitherController extends MobEntityController {
|
||||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dA() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.dA()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
|
|
|
@ -66,6 +66,12 @@ public class WitherController extends MobEntityController {
|
||||||
return npc == null ? super.d(save) : false;
|
return npc == null ? super.d(save) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean dW() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.dW()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
|
|
|
@ -129,6 +129,12 @@ public class WitherController extends MobEntityController {
|
||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean J_() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.J_()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int l(int i) {
|
public int l(int i) {
|
||||||
return npc == null ? super.l(i) : 0;
|
return npc == null ? super.l(i) : 0;
|
||||||
|
|
|
@ -154,6 +154,12 @@ public class WitherController extends MobEntityController {
|
||||||
}
|
}
|
||||||
return super.n(entity);
|
return super.n(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean S_() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.S_()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WitherNPC extends CraftWither implements ForwardingNPCHolder {
|
public static class WitherNPC extends CraftWither implements ForwardingNPCHolder {
|
||||||
|
|
|
@ -132,6 +132,12 @@ public class WitherController extends MobEntityController {
|
||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPowered() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.isPowered()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void push(double x, double y, double z) {
|
public void push(double x, double y, double z) {
|
||||||
Vector vector = Util.callPushEvent(npc, x, y, z);
|
Vector vector = Util.callPushEvent(npc, x, y, z);
|
||||||
|
|
|
@ -134,6 +134,12 @@ public class WitherController extends MobEntityController {
|
||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPowered() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.isPowered()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void push(double x, double y, double z) {
|
public void push(double x, double y, double z) {
|
||||||
Vector vector = Util.callPushEvent(npc, x, y, z);
|
Vector vector = Util.callPushEvent(npc, x, y, z);
|
||||||
|
|
|
@ -126,6 +126,12 @@ public class WitherController extends MobEntityController {
|
||||||
return NMSImpl.isLeashed(this, super.isLeashed());
|
return NMSImpl.isLeashed(this, super.isLeashed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPowered() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.isPowered()
|
||||||
|
: npc.data().get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void push(double x, double y, double z) {
|
public void push(double x, double y, double z) {
|
||||||
Vector vector = Util.callPushEvent(npc, x, y, z);
|
Vector vector = Util.callPushEvent(npc, x, y, z);
|
||||||
|
|
|
@ -62,6 +62,12 @@ public class WitherController extends MobEntityController {
|
||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean cm() {
|
||||||
|
return npc == null || !npc.data().has("wither-arrow-damageable") ? super.cm()
|
||||||
|
: npc.data().<Boolean> get("wither-arrow-damageable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
|
public void collide(net.minecraft.server.v1_8_R3.Entity entity) {
|
||||||
// this method is called by both the entities involved - cancelling
|
// this method is called by both the entities involved - cancelling
|
||||||
|
|
Loading…
Reference in New Issue