Jump to content

Recommended Posts

Posted

How can I modify an existing mob/entity, how to change the spawn, AI, life,...?

I've already created custom entities, but this time I wanted to modify existing entities. They have something to do with "@override".
I'm in Forge 1.18.1

 

Thanks!๐Ÿ˜„

Posted

Events, mostly.

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.

Posted

You can better explain how to do this using events...?

It's just that I haven't found much content on the internet and I really have no idea how to change something from vanilla.  ๐Ÿ˜“

 

Suppose I want to change a zombie's attributes, how would I do that?  ๐Ÿค”

Posted (edited)

I intend to change all entities. (ex: Change all zombies).

It would be to change the attributes of all zombies, for example to get them with more health or to walk faster.๐Ÿค”

Edited by Brun0_MF
Posted
        @SubscribeEvent
        public static void entityJoinWorld(EntityJoinWorldEvent event){
            event.getEntity() // ? 
              //Entity#getAttributes().addTransientAttributeModifiers              ?
              //event.getAttributes().addTransientAttributeModifiers               ?
              //event.getEntity.addTransientAttributeModifiers                     ?

        }

Is it something like that?
Does it work on 1.18.1? I'm putting it in a class that I named ForgeEvents.

It's just that I'm really lost on this topic. Where for sure I have to put this code, because it gives an error in any part I put.

 

๐Ÿค”

If it's simpler to explain, it could teach me how to remove the spawn of a mob (remove it completely (ex: stop spawning zombies)), so I remove the entity and change it for a custom one.

Posted (edited)
  On 1/6/2022 at 10:18 PM, Brun0_MF said:
        @SubscribeEvent
        public static void entityJoinWorld(EntityJoinWorldEvent event){
            event.getEntity() // ? 
              //Entity#getAttributes().addTransientAttributeModifiers              ?
              //event.getAttributes().addTransientAttributeModifiers               ?
              //event.getEntity.addTransientAttributeModifiers                     ?

        }

Is it something like that?
Does it work on 1.18.1? I'm putting it in a class that I named ForgeEvents.

It's just that I'm really lost on this topic. Where for sure I have to put this code, because it gives an error in any part I put.

 

๐Ÿค”

If it's simpler to explain, it could teach me how to remove the spawn of a mob (remove it completely (ex: stop spawning zombies)), so I remove the entity and change it for a custom one.

Expand  

like this:

 

                Entity entity = event.getEntity();
                if (entity.isAlive() && entity instanceof ZombieEntity) {
                    ZombieEntity zombie = (ZombieEntity) entity;
                    // TODO ...
                    event.setCanceled(true);
                }

Cancel zombie spawn

Edited by Spring
Posted

diesieben07, the first thing in the comment was what you sent, it wasn't an attempt, it was just the basis for the attempts.
I have a java course, but I haven't studied what each forge class has yet, and as the forge documentation is not very complete, it's difficult to know how to work with it.

Spring, won't this code to remove entities slow down the game? Since it will check each entity that is generated and eliminate if it is a zombie... (Just out of curiosity, since your code works...)

With what you said and with the code that Spring sent I got something...

        @SubscribeEvent(priority = EventPriority.HIGHEST)
        public static void entityJoinWorld(EntityJoinWorldEvent event){

            Entity entity = event.getEntity();
            if (entity.isAlive() && entity instanceof Zombie) {
                Zombie zombie = (Zombie) entity;
                zombie.getAttributes().addTransientAttributeModifiers(); //not complete
                //event.setCanceled(true);
            }



        }

 

With this code how can I do to, for example, increase movement speed or maximum health?

Something like:

     .addTransientAttributeModifiers(new AttributeModifier(    ?       ?      ?     ))

 

 

How do I use the AttributeModifier?

 

Posted

What are the names and types of the parameters?

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.

Posted (edited)

OK, now that I have the attributemodifier created how should I put it in that method and how will I define in which attribute it should add those values.๐Ÿค”

    public static final AttributeModifier AM = new AttributeModifier("attributemodifier",5d, AttributeModifier.Operation.ADDITION);

                zombie.getAttributes().addTransientAttributeModifiers();

simply do "addTransientAttributeModifiers(AM);" doesn't work because it requires a Multimap

 

<edit> I've been reading a bit about multimap but I'm still not sure how to create a multimap correctly if they can tell me how to create a mutimap. I appreciate it, :) 

Edited by Brun0_MF
Posted

Okay, an update...
I managed to create the multimap, I don't know if it's 100% correct (if not, thanks for the corrections)...
The problem is that it gives an error when I put it in ".addTransientAttributeModifiers(EntityModify());"

    public static final AttributeModifier AM = new AttributeModifier("attributemodifier",5d, AttributeModifier.Operation.ADDITION);

    public static Multimap<String,AttributeModifier> EntityModify(){
        Multimap<String, AttributeModifier> map = HashMultimap.create();
        map.put(Attributes.MOVEMENT_SPEED.getDescriptionId(),AM);
        return map;
    }
        @SubscribeEvent(priority = EventPriority.HIGHEST)
        public void entityJoinWorld(EntityJoinWorldEvent event){

            Entity entity = event.getEntity();
            if (entity.isAlive() && entity instanceof Zombie) {
                Zombie zombie = (Zombie) entity;
                zombie.getAttributes().addTransientAttributeModifiers(EntityModify()); //Error here
                //event.setCanceled(true);
            }



        }

 

Posted
  On 1/8/2022 at 1:22 PM, diesieben07 said:

Nรฃo sei por que fez disso um mรฉtodo, mas... Ok. Nรฃo dรณi nada. Seria melhor usar ImmutableMultimap em um campo final estรกtico.

Seu problema, porรฉm, รฉ que (como vocรช pode esperar ver) adicionarTransientAttributeModifiers leva um Multimap<Attribute, AttributeModifier>. Vocรช estรก dando outra coisa.

Expand  

I've been looking at examples of how to use multimap and most used it like that, so I decided to do that too. I don't think it makes a difference.
Ah thank you!
I really hadn't noticed.

 

 

Posted

    public static final AttributeModifier AM = new AttributeModifier("attributemodifier",2000d, AttributeModifier.Operation.ADDITION);

    public static Multimap<Attribute,AttributeModifier> EntityModify(){
        Multimap<Attribute, AttributeModifier> map = HashMultimap.create();
        map.put(Attributes.MOVEMENT_SPEED,AM);
        return map;
    }



        @SubscribeEvent(priority = EventPriority.HIGHEST)
        public void entityJoinWorld(EntityJoinWorldEvent event){

            Entity entity = event.getEntity();
            if (entity.isAlive() && entity instanceof Zombie) {
                Zombie zombie = (Zombie) entity;
                zombie.getAttributes().addTransientAttributeModifiers(EntityModify());
                //event.setCanceled(true);
            }



        }



    

This is the code...
It turns out that something must be missing, because it's not affecting the entity.

event.setCanceled(true) works, but the rest doesn't.

I think it's because we haven't sent data for the event yet.
We create an instance of a zombie based on the event, but we don't send the data back to it.

Could you tell me how to make it work?

Posted
  On 1/8/2022 at 2:00 PM, Brun0_MF said:

I've been looking at examples of how to use multimap and most used it like that, so I decided to do that too. I don't think it makes a difference.

Expand  

It's a technique called Generics. Just as a List<string> and List<integer> take strings and integers respectively, a HashMap (or Dictionary) maps a key to a value. For example if you wanted to create a table of products and their prices, you might use a HashMap<string,float> mapping the string-name of the product to the float-value of the product.
(A multimap is mostly just syntactic sugar for HashMap<K,List<V>> and the fact that it maps one key to multiple values is all you need to know)

So yes, the Type of the key value is important.

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.

Posted

I went to do some tests and found that the error is here:

        @SubscribeEvent(priority = EventPriority.HIGHEST)
        public void entityJoinWorld(EntityJoinWorldEvent event){

            Entity entity = event.getEntity();
            if (entity.isAlive() && entity instanceof Zombie) {
                Zombie zombie = (Zombie) entity;
                zombie.getAttributes().addTransientAttributeModifiers(EntityModify());
                //event.setCanceled(true);
            }



        }

Error: Entity is not modified.

An instance of the Zombie class is created based on the event, but we don't modify the event, so nothing happens.
The event had to be exchanged for the modified entity "zombie", but I can't find a way to do that...๐Ÿ˜“

 

 

Another question, how to completely disable the natural generation of an entity, without waiting for it to spawn and then despawn.๐Ÿค”

Posted

But when I wanted to disable an event I used "event.setCanceled (true);", when I modified the entity I didn't use the event anymore but the "zombie.getAttributes(). AddTransientAttributeModifiers (EntityModify());" (I used "zombie" and not event). Don't we have to pass the zombie class to the event?

Posted

Or you could just have used git the way git is meant to be used.

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.

Posted (edited)

Sorry!
I don't know how to use Github, so I tried my best not to have to use it...๐Ÿ˜“

 

And you Draco18s, do you have any idea what the error might be? ๐Ÿค”

 

Edited by Brun0_MF
Posted

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.

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

    • When i try to start minecraft forge 1.20.1 an error appears an the launcher shows the error 1, i don't know what's that :   "failed to initialize graphics window with current settings" "Timed out trying to setup the Game Window"
    • Also add the client log after trying to join  
    • Weโ€™ve got a fantastic deal for new usersโ€”just use the acw696499 Temu coupon code to unlock massive savings across Temuโ€™s global marketplace. This code offers maximum benefits to shoppers in the USA, Canada, and major European countries. With the Temu coupon $100 off and Temu 100 off coupon code, you can enjoy generous discounts and exclusive offers. Itโ€™s your key to smart shopping without compromising on quality. What Is The Coupon Code For Temu $100 Off? Everyone loves a great deal, and Temu makes it even better with this limited-time offer. Whether you're a new or existing customer, the Temu coupon $100 off or $100 off Temu coupon is the real deal to watch. acw696499: Flat $100 off on your first purchase as a welcome bonus. acw696499: Access a $100 coupon pack with multiple-use options. acw696499: Exclusive $100 flat discount for new customers on sign-up. acw696499: Extra $100 promo code for existing customers. acw696499: Valid for all users in the USA and Canada for a $100 off coupon experience. Temu Coupon Code $100 Off For New Users In 2025 If you're just starting out with Temu, this deal is tailor-made for you. The Temu coupon $100 off and Temu coupon code $100 off are designed specifically to give new users an exceptional start. acw696499: Flat $100 discount for all new users. acw696499: Get a $100 coupon bundle instantly after registering. acw696499: Up to $100 coupon bundle usable over multiple orders. acw696499: Free shipping to 68 countries, making your first purchase even sweeter. acw696499: Enjoy an extra 30% off on any product as a first-time user. How To Redeem The Temu Coupon $100 Off For New Customers? Using the Temu $100 coupon and Temu $100 off coupon code for new users is easy: Download the Temu app or visit the Temu website. Register as a new user with your email or phone number. Go to the coupon section and enter code acw696499. Browse and add your favorite items to the cart. Apply the coupon at checkout to redeem your discount. Temu Coupon $100 Off For Existing Customers Temu doesnโ€™t just stop at new users. Even returning shoppers can make the most of the Temu $100 coupon codes for existing users and Temu coupon $100 off for existing customers free shipping benefits. acw696499: $100 extra discount for existing Temu users. acw696499: Unlock a $100 coupon bundle for multiple purchases. acw696499: Get a free gift with express shipping throughout the USA and Canada. acw696499: Enjoy an extra 30% off on top of existing discounts. acw696499: Free shipping to 68 countries with no strings attached. How To Use The Temu Coupon Code $100 Off For Existing Customers? To use the Temu coupon code $100 off and Temu coupon $100 off code as an existing user: Log into your Temu account via app or website. Go to the โ€˜Coupons & Promotionsโ€™ section. Enter acw696499 in the coupon code box. Shop for your desired products. Apply the code during checkout to enjoy the savings. Latest Temu Coupon $100 Off First Order Your first order with Temu just got a whole lot more exciting. When you use the Temu coupon code $100 off first order, Temu coupon code first order, or Temu coupon code $100 off first time user, big savings await. acw696499: Flat $100 discount on your first order. acw696499: Activate your $100 Temu coupon code with ease. acw696499: Receive up to $100 worth of coupons for multiple purchases. acw696499: Enjoy free shipping across 68 countries. acw696499: Add 30% off on your first purchase. How To Find The Temu Coupon Code $100 Off? If you're searching for a Temu coupon $100 off or even a verified Temu coupon $100 off Reddit code, weโ€™ve got you covered. Simply sign up for the Temu newsletter to get exclusive coupons straight to your inbox. You can also follow Temuโ€™s official pages on Instagram, Facebook, or Twitter for surprise promo codes. For guaranteed and working coupons, visit any trusted coupon siteโ€”youโ€™ll always find the best deals like acw696499 there. Is Temu $100 Off Coupon Legit? Yes, the Temu $100 Off Coupon Legit offer is 100% real. Our Temu 100 off coupon legit codeโ€”acw696499โ€”has been tested and verified by thousands of users. You can safely use this code for $100 off on your first order and enjoy discounts on recurring purchases too. Thereโ€™s no expiry date, and the code is valid globally. How Does Temu $100 Off Coupon Work? The Temu coupon code $100 off first-time user and Temu coupon codes 100 off offers work by instantly applying discounts to your cart. Once you sign up and apply the coupon code, Temu automatically adjusts the pricing to reflect your savings. Whether itโ€™s a flat $100 off or a bundle, the discounts will apply across eligible items at checkout. How To Earn Temu $100 Coupons As A New Customer? To earn the Temu coupon code $100 off or 100 off Temu coupon code as a new customer, simply sign up on the Temu app or website. Enter the code acw696499 during registration or at checkout, and youโ€™ll instantly unlock $100 worth of coupons. These can be applied over multiple orders, maximizing your benefits as a newcomer. What Are The Advantages Of Using The Temu Coupon $100 Off? The Temu coupon code 100 off and Temu coupon code $100 off offers bring many great benefits: $100 discount on the first order. $100 coupon bundle for multiple uses. Up to 70% discount on trending items. Extra 30% off for existing customers. Up to 90% off on selected categories. Free gift for new users. Free delivery to 68 countries. Temu $100 Discount Code And Free Gift For New And Existing Customers Using the Temu $100 off coupon code or $100 off Temu coupon code gives you unmatched savings and perks. Whether youโ€™re a new or returning customer, youโ€™ll love the benefits. acw696499: Enjoy a $100 discount on your very first order. acw696499: Get an extra 30% off on all purchases. acw696499: Free gift exclusively for new Temu users. acw696499: Up to 70% off across all product categories. acw696499: Free gift and free shipping in 68 countries, including the USA and UK. Pros And Cons Of Using The Temu Coupon Code $100 Off This Month Take advantage of the Temu coupon $100 off code and Temu 100 off coupon deals with these pros and cons: Pros: Massive $100 discount on eligible purchases. Works for both new and existing users. Stackable with other Temu offers. Valid in 68 countries worldwide. Comes with free shipping and gifts. Cons: Only valid through the app or website. May not apply to some sale items. Terms And Conditions Of Using The Temu Coupon $100 Off In 2025 Please read these Temu coupon code $100 off free shipping and latest Temu coupon code $100 off terms: Our coupon code acw696499 does not have an expiration date. The code is valid for both new and existing users. No minimum purchase is required to use this code. It applies across 68 countries worldwide. Free shipping and gifts are included. Final Note: Use The Latest Temu Coupon Code $100 Off Unlock unbeatable value with the Temu coupon code $100 off today. Whether you're new or returning, the savings are just one click away. Enjoy great deals, exclusive bundles, and premium products with our Temu coupon $100 off. Shop smart and save more every time. FAQs Of Temu $100 Off Coupon  Is the Temu $100 off coupon available to everyone? Yes, both new and existing users in supported countries can access the $100 off offer using code acw696499.  How can I ensure my Temu coupon works? Use a trusted and verified code like acw696499 and follow the redemption steps properly at checkout. Does the Temu $100 coupon expire? No, our exclusive code acw696499 has no expiration date and can be used anytime.  Can I combine the $100 coupon with other discounts? Yes, Temu allows coupon stacking, so you can combine acw696499 with other ongoing deals.  Is the Temu $100 off coupon valid worldwide? Absolutely. The acw696499 code is valid in 68 countries, including the USA, Canada, and Europe.
    • So I tried joining it, but they disconnect me immediately after it opens. Here's the log after closing the server: https://mclo.gs/5Bp0Mno
    • We have this Mc Server but some people aren't able to connect and are getting this error This is the Debug.log https://mclo.gs/EoekqaK 
  • Topics

ร—
ร—
  • Create New...

Important Information

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