More more entity classes
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
--- a/net/minecraft/world/entity/AgeableMob.java
|
||||
+++ b/net/minecraft/world/entity/AgeableMob.java
|
||||
@@ -20,11 +_,37 @@
|
||||
protected int age;
|
||||
protected int forcedAge;
|
||||
protected int forcedAgeTimer;
|
||||
+ public boolean ageLocked; // CraftBukkit
|
||||
|
||||
protected AgeableMob(EntityType<? extends AgeableMob> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
+ // Spigot start
|
||||
+ @Override
|
||||
+ public void inactiveTick()
|
||||
+ {
|
||||
+ super.inactiveTick();
|
||||
+ if ( this.level().isClientSide || this.ageLocked )
|
||||
+ { // CraftBukkit
|
||||
+ this.refreshDimensions();
|
||||
+ } else
|
||||
+ {
|
||||
+ int i = this.getAge();
|
||||
+
|
||||
+ if ( i < 0 )
|
||||
+ {
|
||||
+ ++i;
|
||||
+ this.setAge( i );
|
||||
+ } else if ( i > 0 )
|
||||
+ {
|
||||
+ --i;
|
||||
+ this.setAge( i );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
@Override
|
||||
public SpawnGroupData finalizeSpawn(
|
||||
ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData spawnGroupData
|
||||
@@ -66,6 +_,7 @@
|
||||
}
|
||||
|
||||
public void ageUp(int amount, boolean forced) {
|
||||
+ if (this.ageLocked) return; // Paper - Honor ageLock
|
||||
int age = this.getAge();
|
||||
age += amount * 20;
|
||||
if (age > 0) {
|
||||
@@ -104,6 +_,7 @@
|
||||
super.addAdditionalSaveData(tag);
|
||||
tag.putInt("Age", this.getAge());
|
||||
tag.putInt("ForcedAge", this.forcedAge);
|
||||
+ tag.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,6 +_,7 @@
|
||||
super.readAdditionalSaveData(tag);
|
||||
this.setAge(tag.getInt("Age"));
|
||||
this.forcedAge = tag.getInt("ForcedAge");
|
||||
+ this.ageLocked = tag.getBoolean("AgeLocked"); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,7 +_,7 @@
|
||||
@Override
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
- if (this.level().isClientSide) {
|
||||
+ if (this.level().isClientSide || this.ageLocked) { // CraftBukkit
|
||||
if (this.forcedAgeTimer > 0) {
|
||||
if (this.forcedAgeTimer % 4 == 0) {
|
||||
this.level().addParticle(ParticleTypes.HAPPY_VILLAGER, this.getRandomX(1.0), this.getRandomY() + 0.5, this.getRandomZ(1.0), 0.0, 0.0, 0.0);
|
||||
@@ -0,0 +1,117 @@
|
||||
--- a/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
+++ b/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
@@ -47,7 +_,7 @@
|
||||
public float radiusOnUse;
|
||||
public float radiusPerTick;
|
||||
@Nullable
|
||||
- private LivingEntity owner;
|
||||
+ private net.minecraft.world.entity.LivingEntity owner;
|
||||
@Nullable
|
||||
public UUID ownerUUID;
|
||||
|
||||
@@ -128,6 +_,18 @@
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
+ // Spigot start - copied from below
|
||||
+ @Override
|
||||
+ public void inactiveTick() {
|
||||
+ super.inactiveTick();
|
||||
+
|
||||
+ if (this.tickCount >= this.waitTime + this.duration) {
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
@@ -177,7 +_,7 @@
|
||||
|
||||
private void serverTick(ServerLevel level) {
|
||||
if (this.tickCount >= this.waitTime + this.duration) {
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
} else {
|
||||
boolean isWaiting = this.isWaiting();
|
||||
boolean flag = this.tickCount < this.waitTime;
|
||||
@@ -190,7 +_,7 @@
|
||||
if (this.radiusPerTick != 0.0F) {
|
||||
radius += this.radiusPerTick;
|
||||
if (radius < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,6 +_,7 @@
|
||||
list.addAll(this.potionContents.customEffects());
|
||||
List<LivingEntity> entitiesOfClass = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox());
|
||||
if (!entitiesOfClass.isEmpty()) {
|
||||
+ List<org.bukkit.entity.LivingEntity> entities = new java.util.ArrayList<>(); // CraftBukkit
|
||||
for (LivingEntity livingEntity : entitiesOfClass) {
|
||||
if (!this.victims.containsKey(livingEntity)
|
||||
&& livingEntity.isAffectedByPotions()
|
||||
@@ -228,6 +_,17 @@
|
||||
double d1 = livingEntity.getZ() - this.getZ();
|
||||
double d2 = d * d + d1 * d1;
|
||||
if (d2 <= radius * radius) {
|
||||
+ // CraftBukkit start
|
||||
+ entities.add((org.bukkit.entity.LivingEntity) livingEntity.getBukkitEntity());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ for (org.bukkit.entity.LivingEntity entity : event.getAffectedEntities()) {
|
||||
+ if (entity instanceof org.bukkit.craftbukkit.entity.CraftLivingEntity) {
|
||||
+ net.minecraft.world.entity.LivingEntity livingEntity = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity).getHandle();
|
||||
+ // CraftBukkit end
|
||||
this.victims.put(livingEntity, this.tickCount + this.reapplicationDelay);
|
||||
|
||||
for (MobEffectInstance mobEffectInstance1 : list) {
|
||||
@@ -236,14 +_,14 @@
|
||||
.value()
|
||||
.applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance1.getAmplifier(), 0.5);
|
||||
} else {
|
||||
- livingEntity.addEffect(new MobEffectInstance(mobEffectInstance1), this);
|
||||
+ livingEntity.addEffect(new MobEffectInstance(mobEffectInstance1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
if (this.radiusOnUse != 0.0F) {
|
||||
radius += this.radiusOnUse;
|
||||
if (radius < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -253,7 +_,7 @@
|
||||
if (this.durationOnUse != 0) {
|
||||
this.duration = this.duration + this.durationOnUse;
|
||||
if (this.duration <= 0) {
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -299,14 +_,14 @@
|
||||
this.waitTime = waitTime;
|
||||
}
|
||||
|
||||
- public void setOwner(@Nullable LivingEntity owner) {
|
||||
+ public void setOwner(@Nullable net.minecraft.world.entity.LivingEntity owner) {
|
||||
this.owner = owner;
|
||||
this.ownerUUID = owner == null ? null : owner.getUUID();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
- public LivingEntity getOwner() {
|
||||
+ public net.minecraft.world.entity.LivingEntity getOwner() {
|
||||
if (this.owner != null && !this.owner.isRemoved()) {
|
||||
return this.owner;
|
||||
} else {
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/world/entity/ConversionParams.java
|
||||
+++ b/net/minecraft/world/entity/ConversionParams.java
|
||||
@@ -12,4 +_,11 @@
|
||||
public interface AfterConversion<T extends Mob> {
|
||||
void finalizeConversion(T mob);
|
||||
}
|
||||
+
|
||||
+ // Paper start - entity zap event - allow conversion to be cancelled during finalization
|
||||
+ @FunctionalInterface
|
||||
+ public interface CancellingAfterConversion<T extends Mob> {
|
||||
+ boolean finalizeConversionOrCancel(final T convertedEntity);
|
||||
+ }
|
||||
+ // Paper start - entity zap event - allow conversion to be cancelled during finalization
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/ConversionType.java
|
||||
+++ b/net/minecraft/world/entity/ConversionType.java
|
||||
@@ -21,7 +_,7 @@
|
||||
|
||||
for (Entity entity : newMob.getPassengers()) {
|
||||
entity.stopRiding();
|
||||
- entity.remove(Entity.RemovalReason.DISCARDED);
|
||||
+ entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
firstPassenger.startRiding(newMob);
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/Display.java
|
||||
+++ b/net/minecraft/world/entity/Display.java
|
||||
@@ -213,7 +_,7 @@
|
||||
if (tag.contains("transformation")) {
|
||||
Transformation.EXTENDED_CODEC
|
||||
.decode(NbtOps.INSTANCE, tag.get("transformation"))
|
||||
- .resultOrPartial(Util.prefix("Display entity", LOGGER::error))
|
||||
+ .result() // Paper - Hide text display error on spawn
|
||||
.ifPresent(pair -> this.setTransformation(pair.getFirst()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
--- a/net/minecraft/world/entity/EntitySelector.java
|
||||
+++ b/net/minecraft/world/entity/EntitySelector.java
|
||||
@@ -16,6 +_,23 @@
|
||||
public static final Predicate<Entity> NO_SPECTATORS = entity -> !entity.isSpectator();
|
||||
public static final Predicate<Entity> CAN_BE_COLLIDED_WITH = NO_SPECTATORS.and(Entity::canBeCollidedWith);
|
||||
public static final Predicate<Entity> CAN_BE_PICKED = NO_SPECTATORS.and(Entity::isPickable);
|
||||
+ // Paper start - Ability to control player's insomnia and phantoms
|
||||
+ public static Predicate<Player> IS_INSOMNIAC = (player) -> {
|
||||
+ net.minecraft.server.level.ServerPlayer serverPlayer = (net.minecraft.server.level.ServerPlayer) player;
|
||||
+ int playerInsomniaTicks = serverPlayer.level().paperConfig().entities.behavior.playerInsomniaStartTicks;
|
||||
+
|
||||
+ if (playerInsomniaTicks <= 0) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return net.minecraft.util.Mth.clamp(serverPlayer.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= playerInsomniaTicks;
|
||||
+ };
|
||||
+ // Paper end - Ability to control player's insomnia and phantoms
|
||||
+ // Paper start - Affects Spawning API
|
||||
+ public static final Predicate<Entity> PLAYER_AFFECTS_SPAWNING = (entity) -> {
|
||||
+ return !entity.isSpectator() && entity.isAlive() && entity instanceof Player player && player.affectsSpawning;
|
||||
+ };
|
||||
+ // Paper end - Affects Spawning API
|
||||
|
||||
private EntitySelector() {
|
||||
}
|
||||
@@ -26,15 +_,20 @@
|
||||
}
|
||||
|
||||
public static Predicate<Entity> pushableBy(Entity entity) {
|
||||
+ // Paper start - Climbing should not bypass cramming gamerule
|
||||
+ return pushable(entity, false);
|
||||
+ }
|
||||
+ public static Predicate<Entity> pushable(Entity entity, boolean ignoreClimbing) {
|
||||
+ // Paper end - Climbing should not bypass cramming gamerule
|
||||
Team team = entity.getTeam();
|
||||
Team.CollisionRule collisionRule = team == null ? Team.CollisionRule.ALWAYS : team.getCollisionRule();
|
||||
return (Predicate<Entity>)(collisionRule == Team.CollisionRule.NEVER
|
||||
? Predicates.alwaysFalse()
|
||||
: NO_SPECTATORS.and(
|
||||
pushedEntity -> {
|
||||
- if (!pushedEntity.isPushable()) {
|
||||
+ if (!pushedEntity.isCollidable(ignoreClimbing) || !pushedEntity.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(pushedEntity)) { // CraftBukkit - collidable API // Paper - Climbing should not bypass cramming gamerule
|
||||
return false;
|
||||
- } else if (!entity.level().isClientSide || pushedEntity instanceof Player && ((Player)pushedEntity).isLocalPlayer()) {
|
||||
+ } else if (pushedEntity instanceof Player && entity instanceof Player && !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions) { // Paper - Configurable player collision
|
||||
Team team1 = pushedEntity.getTeam();
|
||||
Team.CollisionRule collisionRule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule();
|
||||
if (collisionRule1 == Team.CollisionRule.NEVER) {
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/entity/Interaction.java
|
||||
+++ b/net/minecraft/world/entity/Interaction.java
|
||||
@@ -130,9 +_,16 @@
|
||||
@Override
|
||||
public boolean skipAttackInteraction(Entity entity) {
|
||||
if (entity instanceof Player player) {
|
||||
+ // CraftBukkit start
|
||||
+ DamageSource source = player.damageSources().playerAttack(player);
|
||||
+ org.bukkit.event.entity.EntityDamageEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.attack = new Interaction.PlayerAction(player.getUUID(), this.level().getGameTime());
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, 1.0F, false);
|
||||
+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order
|
||||
}
|
||||
|
||||
return !this.getResponse();
|
||||
@@ -0,0 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/ItemBasedSteering.java
|
||||
+++ b/net/minecraft/world/entity/ItemBasedSteering.java
|
||||
@@ -51,6 +_,14 @@
|
||||
return this.entityData.get(this.boostTimeAccessor);
|
||||
}
|
||||
|
||||
+ // CraftBukkit add setBoostTicks(int)
|
||||
+ public void setBoostTicks(int ticks) {
|
||||
+ this.boosting = true;
|
||||
+ this.boostTime = 0;
|
||||
+ this.entityData.set(this.boostTimeAccessor, ticks);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void addAdditionalSaveData(CompoundTag nbt) {
|
||||
nbt.putBoolean("Saddle", this.hasSaddle());
|
||||
}
|
||||
Reference in New Issue
Block a user