Jump to content

Changing player size


Melodia

Recommended Posts

Okay so basically I've been working on this mod for a while, that changes you, the player's size after an action

for example, each time you eat you gain height.

Client sided it seems to be working fine, but the moment I add it to the server it won't even run the server.

I'm trying to get it to work server-wise, so to my understanding I'll have to work on differently with proxies or idk..

I would really like a bit of help, where do I start lol

Link to comment
Share on other sites

Rendering isn't done on server side. Just check on the server, if you for example ate something.

Then, you have to send a Packet to the client.

If you want to know how to implement packets, just read the forge documentation:

https://mcforge.readthedocs.io/en/latest/networking/

Also, the forge docs have an article about clientside/serverside and what you should do on those sides:

https://mcforge.readthedocs.io/en/latest/concepts/sides/

Link to comment
Share on other sites

On 5/17/2020 at 11:59 PM, Budschie said:

Rendering isn't done on server side. Just check on the server, if you for example ate something.

Then, you have to send a Packet to the client.

If you want to know how to implement packets, just read the forge documentation:

https://mcforge.readthedocs.io/en/latest/networking/

Also, the forge docs have an article about clientside/serverside and what you should do on those sides:

https://mcforge.readthedocs.io/en/latest/concepts/sides/

 

Hey thank you!

I've managed to communicate between the server and client

 

Issue is I don't understand how would I increase the size of the specific player who ate something. increasing everyone's size together is okay somewhat >.<

Link to comment
Share on other sites

Make the player size a capability and sync it everywhere (not literally; only to tracking clients and self), and on the client, render the model based on that player's size capability.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

9 hours ago, DavidM said:

Make the player size a capability and sync it everywhere (not literally; only to tracking clients and self), and on the client, render the model based on that player's size capability.

Thanks for replying!

 I have been playing a bit with capabilities, and I seem to be understanding a bit, but not quite enough

image.png.fe3719c0bf805754e606a8297ec9b3f4.png

 

In the giant.setHeight, I'm attempting to update the capability but it doesn't seem to do anything

I've also tried to change it outside the dist.client

Any idea why it wouldn't update? :c

Link to comment
Share on other sites

Replying to myself sorry,

Fixed that issue

But when I try to load other players from a client's pov I can't reach others capabilities because I'm looking for ClientEntityPlayer and I'm getting RemoteClientEntityPlayer when I'm getting the render of another player in RenderPlayerEvent

Link to comment
Share on other sites

You should sync capabilities of other players to the client.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

On 5/21/2020 at 3:41 AM, DavidM said:

You should sync capabilities of other players to the client.

 

On 5/20/2020 at 7:55 PM, Melodia said:

Replying to myself sorry,

Fixed that issue

But when I try to load other players from a client's pov I can't reach others capabilities because I'm looking for ClientEntityPlayer and I'm getting RemoteClientEntityPlayer when I'm getting the render of another player in RenderPlayerEvent

Sorry for being a newbie, really trying hard on this one

I'm trying to sync the capabilities, is making a list of all the capabilities a good start?

How would I send it as a server to the players?

I don't really understand how would I encode/decode something that isn't primitive >.<

Could you lead me a bit further? I would really appreciate that

Link to comment
Share on other sites

5 hours ago, Melodia said:

I don't really understand how would I encode/decode something that isn't primitive >.<

There are helper functions that allows you to encode complex data (such as ITextComponent and BlockPos) to NBT.

 

5 hours ago, Melodia said:

I'm trying to sync the capabilities, is making a list of all the capabilities a good start?

I personally store my capabilities in static fields marked with @CapabilityInject annotation so that the value of the capability is injected at runtime. An example is this.

 

Here are some links to the capability part of my test mod if you need:

My capability object.

My capability provider.

My capability storage.

My event subscriber for attaching capabilities to player.

My packet that syncs the data of capability to the client.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

19 hours ago, DavidM said:

There are helper functions that allows you to encode complex data (such as ITextComponent and BlockPos) to NBT.

 

I personally store my capabilities in static fields marked with @CapabilityInject annotation so that the value of the capability is injected at runtime. An example is this.

 

Here are some links to the capability part of my test mod if you need:

My capability object.

My capability provider.

My capability storage.

My event subscriber for attaching capabilities to player.

My packet that syncs the data of capability to the client.

If possible could you explain this line?

https://github.com/davidmaamoaix/AquaticExploration/blob/d83561ca633053127545d7518bfb50e243e779a1/src/main/java/cn/davidma/aquaticexploration/common/progress/AquaticProgresses.java#L19

 

How does it get updated?

In the readNBT method you're using that declartion but I don't really understand how it get updated

Link to comment
Share on other sites

Oh I'm just being lazy there.

Instead of finding the registry reference during the appropriate time, I used a LazyValue to find it via GameRegistry.findRegistry the first time I call it.

It is functionally the same with:

if (registry == null) {
	registry = findRegistry();
}

doStuffWithRegistry();

 

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

On 5/24/2020 at 2:35 AM, DavidM said:

Oh I'm just being lazy there.

Instead of finding the registry reference during the appropriate time, I used a LazyValue to find it via GameRegistry.findRegistry the first time I call it.

It is functionally the same with:


if (registry == null) {
	registry = findRegistry();
}

doStuffWithRegistry();

 

Thanks a lot.

Eventually I've managed to fix my problems

But for some reason as the player gets taller, I can't seem to break anything at a height higher than the regular reach radius

Is it possible or is there any variable to change the reach radius to be around my hand at a certain player height?

Link to comment
Share on other sites

9 hours ago, Melodia said:

Is it possible or is there any variable to change the reach radius to be around my hand at a certain player height?

That is changeable in the player's attribute. Obtain the attribute via LivingEntity#getAttribute and pass in the REACH_DISTANCE in PlayerEntity to obtain the reach attribute. You can modify that to change block reach distance.

Unfortunately I don't think there is a convenient method of changing the reach for entity interactions. You'll have to do some manual ray casting.

  • Like 1

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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.

Announcements



×
×
  • Create New...

Important Information

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