mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 20:07:41 +01:00
Add missing fishing event state
This commit is contained in:
parent
276e09c3b0
commit
64cbea9119
@ -22,11 +22,10 @@
|
|||||||
public class FishingHook extends Projectile {
|
public class FishingHook extends Projectile {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
@@ -67,6 +73,18 @@
|
@@ -68,6 +74,18 @@
|
||||||
public FishingHook.FishHookState currentState;
|
|
||||||
private final int luck;
|
private final int luck;
|
||||||
private final int lureSpeed;
|
private final int lureSpeed;
|
||||||
+
|
|
||||||
+ // CraftBukkit start - Extra variables to enable modification of fishing wait time, values are minecraft defaults
|
+ // CraftBukkit start - Extra variables to enable modification of fishing wait time, values are minecraft defaults
|
||||||
+ public int minWaitTime = 100;
|
+ public int minWaitTime = 100;
|
||||||
+ public int maxWaitTime = 600;
|
+ public int maxWaitTime = 600;
|
||||||
@ -38,9 +37,10 @@
|
|||||||
+ public boolean rainInfluenced = true;
|
+ public boolean rainInfluenced = true;
|
||||||
+ public boolean skyInfluenced = true;
|
+ public boolean skyInfluenced = true;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
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();
|
||||||
@@ -75,13 +93,17 @@
|
@@ -75,13 +93,17 @@
|
||||||
this.currentState = FishingHook.FishHookState.FLYING;
|
this.currentState = FishingHook.FishHookState.FLYING;
|
||||||
this.luck = Math.max(0, luckBonus);
|
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);
|
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,16 +412,25 @@
|
@@ -379,16 +412,34 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.timeUntilLured <= 0) {
|
if (this.timeUntilLured <= 0) {
|
||||||
@ -155,6 +155,15 @@
|
|||||||
+ this.fishAngle = Mth.nextFloat(this.random, this.minLureAngle, this.maxLureAngle);
|
+ this.fishAngle = Mth.nextFloat(this.random, this.minLureAngle, this.maxLureAngle);
|
||||||
+ this.timeUntilHooked = Mth.nextInt(this.random, this.minLureTime, this.maxLureTime);
|
+ this.timeUntilHooked = Mth.nextInt(this.random, this.minLureTime, this.maxLureTime);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+ // Paper start - Add missing fishing event state
|
||||||
|
+ if (this.getPlayerOwner() != null) {
|
||||||
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getPlayerOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.LURED);
|
||||||
|
+ if (!playerFishEvent.callEvent()) {
|
||||||
|
+ this.timeUntilHooked = 0;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Add missing fishing event state
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
- this.timeUntilLured = Mth.nextInt(this.random, 100, 600);
|
- this.timeUntilLured = Mth.nextInt(this.random, 100, 600);
|
||||||
@ -175,7 +184,7 @@
|
|||||||
|
|
||||||
public boolean calculateOpenWater(BlockPos pos) {
|
public boolean calculateOpenWater(BlockPos pos) {
|
||||||
FishingHook.OpenWaterType entityfishinghook_waterposition = FishingHook.OpenWaterType.INVALID;
|
FishingHook.OpenWaterType entityfishinghook_waterposition = FishingHook.OpenWaterType.INVALID;
|
||||||
@@ -445,17 +487,35 @@
|
@@ -445,17 +496,35 @@
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag nbt) {}
|
public void readAdditionalSaveData(CompoundTag nbt) {}
|
||||||
|
|
||||||
@ -212,7 +221,7 @@
|
|||||||
} else if (this.nibble > 0) {
|
} else if (this.nibble > 0) {
|
||||||
LootParams lootparams = (new LootParams.Builder((ServerLevel) this.level())).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, usedItem).withParameter(LootContextParams.THIS_ENTITY, this).withLuck((float) this.luck + entityhuman.getLuck()).create(LootContextParamSets.FISHING);
|
LootParams lootparams = (new LootParams.Builder((ServerLevel) this.level())).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, usedItem).withParameter(LootContextParams.THIS_ENTITY, this).withLuck((float) this.luck + entityhuman.getLuck()).create(LootContextParamSets.FISHING);
|
||||||
LootTable loottable = this.level().getServer().reloadableRegistries().getLootTable(BuiltInLootTables.FISHING);
|
LootTable loottable = this.level().getServer().reloadableRegistries().getLootTable(BuiltInLootTables.FISHING);
|
||||||
@@ -466,15 +526,38 @@
|
@@ -466,15 +535,38 @@
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ItemStack itemstack1 = (ItemStack) iterator.next();
|
ItemStack itemstack1 = (ItemStack) iterator.next();
|
||||||
@ -255,7 +264,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 +567,27 @@
|
@@ -484,10 +576,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.onGround()) {
|
if (this.onGround()) {
|
||||||
@ -284,7 +293,7 @@
|
|||||||
return i;
|
return i;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -496,7 +596,7 @@
|
@@ -496,7 +605,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEntityEvent(byte status) {
|
public void handleEntityEvent(byte status) {
|
||||||
@ -293,7 +302,7 @@
|
|||||||
this.pullEntity(this.hookedIn);
|
this.pullEntity(this.hookedIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,8 +620,15 @@
|
@@ -520,8 +629,15 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(Entity.RemovalReason reason) {
|
public void remove(Entity.RemovalReason reason) {
|
||||||
@ -310,7 +319,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -536,7 +643,7 @@
|
@@ -536,7 +652,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOwnerInfo(@Nullable FishingHook fishingBobber) {
|
private void updateOwnerInfo(@Nullable FishingHook fishingBobber) {
|
||||||
@ -319,7 +328,7 @@
|
|||||||
|
|
||||||
if (entityhuman != null) {
|
if (entityhuman != null) {
|
||||||
entityhuman.fishing = fishingBobber;
|
entityhuman.fishing = fishingBobber;
|
||||||
@@ -545,10 +652,10 @@
|
@@ -545,10 +661,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -332,7 +341,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -575,7 +682,7 @@
|
@@ -575,7 +691,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);
|
||||||
|
Loading…
Reference in New Issue
Block a user