Normalizes CraftEntity#toString/getHandle (#12170)

This commit is contained in:
Lulu13022002 2025-05-01 03:21:04 +02:00 committed by GitHub
parent 567f63ae34
commit bc3d946fdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
172 changed files with 413 additions and 1174 deletions

View File

@ -18,27 +18,27 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca
private static final HandlerList HANDLER_LIST = new HandlerList();
private final AreaEffectCloud entity;
private final AreaEffectCloud effectCloud;
private boolean allowEmptyAreaEffectCreation;
private boolean cancelled;
@ApiStatus.Internal
@Deprecated(since = "1.20.2", forRemoval = true)
public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud entity) {
this(potion, null, null, null, entity);
public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud effectCloud) {
this(potion, null, null, null, effectCloud);
}
@ApiStatus.Internal
public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, @NotNull final AreaEffectCloud entity) {
public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, @NotNull final AreaEffectCloud effectCloud) {
super(potion, hitEntity, hitBlock, hitFace);
this.entity = entity;
this.effectCloud = effectCloud;
}
@NotNull
@Override
public ThrownPotion getEntity() {
return (ThrownPotion) super.getEntity();
return (ThrownPotion) this.entity;
}
/**
@ -48,10 +48,9 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca
*/
@NotNull
public AreaEffectCloud getAreaEffectCloud() {
return entity;
return effectCloud;
}
// Paper start
/**
* Sets if an Empty AreaEffectCloud may be created
*
@ -69,7 +68,6 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca
public boolean allowsEmptyCreation() {
return allowEmptyAreaEffectCreation;
}
// Paper end
@Override
public boolean isCancelled() {

View File

@ -13,7 +13,7 @@ public class PaperSchoolableFish extends CraftFish implements SchoolableFish {
@Override
public AbstractSchoolingFish getHandle() {
return (AbstractSchoolingFish) super.getHandle();
return (AbstractSchoolingFish) this.entity;
}
@Override

View File

@ -9,6 +9,11 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti
super(server, entity);
}
@Override
public net.minecraft.world.entity.projectile.Projectile getHandle() {
return (net.minecraft.world.entity.projectile.Projectile) this.entity;
}
@Override
public boolean doesBounce() {
return false;
@ -53,11 +58,6 @@ public abstract class AbstractProjectile extends CraftEntity implements Projecti
this.getHandle().preHitTargetOrDeflectSelf(new net.minecraft.world.phys.EntityHitResult(((CraftEntity) entity).getHandle(), new net.minecraft.world.phys.Vec3(vector.getX(), vector.getY(), vector.getZ())));
}
@Override
public net.minecraft.world.entity.projectile.Projectile getHandle() {
return (net.minecraft.world.entity.projectile.Projectile) entity;
}
@Override
public final org.bukkit.projectiles.ProjectileSource getShooter() {
this.getHandle().refreshProjectileSource(true); // Paper - Refresh ProjectileSource for projectiles

View File

@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import java.util.List;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.BlockCollisions;
@ -13,7 +14,6 @@ import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public abstract class CraftAbstractArrow extends AbstractProjectile implements AbstractArrow {
@ -21,6 +21,11 @@ public abstract class CraftAbstractArrow extends AbstractProjectile implements A
super(server, entity);
}
@Override
public net.minecraft.world.entity.projectile.AbstractArrow getHandle() {
return (net.minecraft.world.entity.projectile.AbstractArrow) this.entity;
}
@Override
public void setKnockbackStrength(int knockbackStrength) {
}
@ -63,8 +68,6 @@ public abstract class CraftAbstractArrow extends AbstractProjectile implements A
this.getHandle().setCritArrow(critical);
}
// Paper - moved to AbstractProjectile
@Override
public boolean isInBlock() {
return this.getHandle().isInGround();
@ -139,16 +142,6 @@ public abstract class CraftAbstractArrow extends AbstractProjectile implements A
this.getHandle().firedFromWeapon = CraftItemStack.asNMSCopy(item);
}
@Override
public net.minecraft.world.entity.projectile.AbstractArrow getHandle() {
return (net.minecraft.world.entity.projectile.AbstractArrow) this.entity;
}
@Override
public String toString() {
return "CraftAbstractArrow";
}
// Paper start
@Override
public CraftItemStack getItemStack() {

View File

@ -15,5 +15,4 @@ public abstract class CraftAbstractCow extends CraftAnimals implements AbstractC
public net.minecraft.world.entity.animal.AbstractCow getHandle() {
return (net.minecraft.world.entity.animal.AbstractCow) this.entity;
}
}

View File

@ -11,13 +11,13 @@ public abstract class CraftAbstractSkeleton extends CraftMonster implements Abst
}
@Override
public void setSkeletonType(Skeleton.SkeletonType type) {
throw new UnsupportedOperationException("Not supported.");
public net.minecraft.world.entity.monster.AbstractSkeleton getHandle() {
return (net.minecraft.world.entity.monster.AbstractSkeleton) this.entity;
}
@Override
public net.minecraft.world.entity.monster.AbstractSkeleton getHandle() {
return (net.minecraft.world.entity.monster.AbstractSkeleton) super.getHandle();
public void setSkeletonType(Skeleton.SkeletonType type) {
throw new UnsupportedOperationException("Not supported.");
}
@Override

View File

@ -25,11 +25,6 @@ public abstract class CraftAbstractVillager extends CraftAgeable implements Craf
return this.getHandle();
}
@Override
public String toString() {
return "CraftAbstractVillager";
}
@Override
public Inventory getInventory() {
return new CraftInventory(this.getHandle().getInventory());

View File

@ -9,19 +9,14 @@ public abstract class CraftAbstractWindCharge extends CraftFireball implements A
super(server, entity);
}
@Override
public void explode() {
this.getHandle().explode(this.getHandle().position());
this.getHandle().discard(EntityRemoveEvent.Cause.EXPLODE); // SPIGOT-7577 - explode doesn't discard the entity, this happens only in tick and onHitBlock
}
@Override
public net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge getHandle() {
return (net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge) this.entity;
}
@Override
public String toString() {
return "CraftAbstractWindCharge";
public void explode() {
this.getHandle().explode(this.getHandle().position());
this.getHandle().discard(EntityRemoveEvent.Cause.EXPLODE); // SPIGOT-7577 - explode doesn't discard the entity, this happens only in tick and onHitBlock
}
}

View File

@ -9,6 +9,11 @@ public class CraftAgeable extends CraftCreature implements Ageable {
super(server, entity);
}
@Override
public AgeableMob getHandle() {
return (AgeableMob) this.entity;
}
@Override
public int getAge() {
return this.getHandle().getAge();
@ -62,14 +67,4 @@ public class CraftAgeable extends CraftCreature implements Ageable {
this.setAge(6000);
}
}
@Override
public AgeableMob getHandle() {
return (AgeableMob) this.entity;
}
@Override
public String toString() {
return "CraftAgeable";
}
}

View File

@ -21,11 +21,6 @@ public class CraftAllay extends CraftCreature implements org.bukkit.entity.Allay
return (Allay) this.entity;
}
@Override
public String toString() {
return "CraftAllay";
}
@Override
public Inventory getInventory() {
return new CraftInventory(this.getHandle().getInventory());

View File

@ -13,9 +13,4 @@ public class CraftAmbient extends CraftMob implements Ambient {
public AmbientCreature getHandle() {
return (AmbientCreature) this.entity;
}
@Override
public String toString() {
return "CraftAmbient";
}
}

View File

@ -20,11 +20,6 @@ public class CraftAnimals extends CraftAgeable implements Animals {
return (Animal) this.entity;
}
@Override
public String toString() {
return "CraftAnimals";
}
@Override
public UUID getBreedCause() {
return this.getHandle().loveCause;

View File

@ -30,12 +30,7 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
@Override
public net.minecraft.world.entity.AreaEffectCloud getHandle() {
return (net.minecraft.world.entity.AreaEffectCloud) super.getHandle();
}
@Override
public String toString() {
return "CraftAreaEffectCloud";
return (net.minecraft.world.entity.AreaEffectCloud) this.entity;
}
@Override

View File

@ -13,7 +13,7 @@ public class CraftArmadillo extends CraftAnimals implements Armadillo {
@Override
public net.minecraft.world.entity.animal.armadillo.Armadillo getHandle() {
return (net.minecraft.world.entity.animal.armadillo.Armadillo) super.getHandle();
return (net.minecraft.world.entity.animal.armadillo.Armadillo) this.entity;
}
@Override
@ -38,11 +38,6 @@ public class CraftArmadillo extends CraftAnimals implements Armadillo {
this.getHandle().getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, ArmadilloState.UNROLLING.animationDuration());
}
@Override
public String toString() {
return "CraftArmadillo";
}
public static State stateToBukkit(ArmadilloState state) {
return switch (state) {
case IDLE -> State.IDLE;

View File

@ -15,14 +15,9 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
super(server, entity);
}
@Override
public String toString() {
return "CraftArmorStand";
}
@Override
public net.minecraft.world.entity.decoration.ArmorStand getHandle() {
return (net.minecraft.world.entity.decoration.ArmorStand) super.getHandle();
return (net.minecraft.world.entity.decoration.ArmorStand) this.entity;
}
@Override

View File

@ -29,11 +29,6 @@ public class CraftArrow extends CraftAbstractArrow implements Arrow {
return (net.minecraft.world.entity.projectile.Arrow) this.entity;
}
@Override
public String toString() {
return "CraftArrow";
}
@Override
public boolean addCustomEffect(PotionEffect effect, boolean override) {
if (this.hasCustomEffect(effect.getType())) {

View File

@ -12,12 +12,7 @@ public class CraftAxolotl extends CraftAnimals implements Axolotl, io.papermc.pa
@Override
public net.minecraft.world.entity.animal.axolotl.Axolotl getHandle() {
return (net.minecraft.world.entity.animal.axolotl.Axolotl) super.getHandle();
}
@Override
public String toString() {
return "CraftAxolotl";
return (net.minecraft.world.entity.animal.axolotl.Axolotl) this.entity;
}
@Override

View File

@ -14,11 +14,6 @@ public class CraftBat extends CraftAmbient implements Bat {
return (net.minecraft.world.entity.ambient.Bat) this.entity;
}
@Override
public String toString() {
return "CraftBat";
}
@Override
public boolean isAwake() {
return !this.getHandle().isResting();

View File

@ -18,11 +18,6 @@ public class CraftBee extends CraftAnimals implements Bee {
return (net.minecraft.world.entity.animal.Bee) this.entity;
}
@Override
public String toString() {
return "CraftBee";
}
@Override
public Location getHive() {
BlockPos hive = this.getHandle().getHivePos();

View File

@ -12,9 +12,4 @@ public class CraftBlaze extends CraftMonster implements Blaze {
public net.minecraft.world.entity.monster.Blaze getHandle() {
return (net.minecraft.world.entity.monster.Blaze) this.entity;
}
@Override
public String toString() {
return "CraftBlaze";
}
}

View File

@ -12,9 +12,4 @@ public class CraftBlockAttachedEntity extends CraftEntity {
public BlockAttachedEntity getHandle() {
return (BlockAttachedEntity) this.entity;
}
@Override
public String toString() {
return "CraftBlockAttachedEntity";
}
}

View File

@ -14,12 +14,7 @@ public class CraftBlockDisplay extends CraftDisplay implements BlockDisplay {
@Override
public net.minecraft.world.entity.Display.BlockDisplay getHandle() {
return (net.minecraft.world.entity.Display.BlockDisplay) super.getHandle();
}
@Override
public String toString() {
return "CraftBlockDisplay";
return (net.minecraft.world.entity.Display.BlockDisplay) this.entity;
}
@Override

View File

@ -1,12 +1,10 @@
package org.bukkit.craftbukkit.entity;
import java.util.stream.Collectors;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.vehicle.AbstractBoat;
import org.bukkit.TreeSpecies;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity;
public abstract class CraftBoat extends CraftVehicle implements Boat, io.papermc.paper.entity.PaperLeashable { // Paper - Leashable API
@ -14,6 +12,11 @@ public abstract class CraftBoat extends CraftVehicle implements Boat, io.papermc
super(server, entity);
}
@Override
public AbstractBoat getHandle() {
return (AbstractBoat) this.entity;
}
@Override
public TreeSpecies getWoodType() {
return CraftBoat.getTreeSpecies(this.getHandle().getType());
@ -99,16 +102,6 @@ public abstract class CraftBoat extends CraftVehicle implements Boat, io.papermc
return CraftBoat.boatStatusFromNms(this.getHandle().status);
}
@Override
public AbstractBoat getHandle() {
return (AbstractBoat) this.entity;
}
@Override
public String toString() {
return "CraftBoat{boatType=" + this.getBoatType() + ",status=" + this.getStatus() + ",passengers=" + this.getPassengers().stream().map(Entity::toString).collect(Collectors.joining("-", "{", "}")) + "}";
}
public static Boat.Type boatTypeFromNms(EntityType<?> boatType) {
if (boatType == EntityType.OAK_BOAT || boatType == EntityType.OAK_CHEST_BOAT) {
return Type.OAK;

View File

@ -15,11 +15,6 @@ public class CraftBogged extends CraftAbstractSkeleton implements Bogged, io.pap
return (net.minecraft.world.entity.monster.Bogged) this.entity;
}
@Override
public String toString() {
return "CraftBogged";
}
@Override
public Skeleton.SkeletonType getSkeletonType() {
return Skeleton.SkeletonType.BOGGED;

View File

@ -22,9 +22,4 @@ public class CraftBreeze extends CraftMonster implements Breeze {
net.minecraft.world.entity.LivingEntity entityLivingTarget = (target instanceof CraftLivingEntity craftLivingEntity) ? craftLivingEntity.getHandle() : null;
this.getHandle().getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityLivingTarget); // SPIGOT-7957: We need override memory for set target and trigger attack behaviours
}
@Override
public String toString() {
return "CraftBreeze";
}
}

View File

@ -12,9 +12,4 @@ public class CraftBreezeWindCharge extends CraftAbstractWindCharge implements Br
public net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge getHandle() {
return (net.minecraft.world.entity.projectile.windcharge.BreezeWindCharge) this.entity;
}
@Override
public String toString() {
return "CraftBreezeWindCharge";
}
}

View File

@ -13,12 +13,7 @@ public class CraftCamel extends CraftAbstractHorse implements Camel {
@Override
public net.minecraft.world.entity.animal.camel.Camel getHandle() {
return (net.minecraft.world.entity.animal.camel.Camel) super.getHandle();
}
@Override
public String toString() {
return "CraftCamel";
return (net.minecraft.world.entity.animal.camel.Camel) this.entity;
}
@Override

View File

@ -20,12 +20,7 @@ public class CraftCat extends CraftTameableAnimal implements Cat {
@Override
public net.minecraft.world.entity.animal.Cat getHandle() {
return (net.minecraft.world.entity.animal.Cat) super.getHandle();
}
@Override
public String toString() {
return "CraftCat";
return (net.minecraft.world.entity.animal.Cat) this.entity;
}
@Override

View File

@ -12,9 +12,4 @@ public class CraftCaveSpider extends CraftSpider implements CaveSpider {
public net.minecraft.world.entity.monster.CaveSpider getHandle() {
return (net.minecraft.world.entity.monster.CaveSpider) this.entity;
}
@Override
public String toString() {
return "CraftCaveSpider";
}
}

View File

@ -18,11 +18,6 @@ public abstract class CraftChestBoat extends CraftBoat implements org.bukkit.ent
return (AbstractChestBoat) this.entity;
}
@Override
public String toString() {
return "CraftChestBoat";
}
@Override
public Inventory getInventory() {
return this.inventory;

View File

@ -12,7 +12,7 @@ public abstract class CraftChestedHorse extends CraftAbstractHorse implements Ch
@Override
public AbstractChestedHorse getHandle() {
return (AbstractChestedHorse) super.getHandle();
return (AbstractChestedHorse) this.entity;
}
@Override

View File

@ -22,11 +22,6 @@ public class CraftChicken extends CraftAnimals implements Chicken {
return (net.minecraft.world.entity.animal.Chicken) this.entity;
}
@Override
public String toString() {
return "CraftChicken";
}
@Override
public Variant getVariant() {
return CraftVariant.minecraftHolderToBukkit(this.getHandle().getVariant());

View File

@ -11,11 +11,6 @@ public class CraftCod extends io.papermc.paper.entity.PaperSchoolableFish implem
@Override
public net.minecraft.world.entity.animal.Cod getHandle() {
return (net.minecraft.world.entity.animal.Cod) super.getHandle();
}
@Override
public String toString() {
return "CraftCod";
return (net.minecraft.world.entity.animal.Cod) this.entity;
}
}

View File

@ -1,20 +1,25 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.world.entity.boss.EnderDragonPart;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.ComplexEntityPart;
import org.bukkit.entity.ComplexLivingEntity;
import org.bukkit.event.entity.EntityDamageEvent;
public class CraftComplexPart extends CraftEntity implements ComplexEntityPart {
public CraftComplexPart(CraftServer server, EnderDragonPart entity) {
super(server, entity);
}
@Override
public EnderDragonPart getHandle() {
return (EnderDragonPart) this.entity;
}
@Override
public ComplexLivingEntity getParent() {
return (ComplexLivingEntity) ((EnderDragon) this.getHandle().parentMob).getBukkitEntity();
return (ComplexLivingEntity) this.getHandle().parentMob.getBukkitEntity();
}
@Override
@ -31,14 +36,4 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart {
public boolean isValid() {
return this.getParent().isValid();
}
@Override
public EnderDragonPart getHandle() {
return (EnderDragonPart) this.entity;
}
@Override
public String toString() {
return "CraftComplexPart";
}
}

View File

@ -22,11 +22,6 @@ public class CraftCow extends CraftAbstractCow implements Cow {
return (net.minecraft.world.entity.animal.Cow) this.entity;
}
@Override
public String toString() {
return "CraftCow";
}
@Override
public Variant getVariant() {
return CraftVariant.minecraftHolderToBukkit(this.getHandle().getVariant());

View File

@ -43,9 +43,4 @@ public class CraftCreaking extends CraftMonster implements org.bukkit.entity.Cre
public boolean isActive() {
return this.getHandle().isActive();
}
@Override
public String toString() {
return "CraftCreaking";
}
}

View File

@ -13,9 +13,4 @@ public class CraftCreature extends CraftMob implements Creature {
public PathfinderMob getHandle() {
return (PathfinderMob) this.entity;
}
@Override
public String toString() {
return "CraftCreature";
}
}

View File

@ -12,6 +12,11 @@ public class CraftCreeper extends CraftMonster implements Creeper {
super(server, entity);
}
@Override
public net.minecraft.world.entity.monster.Creeper getHandle() {
return (net.minecraft.world.entity.monster.Creeper) this.entity;
}
@Override
public boolean isPowered() {
return this.getHandle().isPowered();
@ -92,16 +97,6 @@ public class CraftCreeper extends CraftMonster implements Creeper {
return (this.getHandle().entityIgniter != null) ? this.getHandle().entityIgniter.getBukkitEntity() : null;
}
@Override
public net.minecraft.world.entity.monster.Creeper getHandle() {
return (net.minecraft.world.entity.monster.Creeper) this.entity;
}
@Override
public String toString() {
return "CraftCreeper";
}
// Paper start
@Override
public void setIgnited(boolean ignited) {

View File

@ -14,12 +14,7 @@ public class CraftDisplay extends CraftEntity implements Display {
@Override
public net.minecraft.world.entity.Display getHandle() {
return (net.minecraft.world.entity.Display) super.getHandle();
}
@Override
public String toString() {
return "CraftDisplay";
return (net.minecraft.world.entity.Display) this.entity;
}
@Override

View File

@ -13,12 +13,7 @@ public class CraftDolphin extends CraftAgeable implements Dolphin {
@Override
public net.minecraft.world.entity.animal.Dolphin getHandle() {
return (net.minecraft.world.entity.animal.Dolphin) super.getHandle();
}
@Override
public String toString() {
return "CraftDolphin";
return (net.minecraft.world.entity.animal.Dolphin) this.entity;
}
@Override

View File

@ -10,11 +10,6 @@ public class CraftDonkey extends CraftChestedHorse implements Donkey {
super(server, entity);
}
@Override
public String toString() {
return "CraftDonkey";
}
@Override
public Variant getVariant() {
return Variant.DONKEY;

View File

@ -4,12 +4,8 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.DragonFireball;
public class CraftDragonFireball extends CraftFireball implements DragonFireball {
public CraftDragonFireball(CraftServer server, net.minecraft.world.entity.projectile.DragonFireball entity) {
super(server, entity);
}
@Override
public String toString() {
return "CraftDragonFireball";
}
}

View File

@ -13,9 +13,4 @@ public class CraftDrowned extends CraftZombie implements Drowned, com.destroysto
public net.minecraft.world.entity.monster.Drowned getHandle() {
return (net.minecraft.world.entity.monster.Drowned) this.entity;
}
@Override
public String toString() {
return "CraftDrowned";
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Egg;
public class CraftEgg extends CraftThrowableProjectile implements Egg {
public CraftEgg(CraftServer server, ThrownEgg entity) {
super(server, entity);
}
@ -13,9 +14,4 @@ public class CraftEgg extends CraftThrowableProjectile implements Egg {
public ThrownEgg getHandle() {
return (ThrownEgg) this.entity;
}
@Override
public String toString() {
return "CraftEgg";
}
}

View File

@ -9,11 +9,6 @@ public class CraftElderGuardian extends CraftGuardian implements ElderGuardian {
super(server, entity);
}
@Override
public String toString() {
return "CraftElderGuardian";
}
@Override
public boolean isElder() {
return true;

View File

@ -8,10 +8,16 @@ import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.entity.EnderCrystal;
public class CraftEnderCrystal extends CraftEntity implements EnderCrystal {
public CraftEnderCrystal(CraftServer server, EndCrystal entity) {
super(server, entity);
}
@Override
public EndCrystal getHandle() {
return (EndCrystal) this.entity;
}
@Override
public boolean isShowingBottom() {
return this.getHandle().showsBottom();
@ -38,14 +44,4 @@ public class CraftEnderCrystal extends CraftEntity implements EnderCrystal {
this.getHandle().setBeamTarget(CraftLocation.toBlockPosition(location));
}
}
@Override
public EndCrystal getHandle() {
return (EndCrystal) this.entity;
}
@Override
public String toString() {
return "CraftEnderCrystal";
}
}

View File

@ -20,6 +20,11 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem
super(server, entity);
}
@Override
public net.minecraft.world.entity.boss.enderdragon.EnderDragon getHandle() {
return (net.minecraft.world.entity.boss.enderdragon.EnderDragon) this.entity;
}
@Override
public Set<ComplexEntityPart> getParts() {
Builder<ComplexEntityPart> builder = ImmutableSet.builder();
@ -31,16 +36,6 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem
return builder.build();
}
@Override
public net.minecraft.world.entity.boss.enderdragon.EnderDragon getHandle() {
return (net.minecraft.world.entity.boss.enderdragon.EnderDragon) this.entity;
}
@Override
public String toString() {
return "CraftEnderDragon";
}
@Override
public Phase getPhase() {
return Phase.values()[this.getHandle().getEntityData().get(net.minecraft.world.entity.boss.enderdragon.EnderDragon.DATA_PHASE)];

View File

@ -16,16 +16,6 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago
return (EnderDragon) super.getParent();
}
@Override
public net.minecraft.world.entity.boss.EnderDragonPart getHandle() {
return (net.minecraft.world.entity.boss.EnderDragonPart) this.entity;
}
@Override
public String toString() {
return "CraftEnderDragonPart";
}
@Override
public void damage(double amount, DamageSource damageSource) {
this.getParent().damage(amount, damageSource);

View File

@ -13,9 +13,4 @@ public class CraftEnderPearl extends CraftThrowableProjectile implements EnderPe
public ThrownEnderpearl getHandle() {
return (ThrownEnderpearl) this.entity;
}
@Override
public String toString() {
return "CraftEnderPearl";
}
}

View File

@ -20,11 +20,6 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
return (EyeOfEnder) this.entity;
}
@Override
public String toString() {
return "CraftEnderSignal";
}
@Override
public Location getTargetLocation() {
return new Location(this.getWorld(), this.getHandle().tx, this.getHandle().ty, this.getHandle().tz, this.getHandle().getYRot(), this.getHandle().getXRot());

View File

@ -13,11 +13,21 @@ import org.bukkit.entity.Entity;
import org.bukkit.material.MaterialData;
public class CraftEnderman extends CraftMonster implements Enderman {
public CraftEnderman(CraftServer server, EnderMan entity) {
super(server, entity);
}
@Override public boolean teleportRandomly() { return getHandle().teleport(); } // Paper
@Override
public EnderMan getHandle() {
return (EnderMan) this.entity;
}
@Override
public boolean teleportRandomly() {
return getHandle().teleport();
}
@Override
public MaterialData getCarriedMaterial() {
BlockState blockData = this.getHandle().getCarriedBlock();
@ -60,16 +70,6 @@ public class CraftEnderman extends CraftMonster implements Enderman {
this.getHandle().setHasBeenStaredAt(hasBeenStaredAt);
}
@Override
public EnderMan getHandle() {
return (EnderMan) this.entity;
}
@Override
public String toString() {
return "CraftEnderman";
}
@Override
public boolean teleport() {
return this.getHandle().teleport();

View File

@ -11,12 +11,7 @@ public class CraftEndermite extends CraftMonster implements Endermite {
@Override
public net.minecraft.world.entity.monster.Endermite getHandle() {
return (net.minecraft.world.entity.monster.Endermite) super.getHandle();
}
@Override
public String toString() {
return "CraftEndermite";
return (net.minecraft.world.entity.monster.Endermite) this.entity;
}
@Override

View File

@ -124,6 +124,38 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));
}
public Entity getHandle() {
return this.entity;
}
public Entity getHandleRaw() {
return this.entity;
}
public void setHandle(final Entity entity) {
this.entity = entity;
}
@Override
public String toString() {
return this.getClass().getSimpleName() + "{uuid=" + this.getUniqueId() + '}';
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
final CraftEntity other = (CraftEntity) obj;
return this.entity == other.entity; // There should never be duplicate entities with differing references
}
@Override
public int hashCode() {
// The UUID and thus hash code should never change (unlike the entity id)
return this.getUniqueId().hashCode();
}
@Override
public Location getLocation() {
return CraftLocation.toBukkit(this.entity.position(), this.getWorld(), this.entity.getBukkitYaw(), this.entity.getXRot());
@ -524,14 +556,6 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
this.getHandle().totalEntityAge = value;
}
public Entity getHandle() {
return this.entity;
}
public Entity getHandleRaw() {
return this.entity;
}
@Override
public final EntityType getType() {
return this.entityType;
@ -561,30 +585,6 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return CraftSound.minecraftToBukkit(this.getHandle().getSwimHighSpeedSplashSound());
}
public void setHandle(final Entity entity) {
this.entity = entity;
}
@Override
public String toString() {
return "CraftEntity{" + "id=" + this.getEntityId() + '}';
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
final CraftEntity other = (CraftEntity) obj;
return this.entity == other.entity; // There should never be duplicate entities with differing references
}
@Override
public int hashCode() {
// The UUID and thus hash code should never change (unlike the entity id)
return this.getUniqueId().hashCode();
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
this.server.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);

View File

@ -13,12 +13,7 @@ public class CraftEvoker extends CraftSpellcaster implements Evoker {
@Override
public net.minecraft.world.entity.monster.Evoker getHandle() {
return (net.minecraft.world.entity.monster.Evoker) super.getHandle();
}
@Override
public String toString() {
return "CraftEvoker";
return (net.minecraft.world.entity.monster.Evoker) this.entity;
}
@Override

View File

@ -13,12 +13,7 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs {
@Override
public net.minecraft.world.entity.projectile.EvokerFangs getHandle() {
return (net.minecraft.world.entity.projectile.EvokerFangs) super.getHandle();
}
@Override
public String toString() {
return "CraftEvokerFangs";
return (net.minecraft.world.entity.projectile.EvokerFangs) this.entity;
}
@Override

View File

@ -5,10 +5,16 @@ import org.bukkit.entity.ExperienceOrb;
import java.util.UUID;
public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb {
public CraftExperienceOrb(CraftServer server, net.minecraft.world.entity.ExperienceOrb entity) {
super(server, entity);
}
@Override
public net.minecraft.world.entity.ExperienceOrb getHandle() {
return (net.minecraft.world.entity.ExperienceOrb) this.entity;
}
@Override
public int getExperience() {
return this.getHandle().getValue();
@ -43,14 +49,4 @@ public class CraftExperienceOrb extends CraftEntity implements ExperienceOrb {
public SpawnReason getSpawnReason() {
return this.getHandle().spawnReason;
}
@Override
public net.minecraft.world.entity.ExperienceOrb getHandle() {
return (net.minecraft.world.entity.ExperienceOrb) this.entity;
}
@Override
public String toString() {
return "CraftExperienceOrb";
}
}

View File

@ -19,11 +19,6 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
return (FallingBlockEntity) this.entity;
}
@Override
public String toString() {
return "CraftFallingBlock";
}
@Override
public Material getMaterial() {
return this.getBlockData().getMaterial();

View File

@ -9,10 +9,16 @@ import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class CraftFireball extends AbstractProjectile implements Fireball {
public CraftFireball(CraftServer server, AbstractHurtingProjectile entity) {
super(server, entity);
}
@Override
public AbstractHurtingProjectile getHandle() {
return (AbstractHurtingProjectile) this.entity;
}
@Override
public float getYield() {
return this.getHandle().bukkitYield;
@ -78,14 +84,4 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
return this.getAcceleration();
}
// Paper end - Expose power on fireball projectiles
@Override
public AbstractHurtingProjectile getHandle() {
return (AbstractHurtingProjectile) this.entity;
}
@Override
public String toString() {
return "CraftFireball";
}
}

View File

@ -23,11 +23,6 @@ public class CraftFirework extends CraftProjectile implements Firework {
return (FireworkRocketEntity) this.entity;
}
@Override
public String toString() {
return "CraftFirework";
}
@Override
public FireworkMeta getFireworkMeta() {
return (FireworkMeta) CraftItemStack.getItemMeta(this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM), org.bukkit.inventory.ItemType.FIREWORK_ROCKET); // Paper - Expose firework item directly

View File

@ -14,9 +14,4 @@ public class CraftFish extends CraftWaterMob implements Fish, io.papermc.paper.e
public AbstractFish getHandle() {
return (AbstractFish) this.entity;
}
@Override
public String toString() {
return "CraftFish";
}
}

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.FishHook;
import org.bukkit.inventory.EquipmentSlot;
public class CraftFishHook extends CraftProjectile implements FishHook {
private double biteChance = -1;
public CraftFishHook(CraftServer server, FishingHook entity) {
@ -25,11 +26,6 @@ public class CraftFishHook extends CraftProjectile implements FishHook {
return (FishingHook) this.entity;
}
@Override
public String toString() {
return "CraftFishingHook";
}
@Override
public int getMinWaitTime() {
return this.getHandle().minWaitTime;

View File

@ -14,9 +14,4 @@ public class CraftFlying extends CraftMob implements Flying {
public FlyingMob getHandle() {
return (FlyingMob) this.entity;
}
@Override
public String toString() {
return "CraftFlying";
}
}

View File

@ -17,12 +17,7 @@ public class CraftFox extends CraftAnimals implements Fox {
@Override
public net.minecraft.world.entity.animal.Fox getHandle() {
return (net.minecraft.world.entity.animal.Fox) super.getHandle();
}
@Override
public String toString() {
return "CraftFox";
return (net.minecraft.world.entity.animal.Fox) this.entity;
}
@Override

View File

@ -23,11 +23,6 @@ public class CraftFrog extends CraftAnimals implements org.bukkit.entity.Frog {
return (Frog) this.entity;
}
@Override
public String toString() {
return "CraftFrog";
}
@Override
public Entity getTongueTarget() {
return this.getHandle().getTongueTarget().map(net.minecraft.world.entity.Entity::getBukkitEntity).orElse(null);

View File

@ -14,11 +14,6 @@ public class CraftGhast extends CraftFlying implements Ghast, CraftEnemy {
return (net.minecraft.world.entity.monster.Ghast) this.entity;
}
@Override
public String toString() {
return "CraftGhast";
}
@Override
public boolean isCharging() {
return this.getHandle().isCharging();

View File

@ -13,9 +13,4 @@ public class CraftGiant extends CraftMonster implements Giant {
public net.minecraft.world.entity.monster.Giant getHandle() {
return (net.minecraft.world.entity.monster.Giant) this.entity;
}
@Override
public String toString() {
return "CraftGiant";
}
}

View File

@ -11,11 +11,6 @@ public class CraftGlowItemFrame extends CraftItemFrame implements GlowItemFrame
@Override
public net.minecraft.world.entity.decoration.GlowItemFrame getHandle() {
return (net.minecraft.world.entity.decoration.GlowItemFrame) super.getHandle();
}
@Override
public String toString() {
return "CraftGlowItemFrame{item=" + this.getItem() + ", rotation=" + this.getRotation() + "}";
return (net.minecraft.world.entity.decoration.GlowItemFrame) this.entity;
}
}

View File

@ -12,12 +12,7 @@ public class CraftGlowSquid extends CraftSquid implements GlowSquid {
@Override
public net.minecraft.world.entity.GlowSquid getHandle() {
return (net.minecraft.world.entity.GlowSquid) super.getHandle();
}
@Override
public String toString() {
return "CraftGlowSquid";
return (net.minecraft.world.entity.GlowSquid) this.entity;
}
@Override

View File

@ -11,12 +11,7 @@ public class CraftGoat extends CraftAnimals implements Goat {
@Override
public net.minecraft.world.entity.animal.goat.Goat getHandle() {
return (net.minecraft.world.entity.animal.goat.Goat) super.getHandle();
}
@Override
public String toString() {
return "CraftGoat";
return (net.minecraft.world.entity.animal.goat.Goat) this.entity;
}
@Override

View File

@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Golem;
public class CraftGolem extends CraftCreature implements Golem {
public CraftGolem(CraftServer server, AbstractGolem entity) {
super(server, entity);
}
@ -13,9 +14,4 @@ public class CraftGolem extends CraftCreature implements Golem {
public AbstractGolem getHandle() {
return (AbstractGolem) this.entity;
}
@Override
public String toString() {
return "CraftGolem";
}
}

View File

@ -15,12 +15,7 @@ public class CraftGuardian extends CraftMonster implements Guardian {
@Override
public net.minecraft.world.entity.monster.Guardian getHandle() {
return (net.minecraft.world.entity.monster.Guardian) super.getHandle();
}
@Override
public String toString() {
return "CraftGuardian";
return (net.minecraft.world.entity.monster.Guardian) this.entity;
}
@Override

View File

@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.entity.Hanging;
public class CraftHanging extends CraftBlockAttachedEntity implements Hanging {
public CraftHanging(CraftServer server, HangingEntity entity) {
super(server, entity);
}
@ -61,9 +62,4 @@ public class CraftHanging extends CraftBlockAttachedEntity implements Hanging {
public HangingEntity getHandle() {
return (HangingEntity) this.entity;
}
@Override
public String toString() {
return "CraftHanging";
}
}

View File

@ -10,6 +10,11 @@ public class CraftHoglin extends CraftAnimals implements Hoglin, CraftEnemy {
super(server, entity);
}
@Override
public net.minecraft.world.entity.monster.hoglin.Hoglin getHandle() {
return (net.minecraft.world.entity.monster.hoglin.Hoglin) this.entity;
}
@Override
public boolean isImmuneToZombification() {
return this.getHandle().isImmuneToZombification();
@ -50,14 +55,4 @@ public class CraftHoglin extends CraftAnimals implements Hoglin, CraftEnemy {
public boolean isConverting() {
return this.getHandle().isConverting();
}
@Override
public net.minecraft.world.entity.monster.hoglin.Hoglin getHandle() {
return (net.minecraft.world.entity.monster.hoglin.Hoglin) this.entity;
}
@Override
public String toString() {
return "CraftHoglin";
}
}

View File

@ -16,7 +16,7 @@ public class CraftHorse extends CraftAbstractHorse implements Horse {
@Override
public net.minecraft.world.entity.animal.horse.Horse getHandle() {
return (net.minecraft.world.entity.animal.horse.Horse) super.getHandle();
return (net.minecraft.world.entity.animal.horse.Horse) this.entity;
}
@Override
@ -63,9 +63,4 @@ public class CraftHorse extends CraftAbstractHorse implements Horse {
this.getHandle().createEquipmentSlotContainer(EquipmentSlot.SADDLE)
);
}
@Override
public String toString() {
return "CraftHorse{variant=" + this.getVariant() + ", owner=" + this.getOwner() + '}';
}
}

View File

@ -80,6 +80,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private CraftInventoryPlayer inventory;
private final CraftInventory enderChest;
protected final PermissibleBase perm = new PermissibleBase(this);
@ -93,6 +94,21 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
this.enderChest = new CraftInventory(entity.getEnderChestInventory());
}
@Override
public Player getHandle() {
return (Player) this.entity;
}
public void setHandle(final Player entity) {
super.setHandle(entity);
this.inventory = new CraftInventoryPlayer(entity.getInventory());
}
@Override
public String toString() {
return this.getClass().getSimpleName() + "{name=" + this.getName() + ", uuid=" + this.getUniqueId() + '}';
}
@Override
public PlayerInventory getInventory() {
return this.inventory;
@ -304,21 +320,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
this.mode = mode;
}
@Override
public Player getHandle() {
return (Player) this.entity;
}
public void setHandle(final Player entity) {
super.setHandle(entity);
this.inventory = new CraftInventoryPlayer(entity.getInventory());
}
@Override
public String toString() {
return "CraftHumanEntity{" + "id=" + this.getEntityId() + "name=" + this.getName() + '}';
}
@Override
public InventoryView getOpenInventory() {
return this.getHandle().containerMenu.getBukkitView();

View File

@ -8,9 +8,4 @@ public class CraftHusk extends CraftZombie implements Husk {
public CraftHusk(CraftServer server, net.minecraft.world.entity.monster.Husk entity) {
super(server, entity);
}
@Override
public String toString() {
return "CraftHusk";
}
}

View File

@ -12,11 +12,6 @@ public class CraftIllager extends CraftRaider implements Illager {
@Override
public AbstractIllager getHandle() {
return (AbstractIllager) super.getHandle();
}
@Override
public String toString() {
return "CraftIllager";
return (AbstractIllager) this.entity;
}
}

View File

@ -11,11 +11,6 @@ public class CraftIllusioner extends CraftSpellcaster implements Illusioner, com
@Override
public net.minecraft.world.entity.monster.Illusioner getHandle() {
return (net.minecraft.world.entity.monster.Illusioner) super.getHandle();
}
@Override
public String toString() {
return "CraftIllusioner";
return (net.minecraft.world.entity.monster.Illusioner) this.entity;
}
}

View File

@ -14,12 +14,7 @@ public class CraftInteraction extends CraftEntity implements Interaction {
@Override
public net.minecraft.world.entity.Interaction getHandle() {
return (net.minecraft.world.entity.Interaction) super.getHandle();
}
@Override
public String toString() {
return "CraftInteraction";
return (net.minecraft.world.entity.Interaction) this.entity;
}
@Override

View File

@ -13,11 +13,6 @@ public class CraftIronGolem extends CraftGolem implements IronGolem {
return (net.minecraft.world.entity.animal.IronGolem) this.entity;
}
@Override
public String toString() {
return "CraftIronGolem";
}
@Override
public boolean isPlayerCreated() {
return this.getHandle().isPlayerCreated();

View File

@ -143,9 +143,4 @@ public class CraftItem extends CraftEntity implements Item {
public UUID getThrower() {
return this.getHandle().thrower;
}
@Override
public String toString() {
return "CraftItem";
}
}

View File

@ -15,12 +15,7 @@ public class CraftItemDisplay extends CraftDisplay implements ItemDisplay {
@Override
public net.minecraft.world.entity.Display.ItemDisplay getHandle() {
return (net.minecraft.world.entity.Display.ItemDisplay) super.getHandle();
}
@Override
public String toString() {
return "CraftItemDisplay";
return (net.minecraft.world.entity.Display.ItemDisplay) this.entity;
}
@Override

View File

@ -12,10 +12,16 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.ItemFrame;
public class CraftItemFrame extends CraftHanging implements ItemFrame {
public CraftItemFrame(CraftServer server, net.minecraft.world.entity.decoration.ItemFrame entity) {
super(server, entity);
}
@Override
public net.minecraft.world.entity.decoration.ItemFrame getHandle() {
return (net.minecraft.world.entity.decoration.ItemFrame) this.entity;
}
@Override
public boolean setFacingDirection(BlockFace face, boolean force) {
HangingEntity hanging = this.getHandle();
@ -150,14 +156,4 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame {
public void setFixed(boolean fixed) {
this.getHandle().fixed = fixed;
}
@Override
public net.minecraft.world.entity.decoration.ItemFrame getHandle() {
return (net.minecraft.world.entity.decoration.ItemFrame) this.entity;
}
@Override
public String toString() {
return "CraftItemFrame{item=" + this.getItem() + ", rotation=" + this.getRotation() + "}";
}
}

View File

@ -4,23 +4,19 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.LargeFireball;
public class CraftLargeFireball extends CraftSizedFireball implements LargeFireball {
public CraftLargeFireball(CraftServer server, net.minecraft.world.entity.projectile.LargeFireball entity) {
super(server, entity);
}
@Override
public void setYield(float yield) {
super.setYield(yield);
this.getHandle().explosionPower = (int) yield;
}
@Override
public net.minecraft.world.entity.projectile.LargeFireball getHandle() {
return (net.minecraft.world.entity.projectile.LargeFireball) this.entity;
}
@Override
public String toString() {
return "CraftLargeFireball";
public void setYield(float yield) {
super.setYield(yield);
this.getHandle().explosionPower = (int) yield;
}
}

View File

@ -7,10 +7,16 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.LeashHitch;
public class CraftLeash extends CraftBlockAttachedEntity implements LeashHitch {
public CraftLeash(CraftServer server, LeashFenceKnotEntity entity) {
super(server, entity);
}
@Override
public LeashFenceKnotEntity getHandle() {
return (LeashFenceKnotEntity) this.entity;
}
@Override
public boolean setFacingDirection(BlockFace face, boolean force) {
Preconditions.checkArgument(face == BlockFace.SELF, "%s is not a valid facing direction", face);
@ -34,14 +40,4 @@ public class CraftLeash extends CraftBlockAttachedEntity implements LeashHitch {
public void setFacingDirection(BlockFace face) {
// Leash hitch has no facing direction
}
@Override
public LeashFenceKnotEntity getHandle() {
return (LeashFenceKnotEntity) this.entity;
}
@Override
public String toString() {
return "CraftLeash";
}
}

View File

@ -7,10 +7,16 @@ import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
public class CraftLightningStrike extends CraftEntity implements LightningStrike {
public CraftLightningStrike(final CraftServer server, final LightningBolt entity) {
super(server, entity);
}
@Override
public LightningBolt getHandle() {
return (LightningBolt) this.entity;
}
@Override
public boolean isEffect() {
return this.getHandle().isEffect; // Paper - Properly handle lightning effects api
@ -41,16 +47,6 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
this.getHandle().setCause((player != null) ? ((CraftPlayer) player).getHandle() : null);
}
@Override
public LightningBolt getHandle() {
return (LightningBolt) this.entity;
}
@Override
public String toString() {
return "CraftLightningStrike";
}
// Spigot start
private final LightningStrike.Spigot spigot = new LightningStrike.Spigot() {

View File

@ -107,6 +107,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
}
@Override
public net.minecraft.world.entity.LivingEntity getHandle() {
return (net.minecraft.world.entity.LivingEntity) this.entity;
}
@Override
public double getHealth() {
return Math.min(Math.max(0, this.getHandle().getHealth()), this.getMaxHealth());
@ -503,20 +508,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
this.getHandle().setNoActionTime(ticks);
}
@Override
public net.minecraft.world.entity.LivingEntity getHandle() {
return (net.minecraft.world.entity.LivingEntity) this.entity;
}
public void setHandle(final net.minecraft.world.entity.LivingEntity entity) {
super.setHandle(entity);
}
@Override
public String toString() {
return "CraftLivingEntity{" + "id=" + this.getEntityId() + '}';
}
@Override
public Player getKiller() {
return Optionull.map(this.getHandle().getLastHurtByPlayer(), player -> (Player) player.getBukkitEntity());

View File

@ -6,7 +6,6 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventoryLlama;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Llama.Color;
import org.bukkit.inventory.LlamaInventory;
public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.animal.horse.Llama> { // Paper
@ -17,7 +16,7 @@ public class CraftLlama extends CraftChestedHorse implements Llama, com.destroys
@Override
public net.minecraft.world.entity.animal.horse.Llama getHandle() {
return (net.minecraft.world.entity.animal.horse.Llama) super.getHandle();
return (net.minecraft.world.entity.animal.horse.Llama) this.entity;
}
@Override
@ -58,11 +57,6 @@ public class CraftLlama extends CraftChestedHorse implements Llama, com.destroys
return Horse.Variant.LLAMA;
}
@Override
public String toString() {
return "CraftLlama";
}
@Override
public boolean inCaravan() {
return this.getHandle().inCaravan();

View File

@ -11,11 +11,6 @@ public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit {
@Override
public net.minecraft.world.entity.projectile.LlamaSpit getHandle() {
return (net.minecraft.world.entity.projectile.LlamaSpit) super.getHandle();
}
@Override
public String toString() {
return "CraftLlamaSpit";
return (net.minecraft.world.entity.projectile.LlamaSpit) this.entity;
}
}

View File

@ -13,9 +13,4 @@ public class CraftMagmaCube extends CraftSlime implements MagmaCube {
public net.minecraft.world.entity.monster.MagmaCube getHandle() {
return (net.minecraft.world.entity.monster.MagmaCube) this.entity;
}
@Override
public String toString() {
return "CraftMagmaCube";
}
}

View File

@ -11,11 +11,6 @@ public class CraftMarker extends CraftEntity implements Marker {
@Override
public net.minecraft.world.entity.Marker getHandle() {
return (net.minecraft.world.entity.Marker) super.getHandle();
}
@Override
public String toString() {
return "CraftMarker";
return (net.minecraft.world.entity.Marker) this.entity;
}
}

View File

@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
@ -16,10 +15,16 @@ import org.bukkit.util.Vector;
import java.util.Optional;
public abstract class CraftMinecart extends CraftVehicle implements Minecart {
public CraftMinecart(CraftServer server, AbstractMinecart entity) {
super(server, entity);
}
@Override
public AbstractMinecart getHandle() {
return (AbstractMinecart) this.entity;
}
@Override
public void setDamage(double damage) {
this.getHandle().setDamage((float) damage);
@ -79,11 +84,6 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
}
// Paper end
@Override
public AbstractMinecart getHandle() {
return (AbstractMinecart) this.entity;
}
@Override
public void setDisplayBlock(MaterialData material) {
this.getHandle().setCustomDisplayBlockState(Optional.ofNullable(material).map(CraftMagicNumbers::getBlock));

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.inventory.Inventory;
public class CraftMinecartChest extends CraftMinecartContainer implements StorageMinecart, com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper
private final CraftInventory inventory;
public CraftMinecartChest(CraftServer server, MinecartChest entity) {
@ -18,9 +19,4 @@ public class CraftMinecartChest extends CraftMinecartContainer implements Storag
public Inventory getInventory() {
return this.inventory;
}
@Override
public String toString() {
return "CraftMinecartChest{" + "inventory=" + this.inventory + '}';
}
}

View File

@ -14,6 +14,7 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart, io.papermc.paper.commands.PaperCommandBlockHolder {
private final PermissibleBase perm = new PermissibleBase(this);
public CraftMinecartCommand(CraftServer server, MinecartCommandBlock entity) {
@ -41,11 +42,6 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
this.getHandle().getCommandBlock().setCustomName(CraftChatMessage.fromStringOrNull(name));
}
@Override
public String toString() {
return "CraftMinecartCommand";
}
@Override
public void sendMessage(String message) {
}

View File

@ -6,6 +6,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.minecart.PoweredMinecart;
public class CraftMinecartFurnace extends CraftMinecart implements PoweredMinecart {
public CraftMinecartFurnace(CraftServer server, MinecartFurnace entity) {
super(server, entity);
}
@ -47,9 +48,4 @@ public class CraftMinecartFurnace extends CraftMinecart implements PoweredMineca
final net.minecraft.world.phys.Vec3 push = this.getHandle().push;
this.getHandle().push = new net.minecraft.world.phys.Vec3(push.x, push.y, zPush);
}
@Override
public String toString() {
return "CraftMinecartFurnace";
}
}

View File

@ -6,7 +6,8 @@ import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.inventory.Inventory;
public final class CraftMinecartHopper extends CraftMinecartContainer implements HopperMinecart, com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper
public class CraftMinecartHopper extends CraftMinecartContainer implements HopperMinecart, com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper
private final CraftInventory inventory;
public CraftMinecartHopper(CraftServer server, MinecartHopper entity) {
@ -15,8 +16,8 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements
}
@Override
public String toString() {
return "CraftMinecartHopper{" + "inventory=" + this.inventory + '}';
public net.minecraft.world.entity.vehicle.MinecartHopper getHandle() {
return (net.minecraft.world.entity.vehicle.MinecartHopper) this.entity;
}
@Override
@ -34,11 +35,6 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements
this.getHandle().setEnabled(enabled);
}
@Override
public net.minecraft.world.entity.vehicle.MinecartHopper getHandle() {
return (net.minecraft.world.entity.vehicle.MinecartHopper) super.getHandle();
}
@Override
public int getPickupCooldown() {
throw new UnsupportedOperationException("Hopper minecarts don't have cooldowns");

View File

@ -16,11 +16,17 @@ import org.bukkit.entity.EntitySnapshot;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.minecart.SpawnerMinecart;
final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMinecart, org.bukkit.craftbukkit.spawner.PaperSharedSpawnerLogic { // Paper - more spawner API
CraftMinecartMobSpawner(CraftServer server, MinecartSpawner entity) {
public class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMinecart, org.bukkit.craftbukkit.spawner.PaperSharedSpawnerLogic { // Paper - more spawner API
public CraftMinecartMobSpawner(CraftServer server, MinecartSpawner entity) {
super(server, entity);
}
@Override
public MinecartSpawner getHandle() {
return (MinecartSpawner) this.entity;
}
@Override
public EntityType getSpawnedType() {
SpawnData spawnData = this.getHandle().getSpawner().nextSpawnData;
@ -162,16 +168,6 @@ final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMine
this.getHandle().getSpawner().spawnRange = spawnRange;
}
@Override
public MinecartSpawner getHandle() {
return (MinecartSpawner) this.entity;
}
@Override
public String toString() {
return "CraftMinecartMobSpawner";
}
@Override
public net.minecraft.world.level.BaseSpawner getSpawner() {
return this.getHandle().getSpawner();

View File

@ -1,16 +1,12 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.entity.vehicle.Minecart;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.minecart.RideableMinecart;
public class CraftMinecartRideable extends CraftMinecart implements RideableMinecart {
public CraftMinecartRideable(CraftServer server, AbstractMinecart entity) {
public CraftMinecartRideable(CraftServer server, Minecart entity) {
super(server, entity);
}
@Override
public String toString() {
return "CraftMinecartRideable";
}
}

View File

@ -6,11 +6,17 @@ import net.minecraft.world.entity.vehicle.MinecartTNT;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.minecart.ExplosiveMinecart;
public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart {
CraftMinecartTNT(CraftServer server, MinecartTNT entity) {
public class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart {
public CraftMinecartTNT(CraftServer server, MinecartTNT entity) {
super(server, entity);
}
@Override
public MinecartTNT getHandle() {
return (MinecartTNT) this.entity;
}
@Override
public float getYield() {
return this.getHandle().explosionPowerBase;
@ -72,14 +78,4 @@ public final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMi
this.getHandle().explode(power);
}
@Override
public MinecartTNT getHandle() {
return (MinecartTNT) super.getHandle();
}
@Override
public String toString() {
return "CraftMinecartTNT";
}
}

View File

@ -12,13 +12,30 @@ import org.bukkit.entity.Mob;
import org.bukkit.loot.LootTable;
public abstract class CraftMob extends CraftLivingEntity implements Mob, io.papermc.paper.entity.PaperLeashable { // Paper - Leashable API
public CraftMob(CraftServer server, net.minecraft.world.entity.Mob entity) {
super(server, entity);
paperPathfinder = new com.destroystokyo.paper.entity.PaperPathfinder(entity); // Paper - Mob Pathfinding API
}
private final com.destroystokyo.paper.entity.PaperPathfinder paperPathfinder; // Paper - Mob Pathfinding API
@Override public com.destroystokyo.paper.entity.Pathfinder getPathfinder() { return paperPathfinder; } // Paper - Mob Pathfinding API
public CraftMob(CraftServer server, net.minecraft.world.entity.Mob entity) {
super(server, entity);
this.paperPathfinder = new com.destroystokyo.paper.entity.PaperPathfinder(entity); // Paper - Mob Pathfinding API
}
@Override
public net.minecraft.world.entity.Mob getHandle() {
return (net.minecraft.world.entity.Mob) this.entity;
}
@Override
public void setHandle(net.minecraft.world.entity.Entity entity) {
super.setHandle(entity);
this.paperPathfinder.setHandle(getHandle());
}
@Override
public com.destroystokyo.paper.entity.Pathfinder getPathfinder() {
return this.paperPathfinder;
}
@Override
public void setTarget(LivingEntity target) {
Preconditions.checkState(!this.getHandle().generation, "Cannot set target during world generation");
@ -54,24 +71,6 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob, io.pape
return (sound != null) ? CraftSound.minecraftToBukkit(sound) : null;
}
@Override
public net.minecraft.world.entity.Mob getHandle() {
return (net.minecraft.world.entity.Mob) this.entity;
}
// Paper start - Mob Pathfinding API
@Override
public void setHandle(net.minecraft.world.entity.Entity entity) {
super.setHandle(entity);
paperPathfinder.setHandle(getHandle());
}
// Paper end - Mob Pathfinding API
@Override
public String toString() {
return "CraftMob";
}
@Override
public void setLootTable(LootTable table) {
this.getHandle().lootTable = Optional.ofNullable(CraftLootTable.bukkitToMinecraft(table));

Some files were not shown because too many files have changed in this diff Show More