diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch | 357 |
1 files changed, 357 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch new file mode 100644 index 0000000000..0242bf32b8 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -0,0 +1,357 @@ +--- a/net/minecraft/world/entity/projectile/ShulkerBullet.java ++++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java +@@ -30,7 +30,8 @@ + import net.minecraft.world.phys.Vec3; + + public class ShulkerBullet extends Projectile { +- private static final double SPEED = 0.15; ++ ++ private static final double SPEED = 0.15D; + @Nullable + private Entity finalTarget; + @Nullable +@@ -50,16 +51,30 @@ + public ShulkerBullet(Level level, LivingEntity shooter, Entity finalTarget, Direction.Axis axis) { + this(EntityType.SHULKER_BULLET, level); + this.setOwner(shooter); +- BlockPos blockPos = shooter.blockPosition(); +- double d = (double)blockPos.getX() + 0.5; +- double d1 = (double)blockPos.getY() + 0.5; +- double d2 = (double)blockPos.getZ() + 0.5; +- this.moveTo(d, d1, d2, this.getYRot(), this.getXRot()); ++ BlockPos blockposition = shooter.blockPosition(); ++ double d0 = (double) blockposition.getX() + 0.5D; ++ double d1 = (double) blockposition.getY() + 0.5D; ++ double d2 = (double) blockposition.getZ() + 0.5D; ++ ++ this.moveTo(d0, d1, d2, this.getYRot(), this.getXRot()); + this.finalTarget = finalTarget; + this.currentMoveDirection = Direction.UP; + this.selectNextMoveDirection(axis); ++ projectileSource = (org.bukkit.entity.LivingEntity) shooter.getBukkitEntity(); // CraftBukkit + } + ++ // CraftBukkit start ++ public Entity getTarget() { ++ return this.finalTarget; ++ } ++ ++ public void setTarget(Entity e) { ++ this.finalTarget = e; ++ this.currentMoveDirection = Direction.UP; ++ this.selectNextMoveDirection(Direction.Axis.X); ++ } ++ // CraftBukkit end ++ + @Override + public SoundSource getSoundSource() { + return SoundSource.HOSTILE; +@@ -96,11 +111,11 @@ + if (compound.hasUUID("Target")) { + this.targetId = compound.getUUID("Target"); + } ++ + } + + @Override +- protected void defineSynchedData() { +- } ++ protected void defineSynchedData() {} + + @Nullable + private Direction getMoveDirection() { +@@ -112,73 +127,77 @@ + } + + private void selectNextMoveDirection(@Nullable Direction.Axis axis) { +- double d = 0.5; +- BlockPos blockPos; ++ double d0 = 0.5D; ++ BlockPos blockposition; ++ + if (this.finalTarget == null) { +- blockPos = this.blockPosition().below(); ++ blockposition = this.blockPosition().below(); + } else { +- d = (double)this.finalTarget.getBbHeight() * 0.5; +- blockPos = BlockPos.containing(this.finalTarget.getX(), this.finalTarget.getY() + d, this.finalTarget.getZ()); ++ d0 = (double) this.finalTarget.getBbHeight() * 0.5D; ++ blockposition = BlockPos.containing(this.finalTarget.getX(), this.finalTarget.getY() + d0, this.finalTarget.getZ()); + } + +- double d1 = (double)blockPos.getX() + 0.5; +- double d2 = (double)blockPos.getY() + d; +- double d3 = (double)blockPos.getZ() + 0.5; +- Direction direction = null; +- if (!blockPos.closerToCenterThan(this.position(), 2.0)) { +- BlockPos blockPos1 = this.blockPosition(); ++ double d1 = (double) blockposition.getX() + 0.5D; ++ double d2 = (double) blockposition.getY() + d0; ++ double d3 = (double) blockposition.getZ() + 0.5D; ++ Direction enumdirection = null; ++ ++ if (!blockposition.closerToCenterThan(this.position(), 2.0D)) { ++ BlockPos blockposition1 = this.blockPosition(); + List<Direction> list = Lists.newArrayList(); ++ + if (axis != Direction.Axis.X) { +- if (blockPos1.getX() < blockPos.getX() && this.level().isEmptyBlock(blockPos1.east())) { ++ if (blockposition1.getX() < blockposition.getX() && this.level().isEmptyBlock(blockposition1.east())) { + list.add(Direction.EAST); +- } else if (blockPos1.getX() > blockPos.getX() && this.level().isEmptyBlock(blockPos1.west())) { ++ } else if (blockposition1.getX() > blockposition.getX() && this.level().isEmptyBlock(blockposition1.west())) { + list.add(Direction.WEST); + } + } + + if (axis != Direction.Axis.Y) { +- if (blockPos1.getY() < blockPos.getY() && this.level().isEmptyBlock(blockPos1.above())) { ++ if (blockposition1.getY() < blockposition.getY() && this.level().isEmptyBlock(blockposition1.above())) { + list.add(Direction.UP); +- } else if (blockPos1.getY() > blockPos.getY() && this.level().isEmptyBlock(blockPos1.below())) { ++ } else if (blockposition1.getY() > blockposition.getY() && this.level().isEmptyBlock(blockposition1.below())) { + list.add(Direction.DOWN); + } + } + + if (axis != Direction.Axis.Z) { +- if (blockPos1.getZ() < blockPos.getZ() && this.level().isEmptyBlock(blockPos1.south())) { ++ if (blockposition1.getZ() < blockposition.getZ() && this.level().isEmptyBlock(blockposition1.south())) { + list.add(Direction.SOUTH); +- } else if (blockPos1.getZ() > blockPos.getZ() && this.level().isEmptyBlock(blockPos1.north())) { ++ } else if (blockposition1.getZ() > blockposition.getZ() && this.level().isEmptyBlock(blockposition1.north())) { + list.add(Direction.NORTH); + } + } + +- direction = Direction.getRandom(this.random); ++ enumdirection = Direction.getRandom(this.random); + if (list.isEmpty()) { +- for (int i = 5; !this.level().isEmptyBlock(blockPos1.relative(direction)) && i > 0; i--) { +- direction = Direction.getRandom(this.random); ++ for (int i = 5; !this.level().isEmptyBlock(blockposition1.relative(enumdirection)) && i > 0; --i) { ++ enumdirection = Direction.getRandom(this.random); + } + } else { +- direction = list.get(this.random.nextInt(list.size())); ++ enumdirection = (Direction) list.get(this.random.nextInt(list.size())); + } + +- d1 = this.getX() + (double)direction.getStepX(); +- d2 = this.getY() + (double)direction.getStepY(); +- d3 = this.getZ() + (double)direction.getStepZ(); ++ d1 = this.getX() + (double) enumdirection.getStepX(); ++ d2 = this.getY() + (double) enumdirection.getStepY(); ++ d3 = this.getZ() + (double) enumdirection.getStepZ(); + } + +- this.setMoveDirection(direction); ++ this.setMoveDirection(enumdirection); + double d4 = d1 - this.getX(); + double d5 = d2 - this.getY(); + double d6 = d3 - this.getZ(); +- double squareRoot = Math.sqrt(d4 * d4 + d5 * d5 + d6 * d6); +- if (squareRoot == 0.0) { +- this.targetDeltaX = 0.0; +- this.targetDeltaY = 0.0; +- this.targetDeltaZ = 0.0; ++ double d7 = Math.sqrt(d4 * d4 + d5 * d5 + d6 * d6); ++ ++ if (d7 == 0.0D) { ++ this.targetDeltaX = 0.0D; ++ this.targetDeltaY = 0.0D; ++ this.targetDeltaZ = 0.0D; + } else { +- this.targetDeltaX = d4 / squareRoot * 0.15; +- this.targetDeltaY = d5 / squareRoot * 0.15; +- this.targetDeltaZ = d6 / squareRoot * 0.15; ++ this.targetDeltaX = d4 / d7 * 0.15D; ++ this.targetDeltaY = d5 / d7 * 0.15D; ++ this.targetDeltaZ = d6 / d7 * 0.15D; + } + + this.hasImpulse = true; +@@ -190,73 +209,69 @@ + if (this.level().getDifficulty() == Difficulty.PEACEFUL) { + this.discard(); + } ++ + } + + @Override + public void tick() { + super.tick(); ++ Vec3 vec3d; ++ + if (!this.level().isClientSide) { + if (this.finalTarget == null && this.targetId != null) { +- this.finalTarget = ((ServerLevel)this.level()).getEntity(this.targetId); ++ this.finalTarget = ((ServerLevel) this.level()).getEntity(this.targetId); + if (this.finalTarget == null) { + this.targetId = null; + } + } + +- if (this.finalTarget == null || !this.finalTarget.isAlive() || this.finalTarget instanceof Player && this.finalTarget.isSpectator()) { +- if (!this.isNoGravity()) { +- this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0)); +- } +- } else { +- this.targetDeltaX = Mth.clamp(this.targetDeltaX * 1.025, -1.0, 1.0); +- this.targetDeltaY = Mth.clamp(this.targetDeltaY * 1.025, -1.0, 1.0); +- this.targetDeltaZ = Mth.clamp(this.targetDeltaZ * 1.025, -1.0, 1.0); +- Vec3 deltaMovement = this.getDeltaMovement(); +- this.setDeltaMovement( +- deltaMovement.add( +- (this.targetDeltaX - deltaMovement.x) * 0.2, (this.targetDeltaY - deltaMovement.y) * 0.2, (this.targetDeltaZ - deltaMovement.z) * 0.2 +- ) +- ); ++ if (this.finalTarget != null && this.finalTarget.isAlive() && (!(this.finalTarget instanceof Player) || !this.finalTarget.isSpectator())) { ++ this.targetDeltaX = Mth.clamp(this.targetDeltaX * 1.025D, -1.0D, 1.0D); ++ this.targetDeltaY = Mth.clamp(this.targetDeltaY * 1.025D, -1.0D, 1.0D); ++ this.targetDeltaZ = Mth.clamp(this.targetDeltaZ * 1.025D, -1.0D, 1.0D); ++ vec3d = this.getDeltaMovement(); ++ this.setDeltaMovement(vec3d.add((this.targetDeltaX - vec3d.x) * 0.2D, (this.targetDeltaY - vec3d.y) * 0.2D, (this.targetDeltaZ - vec3d.z) * 0.2D)); ++ } else if (!this.isNoGravity()) { ++ this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D)); + } + +- HitResult hitResultOnMoveVector = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); +- if (hitResultOnMoveVector.getType() != HitResult.Type.MISS) { +- this.onHit(hitResultOnMoveVector); ++ HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); ++ ++ if (movingobjectposition.getType() != HitResult.EnumMovingObjectType.MISS) { ++ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event + } + } + + this.checkInsideBlocks(); +- Vec3 deltaMovement = this.getDeltaMovement(); +- this.setPos(this.getX() + deltaMovement.x, this.getY() + deltaMovement.y, this.getZ() + deltaMovement.z); ++ vec3d = this.getDeltaMovement(); ++ this.setPos(this.getX() + vec3d.x, this.getY() + vec3d.y, this.getZ() + vec3d.z); + ProjectileUtil.rotateTowardsMovement(this, 0.5F); + if (this.level().isClientSide) { +- this.level() +- .addParticle( +- ParticleTypes.END_ROD, this.getX() - deltaMovement.x, this.getY() - deltaMovement.y + 0.15, this.getZ() - deltaMovement.z, 0.0, 0.0, 0.0 +- ); ++ this.level().addParticle(ParticleTypes.END_ROD, this.getX() - vec3d.x, this.getY() - vec3d.y + 0.15D, this.getZ() - vec3d.z, 0.0D, 0.0D, 0.0D); + } else if (this.finalTarget != null && !this.finalTarget.isRemoved()) { + if (this.flightSteps > 0) { +- this.flightSteps--; ++ --this.flightSteps; + if (this.flightSteps == 0) { + this.selectNextMoveDirection(this.currentMoveDirection == null ? null : this.currentMoveDirection.getAxis()); + } + } + + if (this.currentMoveDirection != null) { +- BlockPos blockPos = this.blockPosition(); +- Direction.Axis axis = this.currentMoveDirection.getAxis(); +- if (this.level().loadedAndEntityCanStandOn(blockPos.relative(this.currentMoveDirection), this)) { +- this.selectNextMoveDirection(axis); ++ BlockPos blockposition = this.blockPosition(); ++ Direction.Axis enumdirection_enumaxis = this.currentMoveDirection.getAxis(); ++ ++ if (this.level().loadedAndEntityCanStandOn(blockposition.relative(this.currentMoveDirection), this)) { ++ this.selectNextMoveDirection(enumdirection_enumaxis); + } else { +- BlockPos blockPos1 = this.finalTarget.blockPosition(); +- if (axis == Direction.Axis.X && blockPos.getX() == blockPos1.getX() +- || axis == Direction.Axis.Z && blockPos.getZ() == blockPos1.getZ() +- || axis == Direction.Axis.Y && blockPos.getY() == blockPos1.getY()) { +- this.selectNextMoveDirection(axis); ++ BlockPos blockposition1 = this.finalTarget.blockPosition(); ++ ++ if (enumdirection_enumaxis == Direction.Axis.X && blockposition.getX() == blockposition1.getX() || enumdirection_enumaxis == Direction.Axis.Z && blockposition.getZ() == blockposition1.getZ() || enumdirection_enumaxis == Direction.Axis.Y && blockposition.getY() == blockposition1.getY()) { ++ this.selectNextMoveDirection(enumdirection_enumaxis); + } + } + } + } ++ + } + + @Override +@@ -271,7 +286,7 @@ + + @Override + public boolean shouldRenderAtSqrDistance(double distance) { +- return distance < 16384.0; ++ return distance < 16384.0D; + } + + @Override +@@ -283,27 +298,31 @@ + protected void onHitEntity(EntityHitResult result) { + super.onHitEntity(result); + Entity entity = result.getEntity(); +- Entity owner = this.getOwner(); +- LivingEntity livingEntity = owner instanceof LivingEntity ? (LivingEntity)owner : null; +- boolean flag = entity.hurt(this.damageSources().mobProjectile(this, livingEntity), 4.0F); ++ Entity entity1 = this.getOwner(); ++ LivingEntity entityliving = entity1 instanceof LivingEntity ? (LivingEntity) entity1 : null; ++ boolean flag = entity.hurt(this.damageSources().mobProjectile(this, entityliving), 4.0F); ++ + if (flag) { +- this.doEnchantDamageEffects(livingEntity, entity); +- if (entity instanceof LivingEntity livingEntity1) { +- livingEntity1.addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200), MoreObjects.firstNonNull(owner, this)); ++ this.doEnchantDamageEffects(entityliving, entity); ++ if (entity instanceof LivingEntity) { ++ LivingEntity entityliving1 = (LivingEntity) entity; ++ ++ entityliving1.addEffect(new MobEffectInstance(MobEffects.LEVITATION, 200), (Entity) MoreObjects.firstNonNull(entity1, this), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + } + } ++ + } + + @Override + protected void onHitBlock(BlockHitResult result) { + super.onHitBlock(result); +- ((ServerLevel)this.level()).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(), this.getZ(), 2, 0.2, 0.2, 0.2, 0.0); ++ ((ServerLevel) this.level()).sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(), this.getZ(), 2, 0.2D, 0.2D, 0.2D, 0.0D); + this.playSound(SoundEvents.SHULKER_BULLET_HIT, 1.0F, 1.0F); + } + + private void destroy() { + this.discard(); +- this.level().gameEvent(GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.Context.of(this)); ++ this.level().gameEvent(GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.Context.of((Entity) this)); + } + + @Override +@@ -319,9 +338,14 @@ + + @Override + public boolean hurt(DamageSource source, float amount) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, amount, false)) { ++ return false; ++ } ++ // CraftBukkit end + if (!this.level().isClientSide) { + this.playSound(SoundEvents.SHULKER_BULLET_HURT, 1.0F, 1.0F); +- ((ServerLevel)this.level()).sendParticles(ParticleTypes.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2, 0.2, 0.2, 0.0); ++ ((ServerLevel) this.level()).sendParticles(ParticleTypes.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D); + this.destroy(); + } + +@@ -331,9 +355,10 @@ + @Override + public void recreateFromPacket(ClientboundAddEntityPacket packet) { + super.recreateFromPacket(packet); +- double xa = packet.getXa(); +- double ya = packet.getYa(); +- double za = packet.getZa(); +- this.setDeltaMovement(xa, ya, za); ++ double d0 = packet.getXa(); ++ double d1 = packet.getYa(); ++ double d2 = packet.getZa(); ++ ++ this.setDeltaMovement(d0, d1, d2); + } + } |