Jump to content

Recommended Posts

Posted (edited)

I want to disable healing (from food, not from potions). I know you can do this by disabling the gamerule "naturalRegeneration" but if I'm correct, this will disable the healing for all players. Is there a way to disable the natural healing per player?

Edited by Tieso2001
Posted
  On 8/29/2020 at 11:55 AM, diesieben07 said:

To disable generation from food (not from peaceful difficulty) you'd have to replace the Player's FoodStats object with your own version that does special handling.

Expand  

Okay, I know how to make my own custom FoodStats using capabilities, but how can I disable/replace the original then?

Posted (edited)
  On 8/31/2020 at 10:09 AM, diesieben07 said:

Set PlayerEntity#foodStats using reflection.

Expand  

When do I set it? Is there a PlayerEntity/Entity creation event or something similar that I should use? I only found EntityJoinWorldEvent but then it would create a new FoodStats object everytime the entity joins. How can I check if the entity hasn't been created before? Or should I use something completely different?

Edited by Tieso2001
Posted
  On 9/1/2020 at 8:25 AM, diesieben07 said:

EntityJoinWorldEvent is exactly right. You have to set the object every time. It does not magically persist.

Expand  

Thank you, I got it working that my custom FoodStats is set. I have one more problem:

I created a class named CustomFoodStats that extends FoodStats. When I try to override/copy the tick() method I get lots of errors because all the fields of FoodStats are not accessible. Should I also use reflection to get and set these fields or should I do something else (because that would require a lot of reflection every tick, which I believe is not something I should be doing)?

 

public class CustomFoodStats extends FoodStats {

    private boolean foodHealthRegen = true;

    public CustomFoodStats() {
        super();
    }

    @Override
    public void tick(PlayerEntity player) {
        /*
        this part would be copied from the original FoodStats (don't know if I could post that here)
        */

        boolean flag = player.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION) && this.foodHealthRegen;
      
        /*
        this part would be copied from the original FoodStats (don't know if I could post that here)
        */
    }
}

 

Also I have an additional question. Because I want to override the tick() method but I only change boolean flag, would that not be allowed because in essence I would then almost be entirely copying a method from the minecraft code.

Posted
  On 9/1/2020 at 5:27 PM, diesieben07 said:

You can also use access transformers instead of reflection.

Expand  

I didn't know that was a thing so thank you, that looks like it is exactly what I need. I tried to use it but I can't get it to work.

 

Here is my accesstransformer.cfg

# Makes the fields from the FoodStats class public
public net.minecraft.util.FoodStats foodLevel
public net.minecraft.util.FoodStats foodSaturationLevel
public net.minecraft.util.FoodStats foodExhaustionLevel
public net.minecraft.util.FoodStats foodTimer
public net.minecraft.util.FoodStats prevFoodLevel

 

And here the line I put into my build.gradle (in the minecraft section, under the line with the mappings)

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

 

It says that then I should refresh and it should work, but I refreshed and the fields still don't show up. Do you know how I should fix this?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hey to everyone. I am new here. Nice to meet you<><><>>>>>>>>>>>>>
    • Hey to everyone. I am new here. Nice to meet you<><><>>>>>>>>>>>>>
    • Shopping just got a whole lot more exciting this July 2025. With the verified  Temu   coupon code (acu729640), you can enjoy up to 40% off, a flat $100 discount, and much more—even if you’re a returning customer. The  Temu   coupon code (acu729640) opens the door to a world of savings, perks, and unbeatable deals for savvy shoppers like you and me. Why Everyone Is Buzzing About  Temu   in July 2025  Temu   has become one of the most talked-about shopping platforms globally. Here’s why: Over 250,000 trending items across electronics, fashion, home goods, and more Unbeatable prices with discounts reaching up to 90% Free shipping in 67 countries Reliable and fast delivery with real-time tracking User-friendly app and desktop experience New loyalty rewards programs and exclusive offers like (acu729640) What Makes the  Temu   Coupon Code (acu729640) a Game-Changer The  Temu   promo code (acu729640) for July 2025 is your golden ticket to bigger savings. It’s not just another random promo—it’s a highly flexible code packed with benefits that both new and existing Customers can enjoy. Here’s a breakdown of the savings:  Temu   coupon code (acu729640) $100 off for new Customers – Flat $100 discount on your first order  Temu   coupon code (acu729640) $100 off for existing Customers – Loyal customers get the same amazing $100 off  Temu   coupon code (acu729640) 40% off – Additional 40% discount across popular categories  Temu   $100 coupon bundle – Stackable savings up to $100 for multiple purchases  Temu   first time user coupon – Free gift + instant discounts These aren’t just generic savings. They’re curated to elevate your shopping experience. I used the (acu729640) coupon code last week and saved over $120 while shopping for kitchen gadgets, summer apparel, and gifts.  Temu   Coupons You Shouldn’t Miss in July 2025 If you’re anything like me, stacking deals is the ultimate thrill. And with the  Temu   coupon bundle available this July 2025, that thrill comes with real rewards. Whether you're a new or returning customer,  Temu   has a discount strategy tailored just for you. Must-Have  Temu   Coupon Codes  Temu   coupon code (acu729640) – Ideal for July 2025 sitewide savings  Temu   coupon code (acu729640) $100 off – Massive savings for both new and repeat Customers  Temu   coupon code (acu729640) 40% off – Perfect for trimming costs on trending products  Temu   $100 coupon bundle – Stackable codes for extra savings  Temu   coupons for new Customers – Welcome discounts + surprise gift  Temu   coupons for existing Customers – Loyalty benefits + access to VIP-only sales  Temu   discount code (acu729640) for July 2025 – Boost your cart value while spending less  Temu   promo code (acu729640) for July 2025 – Use this code for optimized checkout deals Country-Specific Coupon Benefits  Temu   coupon code $100 off for USA – Great for electronics, home appliances, and sports gear  Temu   coupon code $100 off for Canada – Ideal for winter wear, home décor, and wellness products  Temu   coupon code $100 off for UK – Popular for fashion, tech accessories, and skincare  Temu   coupon code $100 off for Japan – Perfect for minimalist homeware and tech  Temu   coupon code 40% off for Mexico – Clothing, bags, and beauty products at 40% off  Temu   coupon code 40% off for Brazil – Big savings on shoes, kitchenware, and fitness items The Power of the  Temu   Coupon Bundle The  Temu   $100 coupon bundle is not a myth. It’s a dynamic pack of stackable coupons that can be used together or separately to suit your cart size and item types. Bundle Highlights: Coupons worth $10, $20, $30, and $40 – Use one or stack all Free express shipping codes – Save time AND money Early access to flash sales – App-only deals included Seasonal bonuses – Added during holidays and big sale days Real Benefits You Can Count On Using  Temu   coupon code (acu729640) for July 2025 is not only smart—it’s empowering. Here’s what you stand to gain: $100 off for new Customers – Start strong with a generous discount $100 off for existing Customers – Stay loyal and still save 40% extra off – Cut down your final bill without cutting corners Free gift for new Customers – A little surprise goes a long way $100 coupon bundle – Plan multiple orders and save consistently How to Redeem the  Temu   Promo Code (acu729640) Visit the  Temu   website or download the app Log in or sign up for an account Add your favorite items to the shopping cart Enter the  Temu   discount code (acu729640) at checkout Watch the prices drop before your eyes  Temu   New Offers in July 2025 If you're on the lookout for fresh deals,  Temu  's new offers in July 2025 are hard to beat. With rolling flash sales, new arrivals daily, and special discounts for app Customers, you’ll always find something irresistible. And yes, you can use the  Temu   promo code (acu729640) with many of these new deals.  Temu   is constantly updating their product catalog. Whether you’re interested in smart gadgets, fashion-forward pieces, or home essentials, you’ll find quality and affordability combined in one platform. Final Thoughts Shopping on  Temu   with the coupon code (acu729640) is a no-brainer. You unlock value instantly, stack your savings strategically, and make every purchase count. In July 2025, this code isn’t just recommended—it’s essential. I’ve saved hundreds with the  Temu   coupon code (acu729640), and I know you can too. Why pay full price when you have access to: The  Temu   coupon code (acu729640) $100 off The  Temu   coupon code (acu729640) 40% off The  Temu   $100 coupon bundle Free gifts and fast delivery Your smarter shopping journey starts now. Just remember the magic key: acu729640. Happy shopping!  
  • Topics

×
×
  • Create New...

Important Information

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