From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Mon, 21 Jun 2021 23:56:07 -0400 Subject: [PATCH] Missing Entity Behavior API Co-authored-by: Nassim Jahnke Co-authored-by: Jake Potrebic diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Bee.java +++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java @@ -0,0 +0,0 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { this.setFlag(4, hasStung); } + public net.kyori.adventure.util.TriState rollingOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Rolling override public boolean isRolling() { return this.getFlag(2); } public void setRolling(boolean nearTarget) { + nearTarget = rollingOverride.toBooleanOrElse(nearTarget); // Paper - Rolling override this.setFlag(2, nearTarget); } diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java @@ -0,0 +0,0 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, } + // Paper Start - Horse API + public void setMouthOpen(boolean open) { + this.setFlag(FLAG_OPEN_MOUTH, open); + } + public boolean isMouthOpen() { + return this.getFlag(FLAG_OPEN_MOUTH); + } + // Paper End - Horse API private void openMouth() { if (!this.level.isClientSide) { this.mouthCounter = 1; @@ -0,0 +0,0 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, this.setFlag(16, eatingGrass); } + // Paper Start - Horse API + public void setForceStanding(boolean standing) { + this.setFlag(FLAG_STANDING, standing); + } + // Paper End - Horse API public void setStanding(boolean angry) { if (angry) { this.setEating(false); diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java @@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob return entityliving.getMobType() != MobType.UNDEAD && entityliving.attackable(); }; private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0D).selector(WitherBoss.LIVING_ENTITY_SELECTOR); + // Paper start + private boolean canPortal = false; + + public void setCanTravelThroughPortals(boolean canPortal) { this.canPortal = canPortal; } + // Paper end public WitherBoss(EntityType type, Level world) { super(type, world); @@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob @Override public boolean canChangeDimensions() { - return false; + return super.canChangeDimensions() && canPortal; // Paper } @Override diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java @@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob { this.entityData.set(EnderMan.DATA_STARED_AT, true); } + // Paper start + public void setCreepy(boolean creepy) { + this.entityData.set(EnderMan.DATA_CREEPY, creepy); + } + + public void setHasBeenStaredAt(boolean hasBeenStaredAt) { + this.entityData.set(EnderMan.DATA_STARED_AT, hasBeenStaredAt); + } + // Paper end + @Override public boolean requiresCustomPersistence() { return super.requiresCustomPersistence() || this.getCarriedBlock() != null; diff --git a/src/main/java/net/minecraft/world/entity/monster/Ghast.java b/src/main/java/net/minecraft/world/entity/monster/Ghast.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Ghast.java +++ b/src/main/java/net/minecraft/world/entity/monster/Ghast.java @@ -0,0 +0,0 @@ public class Ghast extends FlyingMob implements Enemy { return this.explosionPower; } + // Paper start + public void setExplosionPower(int explosionPower) { + this.explosionPower = explosionPower; + } + // Paper end + @Override protected boolean shouldDespawnInPeaceful() { return true; diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java @@ -0,0 +0,0 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { } public void startConverting(@Nullable UUID uuid, int delay) { + // Paper start - missing entity behaviour api - converting without entity event + this.startConverting(uuid, delay, true); + } + + public void startConverting(@Nullable UUID uuid, int delay, boolean broadcastEntityEvent) { + // Paper end - missing entity behaviour api - converting without entity event this.conversionStarter = uuid; this.villagerConversionTime = delay; this.getEntityData().set(ZombieVillager.DATA_CONVERTING_ID, true); @@ -0,0 +0,0 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, delay, Math.min(this.level.getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit end - this.level.broadcastEntityEvent(this, (byte) 16); + if (broadcastEntityEvent) this.level.broadcastEntityEvent(this, (byte) 16); // Paper - missing entity behaviour api - converting without entity event } @Override diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java @@ -0,0 +0,0 @@ public class ThrownTrident extends AbstractArrow { return (Boolean) this.entityData.get(ThrownTrident.ID_FOIL); } + // Paper start + public void setFoil(boolean foil) { + this.entityData.set(ThrownTrident.ID_FOIL, foil); + } + + public int getLoyalty() { + return this.entityData.get(ThrownTrident.ID_LOYALTY); + } + + public void setLoyalty(byte loyalty) { + this.entityData.set(ThrownTrident.ID_LOYALTY, loyalty); + } + // Paper end + @Nullable @Override protected EntityHitResult findHitEntity(Vec3 currentPosition, Vec3 nextPosition) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -0,0 +0,0 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac public AbstractHorseInventory getInventory() { return new CraftSaddledInventory(getHandle().inventory); } + + // Paper start - Horse API + @Override + public boolean isEatingGrass() { + return this.getHandle().isEating(); + } + + @Override + public void setEatingGrass(boolean eating) { + this.getHandle().setEating(eating); + } + + @Override + public boolean isRearing() { + return this.getHandle().isStanding(); + } + + @Override + public void setRearing(boolean rearing) { + this.getHandle().setForceStanding(rearing); + } + + @Override + public boolean isEating() { + return this.getHandle().isMouthOpen(); + } + + @Override + public void setEating(boolean eating) { + this.getHandle().setMouthOpen(eating); + } + // Paper end - Horse API } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -0,0 +0,0 @@ public class CraftBee extends CraftAnimals implements Bee { public void setCannotEnterHiveTicks(int ticks) { this.getHandle().setStayOutOfHiveCountdown(ticks); } + // Paper start + @Override + public void setRollingOverride(net.kyori.adventure.util.TriState rolling) { + this.getHandle().rollingOverride = rolling; + + this.getHandle().setRolling(this.getHandle().isRolling()); // Refresh rolling state + } + + @Override + public boolean isRolling() { + return this.getRollingOverride().toBooleanOrElse(this.getHandle().isRolling()); + } + + @Override + public net.kyori.adventure.util.TriState getRollingOverride() { + return this.getHandle().rollingOverride; + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -0,0 +0,0 @@ public class CraftCat extends CraftTameableAnimal implements Cat { public void setCollarColor(DyeColor color) { this.getHandle().setCollarColor(net.minecraft.world.item.DyeColor.byId(color.getWoolData())); } + // Paper Start - More cat api + @Override + public void setLyingDown(boolean lyingDown) { + this.getHandle().setLying(lyingDown); + } + + @Override + public boolean isLyingDown() { + return this.getHandle().isLying(); + } + + @Override + public void setHeadUp(boolean headUp) { + this.getHandle().setRelaxStateOne(headUp); + } + + @Override + public boolean isHeadUp() { + return this.getHandle().isRelaxStateOne(); + } + // Paper End - More cat api } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -0,0 +0,0 @@ public class CraftEnderman extends CraftMonster implements Enderman { this.getHandle().setCarriedBlock(blockData == null ? null : ((CraftBlockData) blockData).getState()); } + // Paper start + @Override + public boolean isScreaming() { + return this.getHandle().isCreepy(); + } + + @Override + public void setScreaming(boolean screaming) { + this.getHandle().setCreepy(screaming); + } + + @Override + public boolean hasBeenStaredAt() { + return this.getHandle().hasBeenStaredAt(); + } + + @Override + public void setHasBeenStaredAt(boolean hasBeenStaredAt) { + this.getHandle().setHasBeenStaredAt(hasBeenStaredAt); + } + // Paper end + @Override public EnderMan getHandle() { return (EnderMan) entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -0,0 +0,0 @@ public class CraftFox extends CraftAnimals implements Fox { public boolean isFaceplanted() { return this.getHandle().isFaceplanted(); } + + // Paper start - Add more fox behavior API + @Override + public void setInterested(boolean interested) { + this.getHandle().setIsInterested(interested); + } + + @Override + public boolean isInterested() { + return this.getHandle().isInterested(); + } + + @Override + public void setLeaping(boolean leaping) { + this.getHandle().setIsPouncing(leaping); + } + + @Override + public boolean isLeaping() { + return this.getHandle().isPouncing(); + } + + @Override + public void setDefending(boolean defending) { + this.getHandle().setDefending(defending); + } + + @Override + public boolean isDefending() { + return this.getHandle().isDefending(); + } + + @Override + public void setFaceplanted(boolean faceplanted) { + this.getHandle().setFaceplanted(faceplanted); + } + // Paper end - Add more fox behavior API } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java @@ -0,0 +0,0 @@ public class CraftGhast extends CraftFlying implements Ghast { public void setCharging(boolean flag) { this.getHandle().setCharging(flag); } + + // Paper start + @Override + public int getExplosionPower() { + return this.getHandle().getExplosionPower(); + } + + @Override + public void setExplosionPower(int explosionPower) { + com.google.common.base.Preconditions.checkArgument(explosionPower >= 0 && explosionPower <= 127, "The explosion power has to be between 0 and 127"); + this.getHandle().setExplosionPower(explosionPower); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -0,0 +0,0 @@ public class CraftPanda extends CraftAnimals implements Panda { public void setHiddenGene(Gene gene) { this.getHandle().setHiddenGene(CraftPanda.toNms(gene)); } + // Paper start - Panda API + @Override + public void setSneezeTicks(int ticks) { + this.getHandle().setSneezeCounter(ticks); + } + + @Override + public int getSneezeTicks() { + return this.getHandle().getSneezeCounter(); + } + + @Override + public void setEatingTicks(int ticks) { + this.getHandle().setEatCounter(ticks); + } + + @Override + public int getEatingTicks() { + return this.getHandle().getEatCounter(); + } + + @Override + public void setUnhappyTicks(int ticks) { + this.getHandle().setUnhappyCounter(ticks); + } + // Paper end - Panda API @Override public boolean isRolling() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -0,0 +0,0 @@ public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.dest public String toString() { return "CraftPiglin"; } + // Paper start + @Override + public void setChargingCrossbow(boolean chargingCrossbow) { + this.getHandle().setChargingCrossbow(chargingCrossbow); + } + + @Override + public boolean isChargingCrossbow() { + return this.getHandle().isChargingCrossbow(); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java @@ -0,0 +0,0 @@ public class CraftPolarBear extends CraftAnimals implements PolarBear { public EntityType getType() { return EntityType.POLAR_BEAR; } + + // Paper start + @Override + public boolean isStanding() { + return this.getHandle().isStanding(); + } + + @Override + public void setStanding(boolean standing) { + this.getHandle().setStanding(standing); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -0,0 +0,0 @@ public abstract class CraftRaider extends CraftMonster implements Raider { public void setCanJoinRaid(boolean join) { this.getHandle().setCanJoinRaid(join); } + + // Paper start + @Override + public boolean isCelebrating() { + return this.getHandle().isCelebrating(); + } + + @Override + public void setCelebrating(boolean celebrating) { + this.getHandle().setCelebrating(celebrating); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -0,0 +0,0 @@ public class CraftTrident extends CraftArrow implements Trident { public EntityType getType() { return EntityType.TRIDENT; } + + // Paper start + @Override + public boolean hasGlint() { + return this.getHandle().isFoil(); + } + + @Override + public void setGlint(boolean glint) { + this.getHandle().setFoil(glint); + } + + @Override + public int getLoyaltyLevel() { + return this.getHandle().getLoyalty(); + } + + @Override + public void setLoyaltyLevel(int loyaltyLevel) { + com.google.common.base.Preconditions.checkArgument(loyaltyLevel >= 0 && loyaltyLevel <= 127, "The loyalty level has to be between 0 and 127"); + this.getHandle().setLoyalty((byte) loyaltyLevel); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -0,0 +0,0 @@ public class CraftVex extends CraftMonster implements Vex { public void setSummoner(org.bukkit.entity.Mob summoner) { getHandle().setOwner(summoner == null ? null : ((CraftMob) summoner).getHandle()); } + + @Override + public boolean hasLimitedLifetime() { + return this.getHandle().hasLimitedLife; + } + + @Override + public void setLimitedLifetime(boolean hasLimitedLifetime) { + this.getHandle().hasLimitedLife = hasLimitedLifetime; + } + + @Override + public int getLimitedLifetimeTicks() { + return this.getHandle().limitedLifeTicks; + } + + @Override + public void setLimitedLifetimeTicks(int ticks) { + this.getHandle().limitedLifeTicks = ticks; + } // Paper end @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -0,0 +0,0 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { @Override public void setConversionTime(int time) { + // Paper start - missing entity behaviour api - converting without entity event + this.setConversionTime(time, true); + } + + @Override + public void setConversionTime(int time, boolean broadcastEntityEvent) { + // Paper stop - missing entity behaviour api - converting without entity event if (time < 0) { this.getHandle().villagerConversionTime = -1; this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.ZombieVillager.DATA_CONVERTING_ID, false); this.getHandle().conversionStarter = null; this.getHandle().removeEffect(MobEffects.DAMAGE_BOOST, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); } else { - this.getHandle().startConverting((UUID) null, time); + this.getHandle().startConverting((UUID) null, time, broadcastEntityEvent); // Paper - missing entity behaviour api - converting without entity event } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -0,0 +0,0 @@ public class CraftWither extends CraftMonster implements Wither, com.destroystok Entity target = this.getHandle().getLevel().getEntity(entityId); return (target != null) ? (LivingEntity) target.getBukkitEntity() : null; } + + // Paper start + @Override + public boolean isCharged() { + return getHandle().isPowered(); + } + + @Override + public int getInvulnerableTicks() { + return getHandle().getInvulnerableTicks(); + } + + @Override + public void setInvulnerableTicks(int ticks) { + getHandle().setInvulnerableTicks(ticks); + } + + @Override + public boolean canTravelThroughPortals() { + return getHandle().canChangeDimensions(); + } + + @Override + public void setCanTravelThroughPortals(boolean value) { + getHandle().setCanTravelThroughPortals(value); + } + // Paper end }