Validate ResourceLocation in NBT reading
This commit is contained in:
@@ -35,12 +35,13 @@
|
||||
protected Mob(EntityType<? extends Mob> type, Level world) {
|
||||
super(type, world);
|
||||
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
@@ -158,7 +172,13 @@
|
||||
@@ -157,8 +171,14 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
this.registerGoals();
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setPersistenceRequired(boolean persistenceRequired) {
|
||||
+ this.persistenceRequired = persistenceRequired;
|
||||
@@ -49,7 +50,7 @@
|
||||
|
||||
protected void registerGoals() {}
|
||||
|
||||
@@ -264,11 +284,42 @@
|
||||
@@ -264,13 +284,44 @@
|
||||
|
||||
@Nullable
|
||||
protected final LivingEntity getTargetFromBrain() {
|
||||
@@ -61,8 +62,8 @@
|
||||
- this.target = target;
|
||||
+ // CraftBukkit start - fire event
|
||||
+ this.setTarget(target, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ public boolean setTarget(LivingEntity entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ if (this.getTarget() == entityliving) return false;
|
||||
+ if (fireEvent) {
|
||||
@@ -91,9 +92,11 @@
|
||||
+ this.target = entityliving;
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public boolean canAttackType(EntityType<?> type) {
|
||||
return type != EntityType.GHAST;
|
||||
@@ -399,6 +450,12 @@
|
||||
return null;
|
||||
}
|
||||
@@ -135,7 +138,15 @@
|
||||
ListTag nbttaglist;
|
||||
CompoundTag nbttagcompound1;
|
||||
int i;
|
||||
@@ -547,6 +616,11 @@
|
||||
@@ -540,13 +609,18 @@
|
||||
this.readLeashData(nbt);
|
||||
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
|
||||
if (nbt.contains("DeathLootTable", 8)) {
|
||||
- this.lootTable = Optional.of(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("DeathLootTable"))));
|
||||
+ this.lootTable = Optional.ofNullable(ResourceLocation.tryParse(nbt.getString("DeathLootTable"))).map((rs) -> ResourceKey.create(Registries.LOOT_TABLE, rs)); // Paper - Validate ResourceLocation
|
||||
} else {
|
||||
this.lootTable = Optional.empty();
|
||||
}
|
||||
|
||||
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
|
||||
this.setNoAi(nbt.getBoolean("NoAI"));
|
||||
|
||||
Reference in New Issue
Block a user