net.minecraft.entity.projectile.EntityFishHook Java Examples

The following examples show how to use net.minecraft.entity.projectile.EntityFishHook. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerListener.java    From SkyblockAddons with MIT License 6 votes vote down vote up
private boolean shouldTriggerFishingIndicator() {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.thePlayer != null && mc.thePlayer.fishEntity != null && mc.thePlayer.getHeldItem() != null
            && mc.thePlayer.getHeldItem().getItem().equals(Items.fishing_rod)
            && main.getConfigValues().isEnabled(Feature.FISHING_SOUND_INDICATOR)) {
        // Highly consistent detection by checking when the hook has been in the water for a while and
        // suddenly moves downward. The client may rarely bug out with the idle bobbing and trigger a false positive.
        EntityFishHook bobber = mc.thePlayer.fishEntity;
        long currentTime = System.currentTimeMillis();
        if (bobber.isInWater() && !oldBobberIsInWater) lastBobberEnteredWater = currentTime;
        oldBobberIsInWater = bobber.isInWater();
        if (bobber.isInWater() && Math.abs(bobber.motionX) < 0.01 && Math.abs(bobber.motionZ) < 0.01
                && currentTime - lastFishingAlert > 1000 && currentTime - lastBobberEnteredWater > 1500) {
            double movement = bobber.posY - oldBobberPosY; // The Entity#motionY field is inaccurate for this purpose
            oldBobberPosY = bobber.posY;
            if (movement < -0.04d) {
                lastFishingAlert = currentTime;
                return true;
            }
        }
    }
    return false;
}
 
Example #2
Source File: CraftFish.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.world.isRainingAt(new BlockPos(MathHelper.floor(hook.posX), MathHelper.floor(hook.posY) + 1, MathHelper.floor(hook.posZ)))) {
            return 1 / 300.0;
        }
        return 1 / 500.0;
    }
    return this.biteChance;
}
 
Example #3
Source File: AutoFishHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onPacketInput(WPacketInputEvent event)
{
	EntityPlayerSP player = WMinecraft.getPlayer();
	if(player == null || player.fishEntity == null)
		return;
	
	if(!(event.getPacket() instanceof SPacketSoundEffect))
		return;
	
	// check sound type
	SPacketSoundEffect sound = (SPacketSoundEffect)event.getPacket();
	if(!SoundEvents.ENTITY_BOBBER_SPLASH.equals(sound.getSound()))
		return;
	
	if(debugDraw.isChecked())
		lastSoundPos = new Vec3d(sound.getX(), sound.getY(), sound.getZ());
	
	// check position
	EntityFishHook bobber = player.fishEntity;
	if(Math.abs(sound.getX() - bobber.posX) > validRange.getValue()
		|| Math.abs(sound.getZ() - bobber.posZ) > validRange.getValue())
		return;
	
	// catch fish
	rightClick();
}
 
Example #4
Source File: CraftFish.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public double getBiteChance() {
    EntityFishHook hook = getHandle();

    if (this.biteChance == -1) {
        if (hook.worldObj.canLightningStrikeAt(MathHelper.floor_double(hook.posX), net.minecraft.util.MathHelper.floor_double(hook.posY) + 1, net.minecraft.util.MathHelper.floor_double(hook.posZ))) {
            return 1/300.0;
        }
        return 1/500.0;
    }
    return this.biteChance;
}
 
Example #5
Source File: MixinRenderFish.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Inject(method = "doRender", at = @At("HEAD"))
private void doRender(EntityFishHook entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
    GL11.glLineWidth(1.0F);
}
 
Example #6
Source File: CraftFish.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftFish(CraftServer server, EntityFishHook entity) {
    super(server, entity);
}
 
Example #7
Source File: CraftFish.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityFishHook getHandle() {
    return (EntityFishHook) entity;
}
 
Example #8
Source File: AutoFishHack.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event)
{
	if(!debugDraw.isChecked())
		return;
	
	// GL settings
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glEnable(GL11.GL_LINE_SMOOTH);
	GL11.glLineWidth(2);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	
	GL11.glPushMatrix();
	GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX,
		-TileEntityRendererDispatcher.staticPlayerY,
		-TileEntityRendererDispatcher.staticPlayerZ);
	
	EntityFishHook bobber = WMinecraft.getPlayer().fishEntity;
	if(bobber != null)
	{
		GL11.glPushMatrix();
		GL11.glTranslated(bobber.posX, bobber.posY, bobber.posZ);
		GL11.glCallList(box);
		GL11.glPopMatrix();
	}
	
	if(lastSoundPos != null)
	{
		GL11.glPushMatrix();
		GL11.glTranslated(WVec3d.getX(lastSoundPos),
			WVec3d.getY(lastSoundPos), WVec3d.getZ(lastSoundPos));
		GL11.glCallList(cross);
		GL11.glPopMatrix();
	}
	
	GL11.glPopMatrix();
	
	// GL resets
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
 
Example #9
Source File: CraftFish.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftFish(CraftServer server, EntityFishHook entity) {
    super(server, entity);
}
 
Example #10
Source File: CraftFish.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityFishHook getHandle() {
    return (EntityFishHook) entity;
}