mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 12:15:53 +01:00
Fix /npc polarbear message and simplify behavior map entities to work with /npc ai
This commit is contained in:
parent
fe7f6e373f
commit
0111600aa8
@ -74,8 +74,9 @@ public class Commands {
|
||||
String output = "";
|
||||
if (args.hasFlag('r')) {
|
||||
trait.setRearing(!trait.isRearing());
|
||||
output += Messaging
|
||||
.tr(trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING);
|
||||
output += Messaging.tr(
|
||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output);
|
||||
|
@ -107,8 +107,9 @@ public class Commands {
|
||||
String output = "";
|
||||
if (args.hasFlag('r')) {
|
||||
trait.setRearing(!trait.isRearing());
|
||||
output += Messaging
|
||||
.tr(trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING);
|
||||
output += Messaging.tr(
|
||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output);
|
||||
|
@ -136,8 +136,9 @@ public class Commands {
|
||||
String output = "";
|
||||
if (args.hasFlag('r')) {
|
||||
trait.setRearing(!trait.isRearing());
|
||||
output += Messaging
|
||||
.tr(trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING);
|
||||
output += Messaging.tr(
|
||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output);
|
||||
|
@ -166,8 +166,9 @@ public class Commands {
|
||||
String output = "";
|
||||
if (args.hasFlag('r')) {
|
||||
trait.setRearing(!trait.isRearing());
|
||||
output += Messaging
|
||||
.tr(trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING);
|
||||
output += Messaging.tr(
|
||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output);
|
||||
|
@ -336,8 +336,9 @@ public class Commands {
|
||||
String output = "";
|
||||
if (args.hasFlag('r')) {
|
||||
trait.setRearing(!trait.isRearing());
|
||||
output += Messaging
|
||||
.tr(trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING);
|
||||
output += Messaging.tr(
|
||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output);
|
||||
|
@ -1,10 +1,8 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import net.minecraft.server.v1_15_R1.EntityMinecartAbstract;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftVillager;
|
||||
@ -18,7 +16,6 @@ import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_15_R1.BehaviorController;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_15_R1.DamageSource;
|
||||
import net.minecraft.server.v1_15_R1.DataWatcherObject;
|
||||
@ -26,6 +23,7 @@ import net.minecraft.server.v1_15_R1.Entity;
|
||||
import net.minecraft.server.v1_15_R1.EntityBoat;
|
||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_15_R1.EntityLightning;
|
||||
import net.minecraft.server.v1_15_R1.EntityMinecartAbstract;
|
||||
import net.minecraft.server.v1_15_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_15_R1.EntityVillager;
|
||||
import net.minecraft.server.v1_15_R1.EnumHand;
|
||||
@ -48,12 +46,10 @@ public class VillagerController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityVillagerNPC extends EntityVillager implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private boolean blockingATrade;
|
||||
private boolean blockTrades = true;
|
||||
boolean calledNMSHeight = false;
|
||||
private final CitizensNPC npc;
|
||||
private BehaviorController<EntityVillager> previousBehaviorController;
|
||||
|
||||
public EntityVillagerNPC(EntityTypes<? extends EntityVillager> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -238,14 +234,7 @@ public class VillagerController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
this.previousBehaviorController = this.getBehaviorController();
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
|
@ -1,10 +1,8 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import net.minecraft.server.v1_15_R1.EntityMinecartAbstract;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftWanderingTrader;
|
||||
@ -25,6 +23,7 @@ import net.minecraft.server.v1_15_R1.Entity;
|
||||
import net.minecraft.server.v1_15_R1.EntityBoat;
|
||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_15_R1.EntityLightning;
|
||||
import net.minecraft.server.v1_15_R1.EntityMinecartAbstract;
|
||||
import net.minecraft.server.v1_15_R1.EntityTypes;
|
||||
import net.minecraft.server.v1_15_R1.EntityVillagerTrader;
|
||||
import net.minecraft.server.v1_15_R1.EnumHand;
|
||||
@ -46,7 +45,6 @@ public class WanderingTraderController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityWanderingTraderNPC extends EntityVillagerTrader implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private boolean blockingATrade;
|
||||
private boolean blockTrades = true;
|
||||
boolean calledNMSHeight = false;
|
||||
@ -234,12 +232,6 @@ public class WanderingTraderController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
super.mobTick();
|
||||
|
@ -380,8 +380,9 @@ public class Commands {
|
||||
String output = "";
|
||||
if (args.hasFlag('r')) {
|
||||
trait.setRearing(!trait.isRearing());
|
||||
output += Messaging
|
||||
.tr(trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING);
|
||||
output += Messaging.tr(
|
||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output);
|
||||
|
@ -1855,8 +1855,18 @@ public class NMSImpl implements NMSBridge {
|
||||
return;
|
||||
if (npc.useMinecraftAI()) {
|
||||
NMSImpl.restoreGoals(npc, entity.goalSelector, entity.targetSelector);
|
||||
if (npc.data().has("behavior-map")) {
|
||||
TreeMap behavior = npc.data().get("behavior-map");
|
||||
getBehaviorMap(entity).putAll(behavior);
|
||||
npc.data().remove("behavior-map");
|
||||
}
|
||||
} else {
|
||||
NMSImpl.clearGoals(npc, entity.goalSelector, entity.targetSelector);
|
||||
TreeMap behaviorMap = getBehaviorMap(entity);
|
||||
if (behaviorMap.size() > 0) {
|
||||
npc.data().set("behavior-map", new TreeMap(behaviorMap));
|
||||
behaviorMap.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.entity;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
|
||||
@ -16,7 +14,6 @@ import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.BehaviorController;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R3.DamageSource;
|
||||
import net.minecraft.server.v1_16_R3.Entity;
|
||||
@ -41,9 +38,7 @@ public class HoglinController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityHoglinNPC extends EntityHoglin implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private final CitizensNPC npc;
|
||||
private BehaviorController<EntityHoglin> previousBehaviorController;
|
||||
|
||||
public EntityHoglinNPC(EntityTypes<? extends EntityHoglin> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -191,14 +186,7 @@ public class HoglinController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
this.previousBehaviorController = this.getBehaviorController();
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
setImmuneToZombification(npc.isProtected());
|
||||
}
|
||||
super.mobTick();
|
||||
|
@ -191,14 +191,7 @@ public class PiglinBruteController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
this.previousBehaviorController = this.getBehaviorController();
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
setImmuneToZombification(npc.isProtected());
|
||||
}
|
||||
super.mobTick();
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.entity;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
|
||||
@ -16,7 +14,6 @@ import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.BehaviorController;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R3.DamageSource;
|
||||
import net.minecraft.server.v1_16_R3.Entity;
|
||||
@ -41,9 +38,7 @@ public class PiglinController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityPiglinNPC extends EntityPiglin implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private final CitizensNPC npc;
|
||||
private BehaviorController<EntityPiglin> previousBehaviorController;
|
||||
|
||||
public EntityPiglinNPC(EntityTypes<? extends EntityPiglin> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -191,14 +186,7 @@ public class PiglinController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
this.previousBehaviorController = this.getBehaviorController();
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
setImmuneToZombification(npc.isProtected());
|
||||
}
|
||||
super.mobTick();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
@ -17,7 +16,6 @@ import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.BehaviorController;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R3.DamageSource;
|
||||
import net.minecraft.server.v1_16_R3.DataWatcherObject;
|
||||
@ -50,12 +48,10 @@ public class VillagerController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityVillagerNPC extends EntityVillager implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private boolean blockingATrade;
|
||||
private boolean blockTrades = true;
|
||||
boolean calledNMSHeight = false;
|
||||
private final CitizensNPC npc;
|
||||
private BehaviorController<EntityVillager> previousBehaviorController;
|
||||
|
||||
public EntityVillagerNPC(EntityTypes<? extends EntityVillager> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -240,14 +236,7 @@ public class VillagerController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
this.previousBehaviorController = this.getBehaviorController();
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.entity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
@ -48,7 +47,6 @@ public class WanderingTraderController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityWanderingTraderNPC extends EntityVillagerTrader implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private boolean blockingATrade;
|
||||
private boolean blockTrades = true;
|
||||
boolean calledNMSHeight = false;
|
||||
@ -236,12 +234,6 @@ public class WanderingTraderController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
super.mobTick();
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.citizensnpcs.nms.v1_16_R3.entity;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
|
||||
@ -16,7 +14,6 @@ import net.citizensnpcs.nms.v1_16_R3.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_16_R3.BehaviorController;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R3.DamageSource;
|
||||
import net.minecraft.server.v1_16_R3.Entity;
|
||||
@ -41,9 +38,7 @@ public class ZoglinController extends MobEntityController {
|
||||
}
|
||||
|
||||
public static class EntityZoglinNPC extends EntityZoglin implements NPCHolder {
|
||||
private TreeMap<?, ?> behaviorMap;
|
||||
private final CitizensNPC npc;
|
||||
private BehaviorController<EntityZoglin> previousBehaviorController;
|
||||
|
||||
public EntityZoglinNPC(EntityTypes<? extends EntityZoglin> types, World world) {
|
||||
this(types, world, null);
|
||||
@ -191,14 +186,7 @@ public class ZoglinController extends MobEntityController {
|
||||
@Override
|
||||
public void mobTick() {
|
||||
if (npc != null) {
|
||||
if (this.behaviorMap == null || this.previousBehaviorController != this.getBehaviorController()) {
|
||||
this.behaviorMap = NMSImpl.getBehaviorMap(this);
|
||||
this.previousBehaviorController = this.getBehaviorController();
|
||||
}
|
||||
if (this.behaviorMap.size() > 0) {
|
||||
this.behaviorMap.clear();
|
||||
NMSImpl.clearGoals(npc, goalSelector, targetSelector);
|
||||
}
|
||||
NMSImpl.updateMinecraftAIState(npc, this);
|
||||
}
|
||||
super.mobTick();
|
||||
if (npc != null) {
|
||||
|
@ -380,8 +380,9 @@ public class Commands {
|
||||
String output = "";
|
||||
if (args.hasFlag('r')) {
|
||||
trait.setRearing(!trait.isRearing());
|
||||
output += Messaging
|
||||
.tr(trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING);
|
||||
output += Messaging.tr(
|
||||
trait.isRearing() ? Messages.POLAR_BEAR_REARING : Messages.POLAR_BEAR_STOPPED_REARING,
|
||||
npc.getName());
|
||||
}
|
||||
if (!output.isEmpty()) {
|
||||
Messaging.send(sender, output);
|
||||
|
@ -1828,8 +1828,18 @@ public class NMSImpl implements NMSBridge {
|
||||
return;
|
||||
if (npc.useMinecraftAI()) {
|
||||
NMSImpl.restoreGoals(npc, entity.goalSelector, entity.targetSelector);
|
||||
if (npc.data().has("behavior-map")) {
|
||||
TreeMap behavior = npc.data().get("behavior-map");
|
||||
getBehaviorMap(entity).putAll(behavior);
|
||||
npc.data().remove("behavior-map");
|
||||
}
|
||||
} else {
|
||||
NMSImpl.clearGoals(npc, entity.goalSelector, entity.targetSelector);
|
||||
TreeMap behaviorMap = getBehaviorMap(entity);
|
||||
if (behaviorMap.size() > 0) {
|
||||
npc.data().set("behavior-map", new TreeMap(behaviorMap));
|
||||
behaviorMap.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user