diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownTrident.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownTrident.java.patch | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownTrident.java.patch new file mode 100644 index 0000000000..6f6538c6eb --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/ThrownTrident.java.patch @@ -0,0 +1,215 @@ +--- a/net/minecraft/world/entity/projectile/ThrownTrident.java ++++ b/net/minecraft/world/entity/projectile/ThrownTrident.java +@@ -25,6 +25,7 @@ + import net.minecraft.world.phys.Vec3; + + public class ThrownTrident extends AbstractArrow { ++ + private static final EntityDataAccessor<Byte> ID_LOYALTY = SynchedEntityData.defineId(ThrownTrident.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor<Boolean> ID_FOIL = SynchedEntityData.defineId(ThrownTrident.class, EntityDataSerializers.BOOLEAN); + private static final ItemStack DEFAULT_ARROW_STACK = new ItemStack(Items.TRIDENT); +@@ -32,20 +33,20 @@ + public int clientSideReturnTridentTickCount; + + public ThrownTrident(EntityType<? extends ThrownTrident> entityType, Level level) { +- super(entityType, level, DEFAULT_ARROW_STACK); ++ super(entityType, level, ThrownTrident.DEFAULT_ARROW_STACK); + } + + public ThrownTrident(Level level, LivingEntity shooter, ItemStack stack) { + super(EntityType.TRIDENT, shooter, level, stack); +- this.entityData.set(ID_LOYALTY, (byte)EnchantmentHelper.getLoyalty(stack)); +- this.entityData.set(ID_FOIL, stack.hasFoil()); ++ this.entityData.set(ThrownTrident.ID_LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack)); ++ this.entityData.set(ThrownTrident.ID_FOIL, stack.hasFoil()); + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(ID_LOYALTY, (byte)0); +- this.entityData.define(ID_FOIL, false); ++ this.entityData.define(ThrownTrident.ID_LOYALTY, (byte) 0); ++ this.entityData.define(ThrownTrident.ID_FOIL, false); + } + + @Override +@@ -54,9 +55,10 @@ + this.dealtDamage = true; + } + +- Entity owner = this.getOwner(); +- int i = this.entityData.get(ID_LOYALTY); +- if (i > 0 && (this.dealtDamage || this.isNoPhysics()) && owner != null) { ++ Entity entity = this.getOwner(); ++ byte b0 = (Byte) this.entityData.get(ThrownTrident.ID_LOYALTY); ++ ++ if (b0 > 0 && (this.dealtDamage || this.isNoPhysics()) && entity != null) { + if (!this.isAcceptibleReturnOwner()) { + if (!this.level().isClientSide && this.pickup == AbstractArrow.Pickup.ALLOWED) { + this.spawnAtLocation(this.getPickupItem(), 0.1F); +@@ -65,19 +67,21 @@ + this.discard(); + } else { + this.setNoPhysics(true); +- Vec3 vec3 = owner.getEyePosition().subtract(this.position()); +- this.setPosRaw(this.getX(), this.getY() + vec3.y * 0.015 * (double)i, this.getZ()); ++ Vec3 vec3d = entity.getEyePosition().subtract(this.position()); ++ ++ this.setPosRaw(this.getX(), this.getY() + vec3d.y * 0.015D * (double) b0, this.getZ()); + if (this.level().isClientSide) { + this.yOld = this.getY(); + } + +- double d = 0.05 * (double)i; +- this.setDeltaMovement(this.getDeltaMovement().scale(0.95).add(vec3.normalize().scale(d))); ++ double d0 = 0.05D * (double) b0; ++ ++ this.setDeltaMovement(this.getDeltaMovement().scale(0.95D).add(vec3d.normalize().scale(d0))); + if (this.clientSideReturnTridentTickCount == 0) { + this.playSound(SoundEvents.TRIDENT_RETURN, 10.0F, 1.0F); + } + +- this.clientSideReturnTridentTickCount++; ++ ++this.clientSideReturnTridentTickCount; + } + } + +@@ -85,12 +89,13 @@ + } + + private boolean isAcceptibleReturnOwner() { +- Entity owner = this.getOwner(); +- return owner != null && owner.isAlive() && (!(owner instanceof ServerPlayer) || !owner.isSpectator()); ++ Entity entity = this.getOwner(); ++ ++ return entity != null && entity.isAlive() ? !(entity instanceof ServerPlayer) || !entity.isSpectator() : false; + } + + public boolean isFoil() { +- return this.entityData.get(ID_FOIL); ++ return (Boolean) this.entityData.get(ThrownTrident.ID_FOIL); + } + + @Nullable +@@ -103,49 +108,59 @@ + protected void onHitEntity(EntityHitResult result) { + Entity entity = result.getEntity(); + float f = 8.0F; +- if (entity instanceof LivingEntity livingEntity) { +- f += EnchantmentHelper.getDamageBonus(this.getPickupItemStackOrigin(), livingEntity.getMobType()); ++ ++ if (entity instanceof LivingEntity) { ++ LivingEntity entityliving = (LivingEntity) entity; ++ ++ f += EnchantmentHelper.getDamageBonus(this.getPickupItemStackOrigin(), entityliving.getMobType()); + } + +- Entity owner = this.getOwner(); +- DamageSource damageSource = this.damageSources().trident(this, (Entity)(owner == null ? this : owner)); ++ Entity entity1 = this.getOwner(); ++ DamageSource damagesource = this.damageSources().trident(this, (Entity) (entity1 == null ? this : entity1)); ++ + this.dealtDamage = true; +- SoundEvent soundEvent = SoundEvents.TRIDENT_HIT; +- if (entity.hurt(damageSource, f)) { ++ SoundEvent soundeffect = SoundEvents.TRIDENT_HIT; ++ ++ if (entity.hurt(damagesource, f)) { + if (entity.getType() == EntityType.ENDERMAN) { + return; + } + +- if (entity instanceof LivingEntity livingEntity1) { +- if (owner instanceof LivingEntity) { +- EnchantmentHelper.doPostHurtEffects(livingEntity1, owner); +- EnchantmentHelper.doPostDamageEffects((LivingEntity)owner, livingEntity1); ++ if (entity instanceof LivingEntity) { ++ LivingEntity entityliving1 = (LivingEntity) entity; ++ ++ if (entity1 instanceof LivingEntity) { ++ EnchantmentHelper.doPostHurtEffects(entityliving1, entity1); ++ EnchantmentHelper.doPostDamageEffects((LivingEntity) entity1, entityliving1); + } + +- this.doPostHurtEffects(livingEntity1); ++ this.doPostHurtEffects(entityliving1); + } + } else if (entity.getType().is(EntityTypeTags.DEFLECTS_TRIDENTS)) { + this.deflect(); + return; + } + +- this.setDeltaMovement(this.getDeltaMovement().multiply(-0.01, -0.1, -0.01)); ++ this.setDeltaMovement(this.getDeltaMovement().multiply(-0.01D, -0.1D, -0.01D)); + float f1 = 1.0F; ++ + if (this.level() instanceof ServerLevel && this.level().isThundering() && this.isChanneling()) { +- BlockPos blockPos = entity.blockPosition(); +- if (this.level().canSeeSky(blockPos)) { +- LightningBolt lightningBolt = EntityType.LIGHTNING_BOLT.create(this.level()); +- if (lightningBolt != null) { +- lightningBolt.moveTo(Vec3.atBottomCenterOf(blockPos)); +- lightningBolt.setCause(owner instanceof ServerPlayer ? (ServerPlayer)owner : null); +- this.level().addFreshEntity(lightningBolt); +- soundEvent = SoundEvents.TRIDENT_THUNDER; ++ BlockPos blockposition = entity.blockPosition(); ++ ++ if (this.level().canSeeSky(blockposition)) { ++ LightningBolt entitylightning = (LightningBolt) EntityType.LIGHTNING_BOLT.create(this.level()); ++ ++ if (entitylightning != null) { ++ entitylightning.moveTo(Vec3.atBottomCenterOf(blockposition)); ++ entitylightning.setCause(entity1 instanceof ServerPlayer ? (ServerPlayer) entity1 : null); ++ ((ServerLevel) this.level()).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit ++ soundeffect = SoundEvents.TRIDENT_THUNDER; + f1 = 5.0F; + } + } + } + +- this.playSound(soundEvent, f1, 1.0F); ++ this.playSound(soundeffect, f1, 1.0F); + } + + public boolean isChanneling() { +@@ -167,13 +182,14 @@ + if (this.ownedBy(entity) || this.getOwner() == null) { + super.playerTouch(entity); + } ++ + } + + @Override + public void readAdditionalSaveData(CompoundTag compound) { + super.readAdditionalSaveData(compound); + this.dealtDamage = compound.getBoolean("DealtDamage"); +- this.entityData.set(ID_LOYALTY, (byte)EnchantmentHelper.getLoyalty(this.getPickupItemStackOrigin())); ++ this.entityData.set(ThrownTrident.ID_LOYALTY, (byte) EnchantmentHelper.getLoyalty(this.getPickupItemStackOrigin())); + } + + @Override +@@ -184,10 +200,12 @@ + + @Override + public void tickDespawn() { +- int i = this.entityData.get(ID_LOYALTY); +- if (this.pickup != AbstractArrow.Pickup.ALLOWED || i <= 0) { ++ byte b0 = (Byte) this.entityData.get(ThrownTrident.ID_LOYALTY); ++ ++ if (this.pickup != AbstractArrow.Pickup.ALLOWED || b0 <= 0) { + super.tickDespawn(); + } ++ + } + + @Override +@@ -196,7 +214,7 @@ + } + + @Override +- public boolean shouldRender(double x, double y, double z) { ++ public boolean shouldRender(double x, double d1, double y) { + return true; + } + } |