More Projectile API
== AT == public net.minecraft.world.entity.projectile.FishingHook timeUntilLured public net.minecraft.world.entity.projectile.FishingHook fishAngle public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaX public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaY public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ public net.minecraft.world.entity.projectile.ShulkerBullet currentMoveDirection public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps public net.minecraft.world.entity.projectile.AbstractArrow soundEvent public net.minecraft.world.entity.projectile.AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage public net.minecraft.world.entity.projectile.Arrow NO_EFFECT_COLOR public net.minecraft.world.entity.projectile.Projectile hasBeenShot public net.minecraft.world.entity.projectile.Projectile leftOwner public net.minecraft.world.entity.projectile.Projectile ownerUUID public net.minecraft.world.entity.projectile.Projectile preOnHit(Lnet/minecraft/world/phys/HitResult;)V public net.minecraft.world.entity.projectile.Projectile canHitEntity(Lnet/minecraft/world/entity/Entity;)Z public net.minecraft.world.entity.projectile.FireworkRocketEntity getDefaultItem()Lnet/minecraft/world/item/ItemStack; public net.minecraft.world.item.CrossbowItem FIREWORK_POWER Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: SoSeDiK <mrsosedik@gmail.com> Co-authored-by: MelnCat <melncatuwu@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
This commit is contained in:
@@ -22,11 +22,10 @@
|
||||
public class FishingHook extends Projectile {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -67,6 +73,18 @@
|
||||
public FishingHook.FishHookState currentState;
|
||||
@@ -68,6 +74,18 @@
|
||||
private final int luck;
|
||||
private final int lureSpeed;
|
||||
+
|
||||
|
||||
+ // CraftBukkit start - Extra variables to enable modification of fishing wait time, values are minecraft defaults
|
||||
+ public int minWaitTime = 100;
|
||||
+ public int maxWaitTime = 600;
|
||||
@@ -38,9 +37,10 @@
|
||||
+ public boolean rainInfluenced = true;
|
||||
+ public boolean skyInfluenced = true;
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
private FishingHook(EntityType<? extends FishingHook> type, Level world, int luckBonus, int waitTimeReductionTicks) {
|
||||
super(type, world);
|
||||
this.syncronizedRandom = RandomSource.create();
|
||||
@@ -75,13 +93,17 @@
|
||||
this.currentState = FishingHook.FishHookState.FLYING;
|
||||
this.luck = Math.max(0, luckBonus);
|
||||
@@ -145,7 +145,7 @@
|
||||
this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
||||
double d3 = this.getY() + 0.5D;
|
||||
|
||||
@@ -379,12 +412,16 @@
|
||||
@@ -379,16 +412,25 @@
|
||||
}
|
||||
|
||||
if (this.timeUntilLured <= 0) {
|
||||
@@ -160,13 +160,22 @@
|
||||
- this.timeUntilLured = Mth.nextInt(this.random, 100, 600);
|
||||
- this.timeUntilLured -= this.lureSpeed;
|
||||
+ // CraftBukkit start - logic to modify fishing wait time
|
||||
+ this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime);
|
||||
+ this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed ) : 0; // Paper - Fix Lure infinite loop
|
||||
+ this.resetTimeUntilLured(); // Paper - more projectile api - extract time until lured reset logic
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,12 +483,20 @@
|
||||
}
|
||||
+ // Paper start - more projectile api - extract time until lured reset logic
|
||||
+ public void resetTimeUntilLured() {
|
||||
+ this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime);
|
||||
+ this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed ) : 0; // Paper - Fix Lure infinite loop
|
||||
+ }
|
||||
+ // Paper end - more projectile api - extract time until lured reset logic
|
||||
|
||||
public boolean calculateOpenWater(BlockPos pos) {
|
||||
FishingHook.OpenWaterType entityfishinghook_waterposition = FishingHook.OpenWaterType.INVALID;
|
||||
@@ -446,12 +488,20 @@
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {}
|
||||
|
||||
public int retrieve(ItemStack usedItem) {
|
||||
@@ -188,7 +197,7 @@
|
||||
this.pullEntity(this.hookedIn);
|
||||
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) entityhuman, usedItem, this, Collections.emptyList());
|
||||
this.level().broadcastEntityEvent(this, (byte) 31);
|
||||
@@ -466,15 +511,38 @@
|
||||
@@ -466,15 +516,38 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ItemStack itemstack1 = (ItemStack) iterator.next();
|
||||
@@ -231,7 +240,7 @@
|
||||
if (itemstack1.is(ItemTags.FISHES)) {
|
||||
entityhuman.awardStat(Stats.FISH_CAUGHT, 1);
|
||||
}
|
||||
@@ -484,10 +552,27 @@
|
||||
@@ -484,10 +557,27 @@
|
||||
}
|
||||
|
||||
if (this.onGround()) {
|
||||
@@ -260,7 +269,7 @@
|
||||
return i;
|
||||
} else {
|
||||
return 0;
|
||||
@@ -496,7 +581,7 @@
|
||||
@@ -496,7 +586,7 @@
|
||||
|
||||
@Override
|
||||
public void handleEntityEvent(byte status) {
|
||||
@@ -269,7 +278,7 @@
|
||||
this.pullEntity(this.hookedIn);
|
||||
}
|
||||
|
||||
@@ -520,8 +605,15 @@
|
||||
@@ -520,8 +610,15 @@
|
||||
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason reason) {
|
||||
@@ -286,7 +295,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -536,7 +628,7 @@
|
||||
@@ -536,7 +633,7 @@
|
||||
}
|
||||
|
||||
private void updateOwnerInfo(@Nullable FishingHook fishingBobber) {
|
||||
@@ -295,7 +304,7 @@
|
||||
|
||||
if (entityhuman != null) {
|
||||
entityhuman.fishing = fishingBobber;
|
||||
@@ -545,10 +637,10 @@
|
||||
@@ -545,10 +642,10 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -308,7 +317,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -575,7 +667,7 @@
|
||||
@@ -575,7 +672,7 @@
|
||||
int i = packet.getData();
|
||||
|
||||
FishingHook.LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(i), i);
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - call projectile hit event
|
||||
+ protected ProjectileDeflection preHitTargetOrDeflectSelf(HitResult movingobjectposition) {
|
||||
+ public ProjectileDeflection preHitTargetOrDeflectSelf(HitResult movingobjectposition) { // Paper - protected -> public
|
||||
+ org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition);
|
||||
+ this.hitCancelled = event != null && event.isCancelled();
|
||||
+ if (movingobjectposition.getType() == HitResult.Type.BLOCK || !this.hitCancelled) {
|
||||
|
||||
@@ -55,7 +55,18 @@
|
||||
super(EntityType.POTION, owner, world, stack);
|
||||
}
|
||||
|
||||
@@ -99,64 +109,86 @@
|
||||
@@ -93,70 +103,96 @@
|
||||
@Override
|
||||
protected void onHit(HitResult hitResult) {
|
||||
super.onHit(hitResult);
|
||||
+ // Paper start - More projectile API
|
||||
+ this.splash(hitResult);
|
||||
+ }
|
||||
+ public void splash(@Nullable HitResult hitResult) {
|
||||
+ // Paper end - More projectile API
|
||||
Level world = this.level();
|
||||
-
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
ItemStack itemstack = this.getItem();
|
||||
PotionContents potioncontents = (PotionContents) itemstack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
|
||||
|
||||
@@ -70,7 +81,7 @@
|
||||
+ showParticles = this.makeAreaOfEffectCloud(potioncontents, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper
|
||||
} else {
|
||||
- this.applySplash(worldserver, potioncontents.getAllEffects(), hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null);
|
||||
+ showParticles = this.applySplash(worldserver, potioncontents.getAllEffects(), hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper
|
||||
+ showParticles = this.applySplash(worldserver, potioncontents.getAllEffects(), hitResult != null && hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null, hitResult); // CraftBukkit - Pass MovingObjectPosition // Paper - More projectile API
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +157,7 @@
|
||||
}
|
||||
|
||||
- private void applySplash(ServerLevel world, Iterable<MobEffectInstance> effects, @Nullable Entity entity) {
|
||||
+ private boolean applySplash(ServerLevel worldserver, Iterable<MobEffectInstance> iterable, @Nullable Entity entity, HitResult position) { // CraftBukkit - Pass MovingObjectPosition // Paper - Fix potions splash events
|
||||
+ private boolean applySplash(ServerLevel worldserver, Iterable<MobEffectInstance> iterable, @Nullable Entity entity, @Nullable HitResult position) { // CraftBukkit - Pass MovingObjectPosition // Paper - Fix potions splash events & More projectile API
|
||||
AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
|
||||
- List<LivingEntity> list = world.getEntitiesOfClass(LivingEntity.class, axisalignedbb);
|
||||
+ List<net.minecraft.world.entity.LivingEntity> list = worldserver.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb);
|
||||
@@ -162,7 +173,7 @@
|
||||
|
||||
if (entityliving.isAffectedByPotions()) {
|
||||
double d0 = this.distanceToSqr((Entity) entityliving);
|
||||
@@ -164,43 +196,71 @@
|
||||
@@ -164,43 +200,71 @@
|
||||
if (d0 < 16.0D) {
|
||||
double d1;
|
||||
|
||||
@@ -242,7 +253,7 @@
|
||||
}
|
||||
|
||||
- private void makeAreaOfEffectCloud(PotionContents potion) {
|
||||
+ private boolean makeAreaOfEffectCloud(PotionContents potioncontents, HitResult position) { // CraftBukkit - Pass MovingObjectPosition
|
||||
+ private boolean makeAreaOfEffectCloud(PotionContents potioncontents, @Nullable HitResult position) { // CraftBukkit - Pass MovingObjectPosition // Paper - More projectile API
|
||||
AreaEffectCloud entityareaeffectcloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
|
||||
Entity entity = this.getOwner();
|
||||
|
||||
@@ -251,7 +262,7 @@
|
||||
entityareaeffectcloud.setOwner(entityliving);
|
||||
}
|
||||
|
||||
@@ -208,8 +268,17 @@
|
||||
@@ -208,8 +272,17 @@
|
||||
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
||||
entityareaeffectcloud.setWaitTime(10);
|
||||
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration());
|
||||
@@ -271,7 +282,7 @@
|
||||
}
|
||||
|
||||
public boolean isLingering() {
|
||||
@@ -220,19 +289,31 @@
|
||||
@@ -220,19 +293,31 @@
|
||||
BlockState iblockdata = this.level().getBlockState(pos);
|
||||
|
||||
if (iblockdata.is(BlockTags.FIRE)) {
|
||||
|
||||
Reference in New Issue
Block a user