Files
CatServer/patches/net/minecraft/item/ItemFishingRod.java.patch
2019-02-24 22:29:41 +08:00

36 lines
1.8 KiB
Diff

--- ../src-base/minecraft/net/minecraft/item/ItemFishingRod.java
+++ ../src-work/minecraft/net/minecraft/item/ItemFishingRod.java
@@ -16,6 +16,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.event.player.PlayerFishEvent;
public class ItemFishingRod extends Item
{
@@ -74,7 +75,7 @@
}
else
{
- worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
+ // worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
if (!worldIn.isRemote)
{
@@ -93,6 +94,15 @@
entityfishhook.setLuck(k);
}
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) playerIn.getBukkitEntity(), null, (org.bukkit.entity.Fish) entityfishhook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
+ worldIn.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ playerIn.fishEntity = null;
+ return new ActionResult<>(EnumActionResult.PASS, itemstack);
+ }
+ worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
+
worldIn.spawnEntity(entityfishhook);
}