mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -07:00
Configurable fishing time ranges
This commit is contained in:
@@ -41,7 +41,17 @@
|
|||||||
private FishingHook(EntityType<? extends FishingHook> type, Level world, int luckBonus, int waitTimeReductionTicks) {
|
private FishingHook(EntityType<? extends FishingHook> type, Level world, int luckBonus, int waitTimeReductionTicks) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
this.syncronizedRandom = RandomSource.create();
|
this.syncronizedRandom = RandomSource.create();
|
||||||
@@ -81,7 +99,7 @@
|
@@ -75,13 +93,17 @@
|
||||||
|
this.currentState = FishingHook.FishHookState.FLYING;
|
||||||
|
this.luck = Math.max(0, luckBonus);
|
||||||
|
this.lureSpeed = Math.max(0, waitTimeReductionTicks);
|
||||||
|
+ // Paper start - Configurable fishing time ranges
|
||||||
|
+ minWaitTime = world.paperConfig().fishingTimeRange.minimum;
|
||||||
|
+ maxWaitTime = world.paperConfig().fishingTimeRange.maximum;
|
||||||
|
+ // Paper end - Configurable fishing time ranges
|
||||||
|
}
|
||||||
|
|
||||||
|
public FishingHook(EntityType<? extends FishingHook> type, Level world) {
|
||||||
this(type, world, 0, 0);
|
this(type, world, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +60,7 @@
|
|||||||
this(EntityType.FISHING_BOBBER, world, luckBonus, waitTimeReductionTicks);
|
this(EntityType.FISHING_BOBBER, world, luckBonus, waitTimeReductionTicks);
|
||||||
this.setOwner(thrower);
|
this.setOwner(thrower);
|
||||||
float f = thrower.getXRot();
|
float f = thrower.getXRot();
|
||||||
@@ -149,15 +167,15 @@
|
@@ -149,15 +171,15 @@
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.syncronizedRandom.setSeed(this.getUUID().getLeastSignificantBits() ^ this.level().getGameTime());
|
this.syncronizedRandom.setSeed(this.getUUID().getLeastSignificantBits() ^ this.level().getGameTime());
|
||||||
super.tick();
|
super.tick();
|
||||||
@@ -69,7 +79,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -250,7 +268,7 @@
|
@@ -250,7 +272,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +88,7 @@
|
|||||||
ItemStack itemstack = player.getMainHandItem();
|
ItemStack itemstack = player.getMainHandItem();
|
||||||
ItemStack itemstack1 = player.getOffhandItem();
|
ItemStack itemstack1 = player.getOffhandItem();
|
||||||
boolean flag = itemstack.is(Items.FISHING_ROD);
|
boolean flag = itemstack.is(Items.FISHING_ROD);
|
||||||
@@ -259,7 +277,7 @@
|
@@ -259,7 +281,7 @@
|
||||||
if (!player.isRemoved() && player.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) player) <= 1024.0D) {
|
if (!player.isRemoved() && player.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) player) <= 1024.0D) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -87,7 +97,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,7 +285,7 @@
|
@@ -267,7 +289,7 @@
|
||||||
private void checkCollision() {
|
private void checkCollision() {
|
||||||
HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
|
HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
|
||||||
|
|
||||||
@@ -96,7 +106,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -300,11 +318,11 @@
|
@@ -300,11 +322,11 @@
|
||||||
int i = 1;
|
int i = 1;
|
||||||
BlockPos blockposition1 = pos.above();
|
BlockPos blockposition1 = pos.above();
|
||||||
|
|
||||||
@@ -110,7 +120,7 @@
|
|||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,6 +332,10 @@
|
@@ -314,6 +336,10 @@
|
||||||
this.timeUntilLured = 0;
|
this.timeUntilLured = 0;
|
||||||
this.timeUntilHooked = 0;
|
this.timeUntilHooked = 0;
|
||||||
this.getEntityData().set(FishingHook.DATA_BITING, false);
|
this.getEntityData().set(FishingHook.DATA_BITING, false);
|
||||||
@@ -121,7 +131,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
float f;
|
float f;
|
||||||
@@ -347,6 +369,13 @@
|
@@ -347,6 +373,13 @@
|
||||||
worldserver.sendParticles(ParticleTypes.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
|
worldserver.sendParticles(ParticleTypes.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -135,7 +145,7 @@
|
|||||||
this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
||||||
double d3 = this.getY() + 0.5D;
|
double d3 = this.getY() + 0.5D;
|
||||||
|
|
||||||
@@ -379,12 +408,16 @@
|
@@ -379,12 +412,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.timeUntilLured <= 0) {
|
if (this.timeUntilLured <= 0) {
|
||||||
@@ -151,12 +161,12 @@
|
|||||||
- this.timeUntilLured -= this.lureSpeed;
|
- this.timeUntilLured -= this.lureSpeed;
|
||||||
+ // CraftBukkit start - logic to modify fishing wait time
|
+ // CraftBukkit start - logic to modify fishing wait time
|
||||||
+ this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime);
|
+ this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime);
|
||||||
+ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed : 0;
|
+ this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed ) : 0; // Paper - Fix Lure infinite loop
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,12 +479,20 @@
|
@@ -446,12 +483,20 @@
|
||||||
public void readAdditionalSaveData(CompoundTag nbt) {}
|
public void readAdditionalSaveData(CompoundTag nbt) {}
|
||||||
|
|
||||||
public int retrieve(ItemStack usedItem) {
|
public int retrieve(ItemStack usedItem) {
|
||||||
@@ -178,7 +188,7 @@
|
|||||||
this.pullEntity(this.hookedIn);
|
this.pullEntity(this.hookedIn);
|
||||||
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) entityhuman, usedItem, this, Collections.emptyList());
|
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) entityhuman, usedItem, this, Collections.emptyList());
|
||||||
this.level().broadcastEntityEvent(this, (byte) 31);
|
this.level().broadcastEntityEvent(this, (byte) 31);
|
||||||
@@ -467,6 +508,15 @@
|
@@ -467,6 +512,15 @@
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ItemStack itemstack1 = (ItemStack) iterator.next();
|
ItemStack itemstack1 = (ItemStack) iterator.next();
|
||||||
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1);
|
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1);
|
||||||
@@ -194,7 +204,7 @@
|
|||||||
double d0 = entityhuman.getX() - this.getX();
|
double d0 = entityhuman.getX() - this.getX();
|
||||||
double d1 = entityhuman.getY() - this.getY();
|
double d1 = entityhuman.getY() - this.getY();
|
||||||
double d2 = entityhuman.getZ() - this.getZ();
|
double d2 = entityhuman.getZ() - this.getZ();
|
||||||
@@ -474,7 +524,11 @@
|
@@ -474,7 +528,11 @@
|
||||||
|
|
||||||
entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
|
entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
|
||||||
this.level().addFreshEntity(entityitem);
|
this.level().addFreshEntity(entityitem);
|
||||||
@@ -207,7 +217,7 @@
|
|||||||
if (itemstack1.is(ItemTags.FISHES)) {
|
if (itemstack1.is(ItemTags.FISHES)) {
|
||||||
entityhuman.awardStat(Stats.FISH_CAUGHT, 1);
|
entityhuman.awardStat(Stats.FISH_CAUGHT, 1);
|
||||||
}
|
}
|
||||||
@@ -484,10 +538,27 @@
|
@@ -484,10 +542,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.onGround()) {
|
if (this.onGround()) {
|
||||||
@@ -236,7 +246,7 @@
|
|||||||
return i;
|
return i;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -496,7 +567,7 @@
|
@@ -496,7 +571,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEntityEvent(byte status) {
|
public void handleEntityEvent(byte status) {
|
||||||
@@ -245,7 +255,7 @@
|
|||||||
this.pullEntity(this.hookedIn);
|
this.pullEntity(this.hookedIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,8 +591,15 @@
|
@@ -520,8 +595,15 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(Entity.RemovalReason reason) {
|
public void remove(Entity.RemovalReason reason) {
|
||||||
@@ -262,7 +272,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -536,7 +614,7 @@
|
@@ -536,7 +618,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOwnerInfo(@Nullable FishingHook fishingBobber) {
|
private void updateOwnerInfo(@Nullable FishingHook fishingBobber) {
|
||||||
@@ -271,7 +281,7 @@
|
|||||||
|
|
||||||
if (entityhuman != null) {
|
if (entityhuman != null) {
|
||||||
entityhuman.fishing = fishingBobber;
|
entityhuman.fishing = fishingBobber;
|
||||||
@@ -545,10 +623,10 @@
|
@@ -545,10 +627,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -284,7 +294,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -575,7 +653,7 @@
|
@@ -575,7 +657,7 @@
|
||||||
int i = packet.getData();
|
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);
|
FishingHook.LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(i), i);
|
||||||
|
Reference in New Issue
Block a user