More more entity classes
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/AgeableMob.java
|
||||
+++ b/net/minecraft/world/entity/AgeableMob.java
|
||||
@@ -21,12 +21,38 @@
|
||||
protected int age;
|
||||
protected int forcedAge;
|
||||
protected int forcedAgeTimer;
|
||||
+ public boolean ageLocked; // CraftBukkit
|
||||
|
||||
protected AgeableMob(EntityType<? extends AgeableMob> type, Level world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
+ // 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 world, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData entityData) {
|
||||
if (entityData == null) {
|
||||
entityData = new AgeableMob.AgeableMobGroupData(true);
|
||||
@@ -60,6 +86,7 @@
|
||||
}
|
||||
|
||||
public void ageUp(int age, boolean overGrow) {
|
||||
+ if (this.ageLocked) return; // Paper - Honor ageLock
|
||||
int j = this.getAge();
|
||||
int k = j;
|
||||
|
||||
@@ -104,6 +131,7 @@
|
||||
super.addAdditionalSaveData(nbt);
|
||||
nbt.putInt("Age", this.getAge());
|
||||
nbt.putInt("ForcedAge", this.forcedAge);
|
||||
+ nbt.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,6 +139,7 @@
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.setAge(nbt.getInt("Age"));
|
||||
this.forcedAge = nbt.getInt("ForcedAge");
|
||||
+ this.ageLocked = nbt.getBoolean("AgeLocked"); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,7 +154,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.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D);
|
||||
@@ -1,160 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
+++ b/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
@@ -33,6 +33,12 @@
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class AreaEffectCloud extends Entity implements TraceableEntity {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -54,7 +60,7 @@
|
||||
public float radiusOnUse;
|
||||
public float radiusPerTick;
|
||||
@Nullable
|
||||
- private LivingEntity owner;
|
||||
+ private net.minecraft.world.entity.LivingEntity owner;
|
||||
@Nullable
|
||||
public UUID ownerUUID;
|
||||
|
||||
@@ -145,7 +151,19 @@
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
+ // Spigot start - copied from below
|
||||
@Override
|
||||
+ public void inactiveTick() {
|
||||
+ super.inactiveTick();
|
||||
+
|
||||
+ if (this.tickCount >= this.waitTime + this.duration) {
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+
|
||||
+ @Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
Level world = this.level();
|
||||
@@ -200,7 +218,7 @@
|
||||
|
||||
private void serverTick(ServerLevel world) {
|
||||
if (this.tickCount >= this.waitTime + this.duration) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
} else {
|
||||
boolean flag = this.isWaiting();
|
||||
boolean flag1 = this.tickCount < this.waitTime;
|
||||
@@ -215,7 +233,7 @@
|
||||
if (this.radiusPerTick != 0.0F) {
|
||||
f += this.radiusPerTick;
|
||||
if (f < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -244,16 +262,17 @@
|
||||
}
|
||||
|
||||
list.addAll(this.potionContents.customEffects());
|
||||
- List<LivingEntity> list1 = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox());
|
||||
+ List<net.minecraft.world.entity.LivingEntity> list1 = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, this.getBoundingBox());
|
||||
|
||||
if (!list1.isEmpty()) {
|
||||
Iterator iterator1 = list1.iterator();
|
||||
|
||||
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
|
||||
while (iterator1.hasNext()) {
|
||||
- LivingEntity entityliving = (LivingEntity) iterator1.next();
|
||||
+ net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator1.next();
|
||||
|
||||
if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) {
|
||||
- Stream stream = list.stream();
|
||||
+ Stream<MobEffectInstance> stream = list.stream(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(entityliving);
|
||||
if (!stream.noneMatch(entityliving::canBeAffected)) {
|
||||
@@ -262,6 +281,19 @@
|
||||
double d2 = d0 * d0 + d1 * d1;
|
||||
|
||||
if (d2 <= (double) (f * f)) {
|
||||
+ // CraftBukkit start
|
||||
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ {
|
||||
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ for (LivingEntity entity : event.getAffectedEntities()) {
|
||||
+ if (entity instanceof CraftLivingEntity) {
|
||||
+ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) entity).getHandle();
|
||||
+ // CraftBukkit end
|
||||
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
|
||||
Iterator iterator2 = list.iterator();
|
||||
|
||||
@@ -271,14 +303,14 @@
|
||||
if (((MobEffect) mobeffect1.getEffect().value()).isInstantenous()) {
|
||||
((MobEffect) mobeffect1.getEffect().value()).applyInstantenousEffect(world, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
|
||||
} else {
|
||||
- entityliving.addEffect(new MobEffectInstance(mobeffect1), this);
|
||||
+ entityliving.addEffect(new MobEffectInstance(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
if (this.radiusOnUse != 0.0F) {
|
||||
f += this.radiusOnUse;
|
||||
if (f < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -288,7 +320,7 @@
|
||||
if (this.durationOnUse != 0) {
|
||||
this.duration += this.durationOnUse;
|
||||
if (this.duration <= 0) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -336,14 +368,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 {
|
||||
@@ -353,10 +385,10 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
Entity entity = worldserver.getEntity(this.ownerUUID);
|
||||
- LivingEntity entityliving;
|
||||
+ net.minecraft.world.entity.LivingEntity entityliving;
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
- LivingEntity entityliving1 = (LivingEntity) entity;
|
||||
+ if (entity instanceof net.minecraft.world.entity.LivingEntity) {
|
||||
+ net.minecraft.world.entity.LivingEntity entityliving1 = (net.minecraft.world.entity.LivingEntity) entity;
|
||||
|
||||
entityliving = entityliving1;
|
||||
} else {
|
||||
@@ -1,14 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/ConversionParams.java
|
||||
+++ b/net/minecraft/world/entity/ConversionParams.java
|
||||
@@ -12,4 +12,11 @@
|
||||
public interface AfterConversion<T extends Mob> {
|
||||
void finalizeConversion(T convertedEntity);
|
||||
}
|
||||
+
|
||||
+ // 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
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/ConversionType.java
|
||||
+++ b/net/minecraft/world/entity/ConversionType.java
|
||||
@@ -4,6 +4,7 @@
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.ai.Brain;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
@@ -11,6 +12,8 @@
|
||||
import net.minecraft.world.entity.monster.Zombie;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public enum ConversionType {
|
||||
|
||||
@@ -31,7 +34,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
entity1 = (Entity) iterator.next();
|
||||
entity1.stopRiding();
|
||||
- entity1.remove(Entity.RemovalReason.DISCARDED);
|
||||
+ entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
entity.startRiding(newEntity);
|
||||
@@ -64,7 +67,7 @@
|
||||
newEntity.hurtTime = oldEntity.hurtTime;
|
||||
newEntity.yBodyRot = oldEntity.yBodyRot;
|
||||
newEntity.setOnGround(oldEntity.onGround());
|
||||
- Optional optional = oldEntity.getSleepingPos();
|
||||
+ Optional<BlockPos> optional = oldEntity.getSleepingPos(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(newEntity);
|
||||
optional.ifPresent(newEntity::setSleepingPos);
|
||||
@@ -156,7 +159,7 @@
|
||||
newEntity.setNoGravity(oldEntity.isNoGravity());
|
||||
newEntity.setPortalCooldown(oldEntity.getPortalCooldown());
|
||||
newEntity.setSilent(oldEntity.isSilent());
|
||||
- Set set = oldEntity.getTags();
|
||||
+ Set<String> set = oldEntity.getTags(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(newEntity);
|
||||
set.forEach(newEntity::addTag);
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/Display.java
|
||||
+++ b/net/minecraft/world/entity/Display.java
|
||||
@@ -903,7 +903,7 @@
|
||||
b = loadFlag(b, nbt, "default_background", (byte)4);
|
||||
Optional<Display.TextDisplay.Align> optional = Display.TextDisplay.Align.CODEC
|
||||
.decode(NbtOps.INSTANCE, nbt.get("alignment"))
|
||||
- .resultOrPartial(Util.prefix("Display entity", Display.LOGGER::error))
|
||||
+ .result() // Paper - Hide text display error on spawn
|
||||
.map(Pair::getFirst);
|
||||
if (optional.isPresent()) {
|
||||
b = switch ((Display.TextDisplay.Align)optional.get()) {
|
||||
@@ -1,49 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/EntitySelector.java
|
||||
+++ b/net/minecraft/world/entity/EntitySelector.java
|
||||
@@ -27,8 +27,25 @@
|
||||
};
|
||||
public static final Predicate<Entity> CAN_BE_COLLIDED_WITH = EntitySelector.NO_SPECTATORS.and(Entity::canBeCollidedWith);
|
||||
public static final Predicate<Entity> CAN_BE_PICKED = EntitySelector.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
|
||||
+
|
||||
private EntitySelector() {}
|
||||
+ // 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
|
||||
|
||||
public static Predicate<Entity> withinDistance(double x, double y, double z, double max) {
|
||||
double d4 = max * max;
|
||||
@@ -39,13 +56,18 @@
|
||||
}
|
||||
|
||||
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
|
||||
PlayerTeam scoreboardteam = entity.getTeam();
|
||||
Team.CollisionRule scoreboardteambase_enumteampush = scoreboardteam == null ? Team.CollisionRule.ALWAYS : scoreboardteam.getCollisionRule();
|
||||
|
||||
return (Predicate) (scoreboardteambase_enumteampush == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : EntitySelector.NO_SPECTATORS.and((entity1) -> {
|
||||
- if (!entity1.isPushable()) {
|
||||
+ if (!entity1.isCollidable(ignoreClimbing) || !entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API // Paper - Climbing should not bypass cramming gamerule
|
||||
return false;
|
||||
- } else if (entity.level().isClientSide && (!(entity1 instanceof Player) || !((Player) entity1).isLocalPlayer())) {
|
||||
+ } else if (entity1 instanceof Player && entity instanceof Player && !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions) { // Paper - Configurable player collision
|
||||
return false;
|
||||
} else {
|
||||
PlayerTeam scoreboardteam1 = entity1.getTeam();
|
||||
@@ -1,42 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/Interaction.java
|
||||
+++ b/net/minecraft/world/entity/Interaction.java
|
||||
@@ -27,6 +27,12 @@
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.damagesource.DamageSource;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Interaction extends Entity implements Attackable, Targeting {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -65,7 +71,7 @@
|
||||
this.setHeight(nbt.getFloat("height"));
|
||||
}
|
||||
|
||||
- DataResult dataresult;
|
||||
+ DataResult<com.mojang.datafixers.util.Pair<Interaction.PlayerAction, net.minecraft.nbt.Tag>> dataresult; // CraftBukkit - decompile error
|
||||
Logger logger;
|
||||
|
||||
if (nbt.contains("attack")) {
|
||||
@@ -145,9 +151,16 @@
|
||||
@Override
|
||||
public boolean skipAttackInteraction(Entity attacker) {
|
||||
if (attacker instanceof Player entityhuman) {
|
||||
+ // CraftBukkit start
|
||||
+ DamageSource source = entityhuman.damageSources().playerAttack(entityhuman);
|
||||
+ EntityDamageEvent event = CraftEventFactory.callNonLivingEntityDamageEvent(this, source, 1.0F, false);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.attack = new Interaction.PlayerAction(entityhuman.getUUID(), this.level().getGameTime());
|
||||
if (entityhuman instanceof ServerPlayer entityplayer) {
|
||||
- CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, entityhuman.damageSources().generic(), 1.0F, 1.0F, false);
|
||||
+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(entityplayer, this, entityhuman.damageSources().generic(), 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order
|
||||
}
|
||||
|
||||
return !this.getResponse();
|
||||
@@ -1,17 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/ItemBasedSteering.java
|
||||
+++ b/net/minecraft/world/entity/ItemBasedSteering.java
|
||||
@@ -53,6 +53,14 @@
|
||||
return (Integer) 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