1.21.6 dev
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
committed by
Nassim Jahnke
parent
39203a65e0
commit
a24f9b204c
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -83,6 +_,14 @@
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@@ -82,6 +_,14 @@
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.ticks.ContainerSingleItem;
|
||||
|
||||
+// CraftBukkit start
|
||||
@ -15,7 +15,7 @@
|
||||
public abstract class Mob extends LivingEntity implements EquipmentUser, Leashable, Targeting {
|
||||
private static final EntityDataAccessor<Byte> DATA_MOB_FLAGS_ID = SynchedEntityData.defineId(Mob.class, EntityDataSerializers.BYTE);
|
||||
private static final int MOB_FLAG_NO_AI = 1;
|
||||
@@ -112,6 +_,7 @@
|
||||
@@ -115,6 +_,7 @@
|
||||
private final BodyRotationControl bodyRotationControl;
|
||||
protected PathNavigation navigation;
|
||||
public GoalSelector goalSelector;
|
||||
@ -23,15 +23,15 @@
|
||||
public GoalSelector targetSelector;
|
||||
@Nullable
|
||||
private LivingEntity target;
|
||||
@@ -126,6 +_,7 @@
|
||||
@@ -129,6 +_,7 @@
|
||||
private Leashable.LeashData leashData;
|
||||
private BlockPos restrictCenter = BlockPos.ZERO;
|
||||
private float restrictRadius = -1.0F;
|
||||
private BlockPos homePosition = BlockPos.ZERO;
|
||||
private int homeRadius = -1;
|
||||
+ public boolean aware = true; // CraftBukkit
|
||||
|
||||
protected Mob(EntityType<? extends Mob> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -142,6 +_,12 @@
|
||||
@@ -145,6 +_,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
protected void registerGoals() {
|
||||
}
|
||||
|
||||
@@ -222,7 +_,39 @@
|
||||
@@ -225,7 +_,39 @@
|
||||
}
|
||||
|
||||
public void setTarget(@Nullable LivingEntity target) {
|
||||
@ -84,40 +84,40 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -358,13 +_,22 @@
|
||||
@@ -365,13 +_,22 @@
|
||||
if (this.isNoAi()) {
|
||||
compound.putBoolean("NoAI", this.isNoAi());
|
||||
output.putBoolean("NoAI", this.isNoAi());
|
||||
}
|
||||
+ compound.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit
|
||||
+ output.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compound) {
|
||||
super.readAdditionalSaveData(compound);
|
||||
- this.setCanPickUpLoot(compound.getBooleanOr("CanPickUpLoot", false));
|
||||
- this.persistenceRequired = compound.getBooleanOr("PersistenceRequired", false);
|
||||
protected void readAdditionalSaveData(ValueInput input) {
|
||||
super.readAdditionalSaveData(input);
|
||||
- this.setCanPickUpLoot(input.getBooleanOr("CanPickUpLoot", false));
|
||||
- this.persistenceRequired = input.getBooleanOr("PersistenceRequired", false);
|
||||
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
|
||||
+ boolean canPickUpLoot = compound.getBooleanOr("CanPickUpLoot", false);
|
||||
+ if (isLevelAtLeast(compound, 1) || canPickUpLoot) {
|
||||
+ boolean canPickUpLoot = input.getBooleanOr("CanPickUpLoot", false);
|
||||
+ if (isLevelAtLeast(input, 1) || canPickUpLoot) {
|
||||
+ this.setCanPickUpLoot(canPickUpLoot);
|
||||
+ }
|
||||
+ boolean persistenceRequired = compound.getBooleanOr("PersistenceRequired", false);
|
||||
+ if (isLevelAtLeast(compound, 1) || persistenceRequired) {
|
||||
+ boolean persistenceRequired = input.getBooleanOr("PersistenceRequired", false);
|
||||
+ if (isLevelAtLeast(input, 1) || persistenceRequired) {
|
||||
+ this.persistenceRequired = persistenceRequired;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
RegistryOps<Tag> registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE);
|
||||
this.dropChances = compound.read("drop_chances", DropChances.CODEC, registryOps).orElse(DropChances.DEFAULT);
|
||||
this.readLeashData(compound);
|
||||
@@ -372,6 +_,7 @@
|
||||
this.lootTable = compound.read("DeathLootTable", LootTable.KEY_CODEC);
|
||||
this.lootTableSeed = compound.getLongOr("DeathLootTableSeed", 0L);
|
||||
this.setNoAi(compound.getBooleanOr("NoAI", false));
|
||||
+ this.aware = compound.getBooleanOr("Bukkit.Aware", true); // CraftBukkit
|
||||
this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT);
|
||||
this.readLeashData(input);
|
||||
this.homeRadius = input.getIntOr("home_radius", -1);
|
||||
@@ -383,6 +_,7 @@
|
||||
this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC);
|
||||
this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L);
|
||||
this.setNoAi(input.getBooleanOr("NoAI", false));
|
||||
+ this.aware = input.getBooleanOr("Bukkit.Aware", true); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -433,6 +_,11 @@
|
||||
@@ -446,6 +_,11 @@
|
||||
&& !itemEntity.getItem().isEmpty()
|
||||
&& !itemEntity.hasPickUpDelay()
|
||||
&& this.wantsToPickUp(serverLevel, itemEntity.getItem())) {
|
||||
@ -129,7 +129,7 @@
|
||||
this.pickUpItem(serverLevel, itemEntity);
|
||||
}
|
||||
}
|
||||
@@ -447,18 +_,24 @@
|
||||
@@ -460,18 +_,24 @@
|
||||
|
||||
protected void pickUpItem(ServerLevel level, ItemEntity entity) {
|
||||
ItemStack item = entity.getItem();
|
||||
@ -156,7 +156,7 @@
|
||||
EquipmentSlot equipmentSlotForItem = this.getEquipmentSlotForItem(stack);
|
||||
if (!this.isEquippableInSlot(stack, equipmentSlotForItem)) {
|
||||
return ItemStack.EMPTY;
|
||||
@@ -471,10 +_,18 @@
|
||||
@@ -484,10 +_,18 @@
|
||||
canReplaceCurrentItem = itemBySlot.isEmpty();
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@
|
||||
}
|
||||
|
||||
ItemStack itemStack = equipmentSlotForItem.limit(stack);
|
||||
@@ -591,22 +_,29 @@
|
||||
@@ -608,22 +_,29 @@
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
|
||||
@ -219,7 +219,7 @@
|
||||
this.noActionTime = 0;
|
||||
}
|
||||
}
|
||||
@@ -618,6 +_,15 @@
|
||||
@@ -635,6 +_,15 @@
|
||||
@Override
|
||||
protected final void serverAiStep() {
|
||||
this.noActionTime++;
|
||||
@ -235,7 +235,7 @@
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
profilerFiller.push("sensing");
|
||||
this.sensing.tick();
|
||||
@@ -793,14 +_,69 @@
|
||||
@@ -814,14 +_,69 @@
|
||||
public boolean stillValid(Player player) {
|
||||
return player.getVehicle() == Mob.this || player.canInteractWithEntity(Mob.this, 4.0);
|
||||
}
|
||||
@ -305,7 +305,7 @@
|
||||
ItemStack itemBySlot = this.getItemBySlot(equipmentSlot);
|
||||
float f = this.dropChances.byEquipment(equipmentSlot);
|
||||
if (f != 0.0F) {
|
||||
@@ -820,7 +_,13 @@
|
||||
@@ -841,7 +_,13 @@
|
||||
}
|
||||
|
||||
this.spawnAtLocation(level, itemBySlot);
|
||||
@ -319,7 +319,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -844,7 +_,9 @@
|
||||
@@ -865,7 +_,9 @@
|
||||
set.add(equipmentSlot);
|
||||
} else if (this.dropChances.isPreserved(equipmentSlot)) {
|
||||
this.setItemSlot(equipmentSlot, ItemStack.EMPTY);
|
||||
@ -329,7 +329,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1122,6 +_,21 @@
|
||||
@@ -1147,6 +_,21 @@
|
||||
public <T extends Mob> T convertTo(
|
||||
EntityType<T> entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion<T> afterConversion
|
||||
) {
|
||||
@ -351,7 +351,7 @@
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -1130,13 +_,23 @@
|
||||
@@ -1155,13 +_,23 @@
|
||||
return null;
|
||||
} else {
|
||||
conversionParams.type().convert(this, mob, conversionParams);
|
||||
@ -378,7 +378,7 @@
|
||||
}
|
||||
|
||||
return mob;
|
||||
@@ -1146,7 +_,18 @@
|
||||
@@ -1171,7 +_,18 @@
|
||||
|
||||
@Nullable
|
||||
public <T extends Mob> T convertTo(EntityType<T> entityType, ConversionParams coversionParams, ConversionParams.AfterConversion<T> afterConversion) {
|
||||
@ -398,7 +398,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1182,7 +_,17 @@
|
||||
@@ -1213,7 +_,17 @@
|
||||
public boolean startRiding(Entity entity, boolean force) {
|
||||
boolean flag = super.startRiding(entity, force);
|
||||
if (flag && this.isLeashed()) {
|
||||
@ -417,7 +417,7 @@
|
||||
}
|
||||
|
||||
return flag;
|
||||
@@ -1270,7 +_,7 @@
|
||||
@@ -1296,7 +_,7 @@
|
||||
float knockback = this.getKnockback(source, damageSource);
|
||||
if (knockback > 0.0F && source instanceof LivingEntity livingEntity) {
|
||||
livingEntity.knockback(
|
||||
|
||||
Reference in New Issue
Block a user