Jump to content

[1.10.2] How to trample crops when wearing certain armor


gibraltar

Recommended Posts

I would like to make it so that if the player walks on farmland while wearing certain armor, that the farmland reverts to dirt, trampling the crops. I want something like onEntityWalking, but it looks like overriding the farmland block would be nigh impossible, because of all the places in the Minecraft code that refers to it via Blocks.FARMLAND rather than using instanceof. Another option would be to add an EntityWalkingEvent to Forge, but that may be overkill, plus it would require waiting however long it takes to get the PR approved and into Forge.

 

Am I missing other options?

Link to comment
Share on other sites

I suggest doing the PR and supplementary until it is implemented you could use PlayerTickEvent.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I'd use the armor item's onArmorTick method.  That way you're not having to check the player's inventory all the time, even when they're not wearing armor.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I'd use the armor item's onArmorTick method.  That way you're not having to check the player's inventory all the time, even when they're not wearing armor.

Ah yes, forgot that method existed (I need to go to sleep)  :( . Also assuming that this is your armor this way.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Hi

 

I'd use the armor item's onArmorTick method.  That way you're not having to check the player's inventory all the time, even when they're not wearing armor.

Ah yes, forgot that method existed (I need to go to sleep)  :( . Also assuming that this is your armor this way.

 

I have a vague recollection that method is client side only, i.e. it won't be any good for trampling farmland because that needs to occur on server side only.

 

Worth testing out, should only take a few minutes to code up.

 

Ah what the hell, I'll try it myself now.

[00:06:16] [Client thread/INFO]: [minecraftbyexample.testingarea.ItemArmorTickTest:onArmorTick:20]: onArmorTick:client
[00:06:16] [server thread/INFO]: [minecraftbyexample.testingarea.ItemArmorTickTest:onArmorTick:20]: onArmorTick:server
[00:06:16] [Client thread/INFO]: [minecraftbyexample.testingarea.ItemArmorTickTest:onArmorTick:20]: onArmorTick:client
[00:06:16] [server thread/INFO]: [minecraftbyexample.testingarea.ItemArmorTickTest:onArmorTick:20]: onArmorTick:server

Guess I was mistaken...

 

-TGG

 

 

 

 

 

 

Link to comment
Share on other sites

OnPlayerTick it is!

 

Which ticks even if you're not wearing the armor. Talk about overkill.

(do your armor tick in one of your armor items, like the boots)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

There are a few ways to fix this .

 

I'd personally only do it on armor tick on the boots. Then on boots side you can check if you also wearing a chestplate then increase the chance of trample or something like that.

 

Boots are what people use to connect to the ground so if you don't wanna trample at all walk bearfoot which nobody will do :D 

 

Another way to do this is to have some kind of player weight stat and whenever you add or remove armor (certain armors) you add or remove weight. or turn weight on and off.

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

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.