| 1 | package net.minecraft.world.entity.projectile;
|
| 2 |
|
| 3 | import com.google.common.base.MoreObjects;
|
| 4 | import it.unimi.dsi.fastutil.doubles.DoubleDoubleImmutablePair;
|
| 5 | import java.util.function.Consumer;
|
| 6 | import net.minecraft.core.BlockPos;
|
| 7 | import net.minecraft.core.component.DataComponentGetter;
|
| 8 | import net.minecraft.core.component.DataComponentType;
|
| 9 | import net.minecraft.core.component.DataComponents;
|
| 10 | import net.minecraft.network.protocol.Packet;
|
| 11 | import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
| 12 | import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
|
| 13 | import net.minecraft.server.level.ServerEntity;
|
| 14 | import net.minecraft.server.level.ServerLevel;
|
| 15 | import net.minecraft.tags.EntityTypeTags;
|
| 16 | import net.minecraft.util.Mth;
|
| 17 | import net.minecraft.world.damagesource.DamageSource;
|
| 18 | import net.minecraft.world.entity.Entity;
|
| 19 | import net.minecraft.world.entity.EntityReference;
|
| 20 | import net.minecraft.world.entity.EntitySelector;
|
| 21 | import net.minecraft.world.entity.EntityType;
|
| 22 | import net.minecraft.world.entity.LivingEntity;
|
| 23 | import net.minecraft.world.entity.MoveSimulationType;
|
| 24 | import net.minecraft.world.entity.TraceableEntity;
|
| 25 | import net.minecraft.world.entity.player.Player;
|
| 26 | import net.minecraft.world.entity.projectile.arrow.AbstractArrow;
|
| 27 | import net.minecraft.world.item.AdventureModePredicate;
|
| 28 | import net.minecraft.world.item.ItemStack;
|
| 29 | import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
| 30 | import net.minecraft.world.level.GameType;
|
| 31 | import net.minecraft.world.level.Level;
|
| 32 | import net.minecraft.world.level.block.state.BlockState;
|
| 33 | import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
| 34 | import net.minecraft.world.level.gameevent.GameEvent;
|
| 35 | import net.minecraft.world.level.gamerules.GameRules;
|
| 36 | import net.minecraft.world.level.storage.ValueInput;
|
| 37 | import net.minecraft.world.level.storage.ValueOutput;
|
| 38 | import net.minecraft.world.phys.AABB;
|
| 39 | import net.minecraft.world.phys.BlockHitResult;
|
| 40 | import net.minecraft.world.phys.EntityHitResult;
|
| 41 | import net.minecraft.world.phys.HitResult;
|
| 42 | import net.minecraft.world.phys.Vec3;
|
| 43 | import org.jspecify.annotations.Nullable;
|
| 44 |
|
| 45 | /**
|
| 46 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 47 | */
|
| 48 | public abstract class Projectile extends Entity implements TraceableEntity {
|
| 49 | private static final boolean DEFAULT_LEFT_OWNER = false;
|
| 50 | private static final boolean DEFAULT_HAS_BEEN_SHOT = false;
|
| 51 | private static final String TAG_OWNER = "Owner";
|
| 52 | private static final String TAG_LEFT_OWNER = "LeftOwner";
|
| 53 | private static final String TAG_HAS_BEEN_SHOT = "HasBeenShot";
|
| 54 | private static final String TAG_CAN_BREAK = "can_break";
|
| 55 | protected @Nullable EntityReference<Entity> owner;
|
| 56 | private @Nullable AdventureModePredicate canBreak;
|
| 57 | private boolean leftOwner = false;
|
| 58 | private boolean leftOwnerChecked;
|
| 59 | private boolean hasBeenShot = false;
|
| 60 | private @Nullable Entity lastDeflectedBy;
|
| 61 |
|
| 62 | /**
|
| 63 | * Access widened by fabric-transitive-access-wideners-v1 to accessible
|
| 64 | */
|
| 65 | public Projectile(final EntityType<? extends Projectile> type, final Level level) {
|
| 66 | super(type, level);
|
| 67 | }
|
| 68 |
|
| 69 | @Override
|
| 70 | protected void applyImplicitComponents(final DataComponentGetter components) {
|
| 71 | this.applyImplicitComponentIfPresent(components, DataComponents.CAN_BREAK);
|
| 72 | super.applyImplicitComponents(components);
|
| 73 | }
|
| 74 |
|
| 75 | @Override
|
| 76 | protected <T> boolean applyImplicitComponent(final DataComponentType<T> type, final T value) {
|
| 77 | if (type == DataComponents.CAN_BREAK) {
|
| 78 | this.canBreak = castComponentValue(DataComponents.CAN_BREAK, value);
|
| 79 | return true;
|
| 80 | } else {
|
| 81 | return super.applyImplicitComponent(type, value);
|
| 82 | }
|
| 83 | }
|
| 84 |
|
| 85 | protected void setOwner(final @Nullable EntityReference<Entity> owner) {
|
| 86 | this.owner = owner;
|
| 87 | }
|
| 88 |
|
| 89 | public void setOwner(final @Nullable Entity owner) {
|
| 90 | this.setOwner(EntityReference.of(owner));
|
| 91 | }
|
| 92 |
|
| 93 | @Override
|
| 94 | public @Nullable Entity getOwner() {
|
| 95 | return EntityReference.getEntity(this.owner, this.level());
|
| 96 | }
|
| 97 |
|
| 98 | public Entity getEffectSource() {
|
| 99 | return MoreObjects.firstNonNull(this.getOwner(), this);
|
| 100 | }
|
| 101 |
|
| 102 | @Override
|
| 103 | protected void addAdditionalSaveData(final ValueOutput output) {
|
| 104 | EntityReference.store(this.owner, output, "Owner");
|
| 105 | if (this.leftOwner) {
|
| 106 | output.putBoolean("LeftOwner", true);
|
| 107 | }
|
| 108 |
|
| 109 | output.putBoolean("HasBeenShot", this.hasBeenShot);
|
| 110 | if (this.canBreak != null) {
|
| 111 | output.store("can_break", AdventureModePredicate.CODEC, this.canBreak);
|
| 112 | }
|
| 113 | }
|
| 114 |
|
| 115 | protected boolean ownedBy(final Entity entity) {
|
| 116 | return this.owner != null && this.owner.matches(entity);
|
| 117 | }
|
| 118 |
|
| 119 | @Override
|
| 120 | protected void readAdditionalSaveData(final ValueInput input) {
|
| 121 | this.setOwner(EntityReference.read(input, "Owner"));
|
| 122 | this.leftOwner = input.getBooleanOr("LeftOwner", false);
|
| 123 | this.hasBeenShot = input.getBooleanOr("HasBeenShot", false);
|
| 124 | this.canBreak = input.read("can_break", AdventureModePredicate.CODEC).orElse(null);
|
| 125 | }
|
| 126 |
|
| 127 | @Override
|
| 128 | public void restoreFrom(final Entity oldEntity) {
|
| 129 | super.restoreFrom(oldEntity);
|
| 130 | if (oldEntity instanceof Projectile projectile) {
|
| 131 | this.owner = projectile.owner;
|
| 132 | }
|
| 133 | }
|
| 134 |
|
| 135 | @Override
|
| 136 | public void tick() {
|
| 137 | if (!this.hasBeenShot) {
|
| 138 | this.gameEvent(GameEvent.PROJECTILE_SHOOT, this.getOwner());
|
| 139 | this.hasBeenShot = true;
|
| 140 | }
|
| 141 |
|
| 142 | this.checkLeftOwner();
|
| 143 | super.tick();
|
| 144 | this.leftOwnerChecked = false;
|
| 145 | }
|
| 146 |
|
| 147 | protected void checkLeftOwner() {
|
| 148 | if (!this.leftOwner && !this.leftOwnerChecked) {
|
| 149 | this.leftOwner = this.isOutsideOwnerCollisionRange();
|
| 150 | this.leftOwnerChecked = true;
|
| 151 | }
|
| 152 | }
|
| 153 |
|
| 154 | private boolean isOutsideOwnerCollisionRange() {
|
| 155 | Entity owner = this.getOwner();
|
| 156 | if (owner != null) {
|
| 157 | AABB aabb = this.getBoundingBox().expandTowards(this.getDeltaMovement()).inflate(1.0);
|
| 158 | return owner.getRootVehicle().getSelfAndPassengers().filter(EntitySelector.CAN_BE_PICKED).noneMatch(entity -> aabb.intersects(entity.getBoundingBox()));
|
| 159 | } else {
|
| 160 | return true;
|
| 161 | }
|
| 162 | }
|
| 163 |
|
| 164 | public Vec3 getMovementToShoot(final double xd, final double yd, final double zd, final float pow, final float uncertainty) {
|
| 165 | return new Vec3(xd, yd, zd)
|
| 166 | .normalize()
|
| 167 | .add(
|
| 168 | this.random.triangle(0.0, 0.0172275 * uncertainty), this.random.triangle(0.0, 0.0172275 * uncertainty), this.random.triangle(0.0, 0.0172275 * uncertainty)
|
| 169 | )
|
| 170 | .scale(pow);
|
| 171 | }
|
| 172 |
|
| 173 | public void shoot(final double xd, final double yd, final double zd, final float pow, final float uncertainty) {
|
| 174 | Vec3 movement = this.getMovementToShoot(xd, yd, zd, pow, uncertainty);
|
| 175 | this.setDeltaMovement(movement);
|
| 176 | this.needsSync = true;
|
| 177 | double sd = movement.horizontalDistance();
|
| 178 | this.setYRot((float)(Mth.atan2(movement.x, movement.z) * 180.0F / (float)Math.PI));
|
| 179 | this.setXRot((float)(Mth.atan2(movement.y, sd) * 180.0F / (float)Math.PI));
|
| 180 | this.yRotO = this.getYRot();
|
| 181 | this.xRotO = this.getXRot();
|
| 182 | }
|
| 183 |
|
| 184 | public void shootFromRotation(final Entity source, final float xRot, final float yRot, final float yOffset, final float pow, final float uncertainty) {
|
| 185 | float xd = -Mth.sin(yRot * (float) (Math.PI / 180.0)) * Mth.cos(xRot * (float) (Math.PI / 180.0));
|
| 186 | float yd = -Mth.sin((xRot + yOffset) * (float) (Math.PI / 180.0));
|
| 187 | float zd = Mth.cos(yRot * (float) (Math.PI / 180.0)) * Mth.cos(xRot * (float) (Math.PI / 180.0));
|
| 188 | this.shoot(xd, yd, zd, pow, uncertainty);
|
| 189 | Vec3 sourceMovement = source.getKnownMovement();
|
| 190 | this.setDeltaMovement(this.getDeltaMovement().add(sourceMovement.x, source.onGround() ? 0.0 : sourceMovement.y, sourceMovement.z));
|
| 191 | }
|
| 192 |
|
| 193 | @Override
|
| 194 | public void onAboveBubbleColumn(final boolean dragDown, final BlockPos pos) {
|
| 195 | double yd = dragDown ? -0.03 : 0.1;
|
| 196 | this.setDeltaMovement(this.getDeltaMovement().add(0.0, yd, 0.0));
|
| 197 | sendBubbleColumnParticles(this.level(), pos);
|
| 198 | }
|
| 199 |
|
| 200 | @Override
|
| 201 | public void onInsideBubbleColumn(final boolean dragDown) {
|
| 202 | double yd = dragDown ? -0.03 : 0.06;
|
| 203 | this.setDeltaMovement(this.getDeltaMovement().add(0.0, yd, 0.0));
|
| 204 | this.resetFallDistance();
|
| 205 | }
|
| 206 |
|
| 207 | public boolean canBreakBlockInAdventureMode(final ServerLevel level, final BlockInWorld blockInWorld) {
|
| 208 | Entity owner = this.getOwner();
|
| 209 | GameType worldGameMode = level.getServer().getDefaultGameType();
|
| 210 | return (owner != null || worldGameMode == GameType.ADVENTURE) && !(owner instanceof Player player && player.gameMode() != GameType.ADVENTURE)
|
| 211 | ? this.canBreak != null && this.canBreak.test(blockInWorld)
|
| 212 | : true;
|
| 213 | }
|
| 214 |
|
| 215 | public static <T extends Projectile> T spawnProjectileFromRotation(
|
| 216 | final Projectile.ProjectileFactory<T> creator,
|
| 217 | final ServerLevel serverLevel,
|
| 218 | final ItemStack itemStack,
|
| 219 | final LivingEntity source,
|
| 220 | final float yOffset,
|
| 221 | final float pow,
|
| 222 | final float uncertainty
|
| 223 | ) {
|
| 224 | return spawnProjectile(
|
| 225 | creator.create(serverLevel, source, itemStack),
|
| 226 | serverLevel,
|
| 227 | itemStack,
|
| 228 | projectile -> projectile.shootFromRotation(source, source.getXRot(), source.getYRot(), yOffset, pow, uncertainty)
|
| 229 | );
|
| 230 | }
|
| 231 |
|
| 232 | public static <T extends Projectile> T spawnProjectileUsingShoot(
|
| 233 | final Projectile.ProjectileFactory<T> creator,
|
| 234 | final ServerLevel serverLevel,
|
| 235 | final ItemStack itemStack,
|
| 236 | final LivingEntity source,
|
| 237 | final double targetX,
|
| 238 | final double targetY,
|
| 239 | final double targetZ,
|
| 240 | final float pow,
|
| 241 | final float uncertainty
|
| 242 | ) {
|
| 243 | return spawnProjectile(
|
| 244 | creator.create(serverLevel, source, itemStack), serverLevel, itemStack, projectile -> projectile.shoot(targetX, targetY, targetZ, pow, uncertainty)
|
| 245 | );
|
| 246 | }
|
| 247 |
|
| 248 | public static <T extends Projectile> T spawnProjectileUsingShoot(
|
| 249 | final T projectile,
|
| 250 | final ServerLevel serverLevel,
|
| 251 | final ItemStack itemStack,
|
| 252 | final double targetX,
|
| 253 | final double targetY,
|
| 254 | final double targetZ,
|
| 255 | final float pow,
|
| 256 | final float uncertainty
|
| 257 | ) {
|
| 258 | return spawnProjectile(projectile, serverLevel, itemStack, i -> projectile.shoot(targetX, targetY, targetZ, pow, uncertainty));
|
| 259 | }
|
| 260 |
|
| 261 | public static <T extends Projectile> T spawnProjectile(final T projectile, final ServerLevel serverLevel, final ItemStack itemStack) {
|
| 262 | return spawnProjectile(projectile, serverLevel, itemStack, ignored -> {});
|
| 263 | }
|
| 264 |
|
| 265 | public static <T extends Projectile> T spawnProjectile(
|
| 266 | final T projectile, final ServerLevel serverLevel, final ItemStack itemStack, final Consumer<T> shootFunction
|
| 267 | ) {
|
| 268 | shootFunction.accept(projectile);
|
| 269 | serverLevel.addFreshEntity(projectile);
|
| 270 | projectile.applyOnProjectileSpawned(serverLevel, itemStack);
|
| 271 | return projectile;
|
| 272 | }
|
| 273 |
|
| 274 | public void applyOnProjectileSpawned(final ServerLevel serverLevel, final ItemStack pickupItemStack) {
|
| 275 | EnchantmentHelper.onProjectileSpawned(serverLevel, pickupItemStack, this, item -> {});
|
| 276 | if (this instanceof AbstractArrow arrow) {
|
| 277 | ItemStack weapon = arrow.getWeaponItem();
|
| 278 | if (weapon != null && !weapon.isEmpty() && !pickupItemStack.getItem().equals(weapon.getItem())) {
|
| 279 | EnchantmentHelper.onProjectileSpawned(serverLevel, weapon, this, arrow::onItemBreak);
|
| 280 | }
|
| 281 | }
|
| 282 | }
|
| 283 |
|
| 284 | protected ProjectileDeflection hitTargetOrDeflectSelf(final HitResult hitResult) {
|
| 285 | if (hitResult instanceof EntityHitResult entityHitResult) {
|
| 286 | Entity entity = entityHitResult.getEntity();
|
| 287 | ProjectileDeflection deflection = entity.deflection(this);
|
| 288 | if (deflection != ProjectileDeflection.NONE) {
|
| 289 | if (entity != this.lastDeflectedBy && this.deflect(deflection, entity, this.owner, false, 1.0)) {
|
| 290 | this.lastDeflectedBy = entity;
|
| 291 | }
|
| 292 |
|
| 293 | return deflection;
|
| 294 | }
|
| 295 | } else if (hitResult instanceof BlockHitResult blockHitResult) {
|
| 296 | if (!blockHitResult.isWorldBorderHit()) {
|
| 297 | BlockState collidedWith = this.level().getBlockState(blockHitResult.getBlockPos());
|
| 298 | if (collidedWith.isAir()) {
|
| 299 | return ProjectileDeflection.NONE;
|
| 300 | }
|
| 301 | } else if (this.shouldBounceOnWorldBorder()) {
|
| 302 | ProjectileDeflection deflection = ProjectileDeflection.REVERSE;
|
| 303 | if (this.deflect(deflection, null, this.owner, false, 0.2)) {
|
| 304 | return deflection;
|
| 305 | }
|
| 306 | }
|
| 307 | }
|
| 308 |
|
| 309 | this.onHit(hitResult);
|
| 310 | return ProjectileDeflection.NONE;
|
| 311 | }
|
| 312 |
|
| 313 | protected boolean shouldBounceOnWorldBorder() {
|
| 314 | return false;
|
| 315 | }
|
| 316 |
|
| 317 | public boolean deflect(
|
| 318 | final ProjectileDeflection deflection,
|
| 319 | final @Nullable Entity deflectingEntity,
|
| 320 | final @Nullable EntityReference<Entity> newOwner,
|
| 321 | final boolean byAttack,
|
| 322 | final Vec3 power
|
| 323 | ) {
|
| 324 | if (!this.level().isClientSide()) {
|
| 325 | deflection.deflect(this, deflectingEntity, this.random, power);
|
| 326 | this.setOwner(newOwner);
|
| 327 | this.onDeflection(byAttack);
|
| 328 | }
|
| 329 |
|
| 330 | return true;
|
| 331 | }
|
| 332 |
|
| 333 | public boolean deflect(
|
| 334 | final ProjectileDeflection deflection,
|
| 335 | final @Nullable Entity deflectingEntity,
|
| 336 | final @Nullable EntityReference<Entity> newOwner,
|
| 337 | final boolean byAttack,
|
| 338 | final double power
|
| 339 | ) {
|
| 340 | return this.deflect(deflection, deflectingEntity, newOwner, byAttack, new Vec3(power, power, power));
|
| 341 | }
|
| 342 |
|
| 343 | protected void onDeflection(final boolean byAttack) {
|
| 344 | }
|
| 345 |
|
| 346 | protected void onItemBreak(final ItemStack item) {
|
| 347 | }
|
| 348 |
|
| 349 | protected void onHit(final HitResult hitResult) {
|
| 350 | HitResult.Type type = hitResult.getType();
|
| 351 | if (type == HitResult.Type.ENTITY) {
|
| 352 | EntityHitResult entityHitResult = (EntityHitResult)hitResult;
|
| 353 | Entity entityHit = entityHitResult.getEntity();
|
| 354 | if (entityHit.is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entityHit instanceof Projectile projectile) {
|
| 355 | this.onRedirectProjectile(projectile);
|
| 356 | }
|
| 357 |
|
| 358 | this.onHitEntity(entityHitResult);
|
| 359 | this.level().gameEvent(GameEvent.PROJECTILE_LAND, hitResult.getLocation(), GameEvent.Context.of(this, null));
|
| 360 | } else if (type == HitResult.Type.BLOCK) {
|
| 361 | BlockHitResult blockHit = (BlockHitResult)hitResult;
|
| 362 | this.onHitBlock(blockHit);
|
| 363 | BlockPos target = blockHit.getBlockPos();
|
| 364 | this.level().gameEvent(GameEvent.PROJECTILE_LAND, target, GameEvent.Context.of(this, this.level().getBlockState(target)));
|
| 365 | }
|
| 366 | }
|
| 367 |
|
| 368 | protected void onHitEntity(final EntityHitResult hitResult) {
|
| 369 | }
|
| 370 |
|
| 371 | protected void onHitBlock(final BlockHitResult hitResult) {
|
| 372 | BlockState state = this.level().getBlockState(hitResult.getBlockPos());
|
| 373 | state.onProjectileHit(this.level(), state, hitResult, this);
|
| 374 | }
|
| 375 |
|
| 376 | protected void onRedirectProjectile(final Projectile hitProjectile) {
|
| 377 | hitProjectile.deflect(ProjectileDeflection.AIM_DEFLECT, this.getOwner(), this.owner, true, 1.0);
|
| 378 | }
|
| 379 |
|
| 380 | protected boolean canHitEntity(final Entity entity) {
|
| 381 | if (!entity.canBeHitByProjectile()) {
|
| 382 | return false;
|
| 383 | }
|
| 384 |
|
| 385 | Entity owner = this.getOwner();
|
| 386 | return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(entity);
|
| 387 | }
|
| 388 |
|
| 389 | protected void updateRotation() {
|
| 390 | Vec3 movement = this.getDeltaMovement();
|
| 391 | double sd = movement.horizontalDistance();
|
| 392 | this.setXRot(lerpRotation(this.xRotO, (float)(Mth.atan2(movement.y, sd) * 180.0F / (float)Math.PI)));
|
| 393 | this.setYRot(lerpRotation(this.yRotO, (float)(Mth.atan2(movement.x, movement.z) * 180.0F / (float)Math.PI)));
|
| 394 | }
|
| 395 |
|
| 396 | protected static float lerpRotation(float rotO, final float rot) {
|
| 397 | while (rot - rotO < -180.0F) {
|
| 398 | rotO -= 360.0F;
|
| 399 | }
|
| 400 |
|
| 401 | while (rot - rotO >= 180.0F) {
|
| 402 | rotO += 360.0F;
|
| 403 | }
|
| 404 |
|
| 405 | return Mth.lerp(0.2F, rotO, rot);
|
| 406 | }
|
| 407 |
|
| 408 | @Override
|
| 409 | public Packet<ClientGamePacketListener> getAddEntityPacket(final ServerEntity serverEntity) {
|
| 410 | Entity owner = this.getOwner();
|
| 411 | return new ClientboundAddEntityPacket(this, serverEntity, owner == null ? 0 : owner.getId());
|
| 412 | }
|
| 413 |
|
| 414 | @Override
|
| 415 | public void recreateFromPacket(final ClientboundAddEntityPacket packet) {
|
| 416 | super.recreateFromPacket(packet);
|
| 417 | Entity owner = this.level().getEntity(packet.getData());
|
| 418 | if (owner != null) {
|
| 419 | this.setOwner(owner);
|
| 420 | }
|
| 421 | }
|
| 422 |
|
| 423 | @Override
|
| 424 | public boolean mayInteract(final ServerLevel level, final BlockPos pos) {
|
| 425 | Entity owner = this.getOwner();
|
| 426 | return owner instanceof Player ? owner.mayInteract(level, pos) : owner == null || level.getGameRules().get(GameRules.MOB_GRIEFING);
|
| 427 | }
|
| 428 |
|
| 429 | public boolean mayBreak(final ServerLevel level, final BlockPos pos) {
|
| 430 | return this.is(EntityTypeTags.IMPACT_PROJECTILES)
|
| 431 | && level.getGameRules().get(GameRules.PROJECTILES_CAN_BREAK_BLOCKS)
|
| 432 | && this.canBreakBlockInAdventureMode(level, new BlockInWorld(level, pos, false));
|
| 433 | }
|
| 434 |
|
| 435 | @Override
|
| 436 | public boolean isPickable() {
|
| 437 | return this.is(EntityTypeTags.REDIRECTABLE_PROJECTILE);
|
| 438 | }
|
| 439 |
|
| 440 | @Override
|
| 441 | public float getPickRadius() {
|
| 442 | return this.isPickable() ? 1.0F : 0.0F;
|
| 443 | }
|
| 444 |
|
| 445 | public DoubleDoubleImmutablePair calculateHorizontalHurtKnockbackDirection(final LivingEntity hurtEntity, final DamageSource damageSource) {
|
| 446 | double dx = this.getDeltaMovement().x;
|
| 447 | double dz = this.getDeltaMovement().z;
|
| 448 | return DoubleDoubleImmutablePair.of(dx, dz);
|
| 449 | }
|
| 450 |
|
| 451 | @Override
|
| 452 | public int getDimensionChangingDelay() {
|
| 453 | return 2;
|
| 454 | }
|
| 455 |
|
| 456 | @Override
|
| 457 | public boolean hurtServer(final ServerLevel level, final DamageSource source, final float damage) {
|
| 458 | if (!this.isInvulnerableToBase(source)) {
|
| 459 | this.markHurt();
|
| 460 | }
|
| 461 |
|
| 462 | return false;
|
| 463 | }
|
| 464 |
|
| 465 | @Override
|
| 466 | public MoveSimulationType getMoveSimulationType() {
|
| 467 | return MoveSimulationType.SERVER_AND_CLIENT;
|
| 468 | }
|
| 469 |
|
| 470 | @FunctionalInterface
|
| 471 | public interface ProjectileFactory<T extends Projectile> {
|
| 472 | T create(final ServerLevel level, LivingEntity entity, ItemStack itemStack);
|
| 473 | }
|
| 474 | }
|
| 475 |
|