use of org.bukkit.entity.Fish in project Mohist by MohistMC.
the class CraftEventFactory method callPlayerFishBucketEvent.
/**
* Player Fish Bucket Event
*/
public static PlayerBucketEntityEvent callPlayerFishBucketEvent(LivingEntity fish, net.minecraft.world.entity.player.Player entityHuman, ItemStack originalBucket, ItemStack entityBucket) {
Player player = (Player) entityHuman.getBukkitEntity();
PlayerBucketEntityEvent event;
if (fish instanceof AbstractFish) {
event = new PlayerBucketFishEvent(player, (Fish) fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket));
} else {
event = new PlayerBucketEntityEvent(player, fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket));
}
Bukkit.getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.entity.Fish in project CumServerPro by MCUmbrella.
the class EntityFishHook method catchingFish.
private void catchingFish(BlockPos p_190621_1_) {
WorldServer worldserver = (WorldServer) this.world;
int i = 1;
BlockPos blockpos = p_190621_1_.up();
if (this.rand.nextFloat() < 0.25F && this.world.isRainingAt(blockpos)) {
++i;
}
if (this.rand.nextFloat() < 0.5F && !this.world.canSeeSky(blockpos)) {
--i;
}
if (this.ticksCatchable > 0) {
--this.ticksCatchable;
if (this.ticksCatchable <= 0) {
this.ticksCaughtDelay = 0;
this.ticksCatchableDelay = 0;
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.angler.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
} else {
this.motionY -= 0.2D * (double) this.rand.nextFloat() * (double) this.rand.nextFloat();
}
} else if (this.ticksCatchableDelay > 0) {
this.ticksCatchableDelay -= i;
if (this.ticksCatchableDelay > 0) {
this.fishApproachAngle = (float) ((double) this.fishApproachAngle + this.rand.nextGaussian() * 4.0D);
float f = this.fishApproachAngle * 0.017453292F;
float f1 = MathHelper.sin(f);
float f2 = MathHelper.cos(f);
double d0 = this.posX + (double) (f1 * (float) this.ticksCatchableDelay * 0.1F);
double d1 = (double) ((float) MathHelper.floor(this.getEntityBoundingBox().minY) + 1.0F);
double d2 = this.posZ + (double) (f2 * (float) this.ticksCatchableDelay * 0.1F);
IBlockState state = worldserver.getBlockState(new BlockPos(d0, d1 - 1.0D, d2));
if (state.getMaterial() == Material.WATER) {
if (this.rand.nextFloat() < 0.15F) {
worldserver.spawnParticle(EnumParticleTypes.WATER_BUBBLE, d0, d1 - 0.10000000149011612D, d2, 1, (double) f1, 0.1D, (double) f2, 0.0D);
}
float f3 = f1 * 0.04F;
float f4 = f2 * 0.04F;
worldserver.spawnParticle(EnumParticleTypes.WATER_WAKE, d0, d1, d2, 0, (double) f4, 0.01D, (double) (-f3), 1.0D);
worldserver.spawnParticle(EnumParticleTypes.WATER_WAKE, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
}
} else {
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.angler.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return;
}
this.motionY = (double) (-0.4F * MathHelper.nextFloat(this.rand, 0.6F, 1.0F));
this.playSound(SoundEvents.ENTITY_BOBBER_SPLASH, 0.25F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
double d3 = this.getEntityBoundingBox().minY + 0.5D;
worldserver.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX, d3, this.posZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D);
worldserver.spawnParticle(EnumParticleTypes.WATER_WAKE, this.posX, d3, this.posZ, (int) (1.0F + this.width * 20.0F), (double) this.width, 0.0D, (double) this.width, 0.20000000298023224D);
this.ticksCatchable = MathHelper.getInt(this.rand, 20, 40);
}
} else if (this.ticksCaughtDelay > 0) {
this.ticksCaughtDelay -= i;
float f5 = 0.15F;
if (this.ticksCaughtDelay < 20) {
f5 = (float) ((double) f5 + (double) (20 - this.ticksCaughtDelay) * 0.05D);
} else if (this.ticksCaughtDelay < 40) {
f5 = (float) ((double) f5 + (double) (40 - this.ticksCaughtDelay) * 0.02D);
} else if (this.ticksCaughtDelay < 60) {
f5 = (float) ((double) f5 + (double) (60 - this.ticksCaughtDelay) * 0.01D);
}
if (this.rand.nextFloat() < f5) {
float f6 = MathHelper.nextFloat(this.rand, 0.0F, 360.0F) * 0.017453292F;
float f7 = MathHelper.nextFloat(this.rand, 25.0F, 60.0F);
double d4 = this.posX + (double) (MathHelper.sin(f6) * f7 * 0.1F);
double d5 = (double) ((float) MathHelper.floor(this.getEntityBoundingBox().minY) + 1.0F);
double d6 = this.posZ + (double) (MathHelper.cos(f6) * f7 * 0.1F);
IBlockState state = worldserver.getBlockState(new BlockPos((int) d4, (int) d5 - 1, (int) d6));
if (state.getMaterial() == Material.WATER) {
worldserver.spawnParticle(EnumParticleTypes.WATER_SPLASH, d4, d5, d6, 2 + this.rand.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D);
}
}
if (this.ticksCaughtDelay <= 0) {
this.fishApproachAngle = MathHelper.nextFloat(this.rand, 0.0F, 360.0F);
this.ticksCatchableDelay = MathHelper.getInt(this.rand, 20, 80);
}
} else {
this.ticksCaughtDelay = MathHelper.getInt(this.rand, 100, 600);
this.ticksCaughtDelay -= this.lureSpeed * 20 * 5;
}
}
use of org.bukkit.entity.Fish in project CumServerPro by MCUmbrella.
the class EntityFishHook method handleHookRetraction.
public int handleHookRetraction() {
if (!this.world.isRemote && this.angler != null) {
int i = 0;
net.minecraftforge.event.entity.player.ItemFishedEvent event = null;
if (this.caughtEntity != null) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.angler.getBukkitEntity(), this.caughtEntity.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
this.bringInHookedEntity();
this.world.setEntityState(this, (byte) 31);
i = this.caughtEntity instanceof EntityItem ? 3 : 5;
} else if (this.ticksCatchable > 0) {
LootContext.Builder lootcontext$builder = new LootContext.Builder((WorldServer) this.world);
// Forge: add player & looted entity to LootContext
lootcontext$builder.withLuck((float) this.luck + this.angler.getLuck()).withPlayer(this.angler).withLootedEntity(this);
List<ItemStack> result = this.world.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.rand, lootcontext$builder.build());
event = new net.minecraftforge.event.entity.player.ItemFishedEvent(result, this.inGround ? 2 : 1, this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
this.setDead();
return event.getRodDamage();
}
for (ItemStack itemstack : result) {
EntityItem entityitem = new EntityItem(this.world, this.posX, this.posY, this.posZ, itemstack);
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.angler.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
playerFishEvent.setExpToDrop(this.rand.nextInt(6) + 1);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
double d0 = this.angler.posX - this.posX;
double d1 = this.angler.posY - this.posY;
double d2 = this.angler.posZ - this.posZ;
double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
double d4 = 0.1D;
entityitem.motionX = d0 * 0.1D;
entityitem.motionY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D;
entityitem.motionZ = d2 * 0.1D;
this.world.spawnEntity(entityitem);
// CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
if (playerFishEvent.getExpToDrop() > 0) {
this.angler.world.spawnEntity(new EntityXPOrb(this.angler.world, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, playerFishEvent.getExpToDrop()));
}
// CraftBukkit end
Item item = itemstack.getItem();
if (item == Items.FISH || item == Items.COOKED_FISH) {
this.angler.addStat(StatList.FISH_CAUGHT, 1);
}
}
i = 1;
}
if (this.inGround) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.angler.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
i = 2;
}
if (i == 0) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.angler.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
}
this.setDead();
return event == null ? i : event.getRodDamage();
} else {
return 0;
}
}
use of org.bukkit.entity.Fish in project NachoSpigot by CobbleSword.
the class EntityFishingHook method l.
public int l() {
if (this.world.isClientSide) {
return 0;
} else {
byte b0 = 0;
if (this.hooked != null) {
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
// CraftBukkit end
double d0 = this.owner.locX - this.locX;
double d1 = this.owner.locY - this.locY;
double d2 = this.owner.locZ - this.locZ;
double d3 = (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
double d4 = 0.1D;
this.hooked.motX += d0 * d4;
this.hooked.motY += d1 * d4 + (double) MathHelper.sqrt(d3) * 0.08D;
this.hooked.motZ += d2 * d4;
b0 = 3;
} else if (this.av > 0) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, this.m());
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
// CraftBukkit end
double d5 = this.owner.locX - this.locX;
double d6 = this.owner.locY - this.locY;
double d7 = this.owner.locZ - this.locZ;
double d8 = (double) MathHelper.sqrt(d5 * d5 + d6 * d6 + d7 * d7);
double d9 = 0.1D;
entityitem.motX = d5 * d9;
entityitem.motY = d6 * d9 + (double) MathHelper.sqrt(d8) * 0.08D;
entityitem.motZ = d7 * d9;
this.world.addEntity(entityitem);
// CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
if (playerFishEvent.getExpToDrop() > 0) {
this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop()));
}
// CraftBukkit end
b0 = 1;
}
if (this.as) {
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
// CraftBukkit end
b0 = 2;
}
// CraftBukkit start
if (b0 == 0) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
}
// CraftBukkit end
this.die();
this.owner.hookedFish = null;
return b0;
}
}
use of org.bukkit.entity.Fish in project WindSpigot by Wind-Development.
the class EntityFishingHook method l.
public int l() {
if (this.world.isClientSide) {
return 0;
} else {
byte b0 = 0;
if (this.hooked != null) {
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
// CraftBukkit end
double d0 = this.owner.locX - this.locX;
double d1 = this.owner.locY - this.locY;
double d2 = this.owner.locZ - this.locZ;
double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
double d4 = 0.1D;
this.hooked.motX += d0 * d4;
this.hooked.motY += d1 * d4 + MathHelper.sqrt(d3) * 0.08D;
this.hooked.motZ += d2 * d4;
b0 = 3;
} else if (this.av > 0) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, this.m());
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
// CraftBukkit end
double d5 = this.owner.locX - this.locX;
double d6 = this.owner.locY - this.locY;
double d7 = this.owner.locZ - this.locZ;
double d8 = MathHelper.sqrt(d5 * d5 + d6 * d6 + d7 * d7);
double d9 = 0.1D;
entityitem.motX = d5 * d9;
entityitem.motY = d6 * d9 + MathHelper.sqrt(d8) * 0.08D;
entityitem.motZ = d7 * d9;
this.world.addEntity(entityitem);
// playerFishEvent.getExpToDrop()
if (playerFishEvent.getExpToDrop() > 0) {
this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop()));
}
// CraftBukkit end
b0 = 1;
}
if (this.as) {
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
// CraftBukkit end
b0 = 2;
}
// CraftBukkit start
if (b0 == 0) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
}
// CraftBukkit end
this.die();
this.owner.hookedFish = null;
return b0;
}
}
Aggregations