Jump to content

[1.17] Custom fishing rod error


ocome

Recommended Posts

https://github.com/MinecraftForge/MinecraftForge/pull/8168/files

I am trying to use this, but when I create the CustomFishingHook, the call to super.tick goes wrong and does not work properly.

I would like to know how to run the supertick (Projectile.tick) and what the solution is.

https://github.com/ocome85/Fishing-Mod/blob/main/src/main/java/com/ocome/ocomefishingmod/item/CustomFishingHook.java#L252

Link to comment
Share on other sites

I tried to create it, but CustomFishingHook shouldStopFishing is not referenced.

 

resources/META-INF/accesstransformer.cfg

protected net.minecraft.world.entity.projectile.FishingHook
protected net.minecraft.world.entity.projectile.FishingHook$shouldStopFishing

CustomFishingHook 

public class CustomFishingHookaa extends FishingHook{
    @Nullable

    public CustomFishingHookaa(EntityType<? extends CustomFishingHookaa> p_150138_, Level p_150139_, int p_150143_, int p_150144_) {
        super(p_150138_, p_150139_);
        this.noCulling = true;

    }

    public CustomFishingHookaa(Player p_37106_, Level p_37107_, int p_37108_, int p_37109_) {
        this(ModEntities.MODFISHING_BOBBER, p_37107_, p_37108_, p_37109_);
        this.setOwner(p_37106_);
        float f = p_37106_.getXRot();
        float f1 = p_37106_.getYRot();
        float f2 = Mth.cos(-f1 * ((float)Math.PI / 180F) - (float)Math.PI);
        float f3 = Mth.sin(-f1 * ((float)Math.PI / 180F) - (float)Math.PI);
        float f4 = -Mth.cos(-f * ((float)Math.PI / 180F));
        float f5 = Mth.sin(-f * ((float)Math.PI / 180F));
        double d0 = p_37106_.getX() - (double)f3 * 0.3D;
        double d1 = p_37106_.getEyeY();
        double d2 = p_37106_.getZ() - (double)f2 * 0.3D;
        this.moveTo(d0, d1, d2, f1, f);
        Vec3 vec3 = new Vec3((double)(-f3), (double)Mth.clamp(-(f5 / f4), -5.0F, 5.0F), (double)(-f2));
        double d3 = vec3.length();
        vec3 = vec3.multiply(0.6D / d3 + 0.5D + this.random.nextGaussian() * 0.0045D, 0.6D / d3 + 0.5D + this.random.nextGaussian() * 0.0045D, 0.6D / d3 + 0.5D + this.random.nextGaussian() * 0.0045D);
        this.setDeltaMovement(vec3);
        this.setYRot((float)(Mth.atan2(vec3.x, vec3.z) * (double)(180F / (float)Math.PI)));
        this.setXRot((float)(Mth.atan2(vec3.y, vec3.horizontalDistance()) * (double)(180F / (float)Math.PI)));
        this.yRotO = this.getYRot();
        this.xRotO = this.getXRot();
    }

    public CustomFishingHookaa(EntityType<CustomFishingHookaa> customFishingHookEntityType, Level level) {
        this(customFishingHookEntityType,level, 0, 0);
    }


    protected  boolean shouldStopFishing(Player p_37137_)  {
        ItemStack itemstack = p_37137_.getMainHandItem();
        ItemStack itemstack1 = p_37137_.getOffhandItem();
        boolean flag = itemstack.getItem() instanceof Netherite_Rod;
        boolean flag1 = itemstack1.getItem() instanceof Netherite_Rod;
        if (!p_37137_.isRemoved() && p_37137_.isAlive() && (flag || flag1) && !(this.distanceToSqr(p_37137_) > 1024.0D)) {
            return false;
        } else {
            this.discard();
            return true;
        }
    }

}

I've seen the documentation, but I'm not sure if it's correct.

Link to comment
Share on other sites

14 minutes ago, diesieben07 said:

This is incorrect on multiple levels:

  • Why did you try to make the class protected?
  • That is the wrong syntax for ATing a field.

Since shouldStopFishing is private, I thought I could make it protected and reference it.

 

# Makes protected the 'COLOR_WHITE' field in Gui
protected net.minecraft.client.gui.Gui f_168667_ # COLOR_WHITE

If it is a field, should I use this example?

But we don't know why.
This may be my lack of knowledge about java.

 

I'll check again.

Link to comment
Share on other sites

protected net.minecraft.world.entity.projectile.FishingHook m_37136_(Lnet/minecraft/world/entity/player/Player;)Z

I was able to implement it by re-reading each one.

I'm getting an Override error message, should I continue developing?

It has taken me a long time to get to this point. Can I post the whole code in case someone else has a similar problem? (Fill in or Github link)

I'm very grateful.  Thank you.

 

 

 

Edited by ocome
Link to comment
Share on other sites

How on earth did you upload this Git Repo, use a Git Client!
In addition, you should use the .gitignore from the mdk when uploading. It ensures that the correct files/folders are upload,
also stop putting your project in a separate folder.

Did you refresh the gradle dependencies?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.