From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Samsuik Date: Fri, 23 Feb 2024 16:18:51 +0000 Subject: [PATCH] Configure potion speed and breaking inside entities diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java index 5f7d152f41eb85f17bcded4bc8099b998e5a338b..81e2161c90001ea941611f1691160df089c1cf97 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java @@ -156,7 +156,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { super.tick(); } - private boolean checkLeftOwner() { + protected boolean checkLeftOwner() { // Sakura - configure potion mechanics Entity entity = this.getOwner(); if (entity != null) { diff --git a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java index e43b3b37a3afc903f057d49d34339f8022274d3e..4ee08ec33bca0313e105053266cfe5345e3e324e 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java @@ -51,7 +51,14 @@ public final class ProjectileUtil { vec3 = hitResult.getLocation(); } - HitResult hitResult2 = getEntityHitResult(world, entity, pos, vec3, entity.getBoundingBox().expandTowards(velocity).inflate(1.0), predicate, margin); + // Sakura start - configure potion mechanics + final HitResult hitResult2; + if (world.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && entity instanceof ThrownPotion) { + hitResult2 = getEntityHitResult(entity, pos, vec3, entity.getBoundingBox().expandTowards(velocity).inflate(1.0), predicate, margin); + } else { + hitResult2 = getEntityHitResult(world, entity, pos, vec3, entity.getBoundingBox().expandTowards(velocity).inflate(1.0), predicate, margin); + } + // Sakura end - configure potion mechanics if (hitResult2 != null) { hitResult = hitResult2; } diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java index 86c4b593a97431efd062b8c9d86bf92269c00536..6bab3cad31d230cff33e1fcdba715a698cd5c787 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java @@ -64,6 +64,25 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie super(EntityType.POTION, x, y, z, world); } + // Sakura start - configure potion mechanics + @Override + public void shoot(double x, double y, double z, float speed, float divergence) { + super.shoot(x, y, z, speed, divergence); + + net.minecraft.world.phys.Vec3 movement = getDeltaMovement(); + double moveX = movement.x * level().sakuraConfig().entity.thrownPotion.horizontalSpeed; + double moveY = movement.y * level().sakuraConfig().entity.thrownPotion.verticalSpeed; + double moveZ = movement.z * level().sakuraConfig().entity.thrownPotion.horizontalSpeed; + + setDeltaMovement(moveX, moveY, moveZ); + } + + @Override + protected final boolean checkLeftOwner() { + return super.checkLeftOwner() || level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && tickCount >= 5; + } + // Sakura end - configure potion mechanics + @Override protected Item getDefaultItem() { return Items.SPLASH_POTION;