Jump to content

Recommended Posts

Posted

Hello,

trying to increase range of players hand

	
public static void setExtraReach(EntityLivingBase entity, float reach) {
	if(entity instanceof EntityPlayerMP)
		((EntityPlayerMP) entity).theItemInWorldManager.setBlockReachDistance(Math.max(5, ((EntityPlayerMP) entity).theItemInWorldManager.getBlockReachDistance() + reach));
}

This Method doesnt work my question is why ? and how to fix it ?

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

In My eventhandler class

@SubscribeEvent
public void checksomething (LivingUpdateEvent event) {
	if(event.entityLiving instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.entityLiving;
		if(player.inventory.hasItem(ItemsHandler.Corn)) {
                                System.out.println("SOMETHING !");
			FMTMethods.setExtraReach(player, 3.5F);
		}
	}
}

 

This will get printed out but the setExtraEach doesnt work

 System.out.println("SOMETHING !");

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

I know this might be  onfusing, but you check in the event handler if entity instaceof EntityPlayer. But keep in mind that it aint the same as EntityPlayerMP(wich you check in the extendReach() methode. So the methode might be called. But the check will always be false i  this case

(EntityPlayer != EntityPlayerMP)

 

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Posted

The reach distance on the client is determined in the PlayerControllerMP class, in the

getBlockReachDistance

method. You can't change the values returned there, but you can change the

Minecraft#playerController

field to return a custom class extending PlayerControllerMP, in which you do have full control over the method (and return your own values).

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Ok thank you all im gonna try it

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

The reach distance on the client is determined in the PlayerControllerMP class, in the

getBlockReachDistance

method. You can't change the values returned there, but you can change the

Minecraft#playerController

field to return a custom class extending PlayerControllerMP, in which you do have full control over the method (and return your own values).

 

I think this may have a problem though. That method is used by the EntityRenderer#getMouseOver() method. But that method seems to clamp the value to 3.0D (or 6.0D if in creative mode).  Here's the relevant code:

                this.mc.pointedEntity = null;
                double d0 = (double)this.mc.playerController.getBlockReachDistance();
                this.mc.objectMouseOver = this.mc.renderViewEntity.rayTrace(d0, p_78473_1_);
                double d1 = d0;
                Vec3 vec3 = this.mc.renderViewEntity.getPosition(p_78473_1_);

                if (this.mc.playerController.extendedReach())
                {
                    d0 = 6.0D;
                    d1 = 6.0D;
                }
                else
                {
                    if (d0 > 3.0D)
                    {
                        d1 = 3.0D;
                    }

                    d0 = d1;
                }

                if (this.mc.objectMouseOver != null)
                {
                    d1 = this.mc.objectMouseOver.hitVec.distanceTo(vec3);
                }

 

Doesn't that prevent values over 3.0D?

 

This is why I chose to try creating my own mouse over method instead.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I suppose you can change the whole EntityRenderer instance in the Minecraft class, but that might be a bit rediculous for what you are trying to do.

 

BTW Jabelar, isn't your mouse over method only for entities?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

BTW Jabelar, isn't your mouse over method only for entities?

 

No, while I used the method to show attacking an entity, it is really just a copy of the mouse over method with a reach you can specify. It returns a moving object position so (although I didn't confirm it) I think it will return a block if it doesn't hit an entity.

 

The method basically works by first doing a ray trace on the look vector which returns a block, and then iterates along the vector to that block to see if there is an entity in the way.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

BTW Jabelar, isn't your mouse over method only for entities?

 

No, while I used the method to show attacking an entity, it is really just a copy of the mouse over method with a reach you can specify. It returns a moving object position so (although I didn't confirm it) I think it will return a block if it doesn't hit an entity.

 

The method basically works by first doing a ray trace on the look vector which returns a block, and then iterates along the vector to that block to see if there is an entity in the way.

Nice, maybe I'll use it in the future!

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.

Announcements



×
×
  • Create New...

Important Information

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