use of net.minecraft.entity.projectile.FishingBobberEntity in project LoliServer by Loli-Server.
the class CraftFishHook method setMaxWaitTime.
@Override
public void setMaxWaitTime(int maxWaitTime) {
FishingBobberEntity hook = getHandle();
Validate.isTrue(maxWaitTime >= 0 && maxWaitTime >= this.getMinWaitTime(), "The maximum wait time should be higher than or equal to 0 and the minimum wait time.");
hook.maxWaitTime = maxWaitTime;
}
use of net.minecraft.entity.projectile.FishingBobberEntity in project LoliServer by Loli-Server.
the class CraftFishHook method setMinWaitTime.
@Override
public void setMinWaitTime(int minWaitTime) {
FishingBobberEntity hook = getHandle();
Validate.isTrue(minWaitTime >= 0 && minWaitTime <= this.getMaxWaitTime(), "The minimum wait time should be between 0 and the maximum wait time.");
hook.minWaitTime = minWaitTime;
}
use of net.minecraft.entity.projectile.FishingBobberEntity in project Arclight by IzzelAliz.
the class FishingRodItemMixin method onItemRightClick.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
if (playerIn.fishingBobber != null) {
if (!worldIn.isRemote) {
int i = playerIn.fishingBobber.handleHookRetraction(itemstack);
itemstack.damageItem(i, playerIn, (p_220000_1_) -> {
p_220000_1_.sendBreakAnimation(handIn);
});
}
playerIn.swingArm(handIn);
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
} else {
if (!worldIn.isRemote) {
int k = EnchantmentHelper.getFishingSpeedBonus(itemstack);
int j = EnchantmentHelper.getFishingLuckBonus(itemstack);
FishingBobberEntity hook = new FishingBobberEntity(playerIn, worldIn, j, k);
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity(), null, (FishHook) ((EntityBridge) hook).bridge$getBukkitEntity(), PlayerFishEvent.State.FISHING);
Bukkit.getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
playerIn.fishingBobber = null;
return new ActionResult<>(ActionResultType.PASS, itemstack);
}
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
worldIn.addEntity(new FishingBobberEntity(playerIn, worldIn, j, k));
}
// playerIn.swingArm(handIn);
playerIn.addStat(Stats.ITEM_USED.get(this));
}
return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
}
use of net.minecraft.entity.projectile.FishingBobberEntity in project Arclight by IzzelAliz.
the class FishingBobberEntityMixin method handleHookRetraction.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
public int handleHookRetraction(ItemStack p_146034_1_) {
if (!this.world.isRemote && this.angler != null) {
int i = 0;
ItemFishedEvent event = null;
if (this.caughtEntity != null) {
PlayerFishEvent fishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), ((EntityBridge) this.caughtEntity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
Bukkit.getPluginManager().callEvent(fishEvent);
if (fishEvent.isCancelled()) {
return 0;
}
this.bringInHookedEntity();
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) this.angler, p_146034_1_, (FishingBobberEntity) (Object) this, Collections.emptyList());
this.world.setEntityState((FishingBobberEntity) (Object) this, (byte) 31);
i = this.caughtEntity instanceof ItemEntity ? 3 : 5;
} else if (this.ticksCatchable > 0) {
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerWorld) this.world)).withParameter(LootParameters.POSITION, new BlockPos((FishingBobberEntity) (Object) this)).withParameter(LootParameters.TOOL, p_146034_1_).withRandom(this.rand).withLuck((float) this.luck + this.angler.getLuck());
lootcontext$builder.withParameter(LootParameters.KILLER_ENTITY, this.angler).withParameter(LootParameters.THIS_ENTITY, (FishingBobberEntity) (Object) this);
LootTable loottable = this.world.getServer().getLootTableManager().getLootTableFromLocation(LootTables.GAMEPLAY_FISHING);
List<ItemStack> list = loottable.generate(lootcontext$builder.build(LootParameterSets.FISHING));
event = new ItemFishedEvent(list, this.inGround ? 2 : 1, (FishingBobberEntity) (Object) this);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
this.remove();
return event.getRodDamage();
}
CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayerEntity) this.angler, p_146034_1_, (FishingBobberEntity) (Object) this, list);
for (ItemStack itemstack : list) {
ItemEntity itementity = new ItemEntity(this.world, this.posX, this.posY, this.posZ, itemstack);
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), ((EntityBridge) itementity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
playerFishEvent.setExpToDrop(this.rand.nextInt(6) + 1);
Bukkit.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 = 0.1D;
itementity.setMotion(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
this.world.addEntity(itementity);
if (playerFishEvent.getExpToDrop() > 0) {
this.angler.world.addEntity(new ExperienceOrbEntity(this.angler.world, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, playerFishEvent.getExpToDrop()));
}
if (itemstack.getItem().isIn(ItemTags.FISHES)) {
this.angler.addStat(Stats.FISH_CAUGHT, 1);
}
}
i = 1;
}
if (this.inGround) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
Bukkit.getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
i = 2;
}
if (i == 0) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) this.angler).bridge$getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
Bukkit.getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return 0;
}
}
this.remove();
return event == null ? i : event.getRodDamage();
} else {
return 0;
}
}
use of net.minecraft.entity.projectile.FishingBobberEntity in project Client by MatHax.
the class AutoFish method onPlaySound.
@EventHandler
private void onPlaySound(PlaySoundEvent event) {
SoundInstance p = event.sound;
FishingBobberEntity b = mc.player.fishHook;
if (p.getId().getPath().equals("entity.fishing_bobber.splash")) {
if (!splashDetectionRangeEnabled.get() || Utils.distance(b.getX(), b.getY(), b.getZ(), p.getX(), p.getY(), p.getZ()) <= splashDetectionRange.get()) {
ticksEnabled = true;
ticksToRightClick = ticksCatch.get();
ticksData = 0;
}
}
}
Aggregations