Jump to content

Villager_31441

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by Villager_31441

  1. I am now sending a message to the clients when a mob changes its status. But how can I assign the status to the entity on the client? I have tried sending the entity UUID alongside the message but it appears the client only uses a numerical non-persistent identifier. Is there another way to find the correct entity?

  2. Noob here but from what I could find you'd create an event handler that listens for destroyed blocks using a handleBlockDestruction method.

    You'd then check if the event.entity has the correct pickaxe equipped. If so, you can iterate through the affected blocks. Should be all blocks with either x, y or z coordinate one greater or smaller than the destoryed one.

    Not sure about how to add the actual item to the game. For wireframing you can try to have all pickaxes affected at first. But you'll probably find some tutorials on how to create new items.

  3. 1 minute ago, diesieben07 said:

    This is where capabilities come into play. You can use them to store this additional state on the entity.

    Ah, now I got it. So I detect the state on the server and store them with a capability, send updates to the client and store them with the exact same capability. It's starting to make sense now.

     

    Thank you so much for your help and quick responses!

  4. Thanks a lot.

     

    13 minutes ago, diesieben07 said:

    There are two overloads for this method. One is deprecated, one is not. 

    Ah, I see. The new API requires a factory of type Callable instead of the class.

     

    16 minutes ago, diesieben07 said:

    If an entity enters this radius, this event is fired. This is an opportunity for mods to send additional data attached to the entity to the client that is now tracking this entity.

    So I send the state of all entities (or at least those with a positive state - as in they have levitation) to the respective client once they are being tracked.

    What would I do when the state of a currently tracked entity changes? I have to send it to all tracking clients. But is there a simple way to find out who that is or do I have to store which client tracks which entities myself?

    When I do notify the clients would I simply send a message via SimplImpl? Can I apply the state directly to the entity so that I can find out about it via entity.whatever() or do I have to find my own solution, e.g. store all the IDs of entities with a positive state in an ArrayList and then check if the entity is in there?

  5. So, I followed this guide on PlanetMinecraft about the capability system.

    What is still unclear to me:

    • Is the guide still up to date or has a lot changed since then?
    • What is that resource location in the capability handler pointing at?
    • My IDE warns me that CapabilityManager.INSTANCE.register() is deprecated but it still appears in the official documentation. What is the new way of registering your capabilities?

    And I also cannot find anything about the mentioned tracking events. What are the respective functions called and how do I use them?

    EntityLivingBase#potionsNeedUpdate also doesn't appear to be a thing.

  6. On 7/10/2018 at 3:39 PM, Animefan8888 said:

    It turns out you might have to subscribe to PlayerEvent.StartTracking and "tag" the entity and "untag" the entity in PlayerEvent.StopTracking. And then in a tick event check if they have the potion effect and send the packet and mark that so you don't continuously send the packet. And then check if they don't have the effect and send another packet letting the client know. Honestly, you might even want to skip the Tracking section because it might work better.

    Is this page about Extended Entity Properties what your are talking about? It says that the system is deprecated but the favored Capability system doesn't sound at all like it would solve my problem.

    I am also having a very hard time understanding what is going on in these code snippets. Do you know of any more detailed explanations than the docs? I consider them very confusing.

  7. 16 minutes ago, diesieben07 said:

    Also Problematic code, issue 8.

    Yeah. I figured the id is bad practice. Makes it hard to read, too. I've seen a bunch of code examples using something like Potion.jump_boost ect. but IntelliJ tells me that no attributes of that sort exist. So what would be a good way to refer to "minecraft:levitation" in code?

     

    21 minutes ago, Animefan8888 said:

    in a tick event check if they have the potion effect and send the packet and mark that so you don't continuously send the packet. And then check if they don't have the effect and send another packet letting the client know.

    Ugh, I was really hoping for an easier way.

    I am just trying to create a very simple mod that flips the player/mob model around when someone hits the ceiling under the levitation effect. Maybe I can just detect upward movement instead of the effect? But then I wouldn't know how to differentiate between floating and jumping against a block. So I guess I will have to learn how to efficiently do the networking stuff.

    Thank you for your help thus far!

  8. 5 minutes ago, Animefan8888 said:

    Are you specifically targeting the levitation potion effect? If so you could just retrieve it with Entity#hasNoGravity()

    I am. Thanks. Just tried that out. It doesn't work for the mobs nor the player. It did detect a newly summoned Zombie Pigman with {NoGravity:1} NBT data though. So I suppose it does just that and nothing beyond.

  9. 4 minutes ago, Animefan8888 said:

    I believe your issue is that other entities never sync their PotionEffects to the client.

    I thought about that as well. The client should know about the effects on the player character but not necessarily any other entity.

    How would I go about retrieving that information from the server? Especially with the check happening every tick.

    Do I have to send a message to the client using SimplImpl whenever a mob in its maximum view distance receives or runs out of a potion effect?

  10. Hello there.

    I just started with creating mods for Minecraft.

    I am trying to check for all entities that have a specific potion effect and change some stuff in how they are rendered.

    The code works absolutely fine with players but not for mobs at all. I found out that it is this piece of code.

    @SubscribeEvent
    public void onRenderLiving(RenderLivingEvent.Pre event) {
      LivingEntityBase = event.entity;
      Potion levitation = Potion.getPotionById(25);
      if(levitation != null && player.getActivePotionEffect(levitation) != null) {
        // do stuff
      }
    }

    The code in the if-statement is never executed for any entities other than players.

    I also tried iterating through .getActivePotionEffects() but it never finds any effect at all. Logging revealed that the entites will be passed to the function though. So it must be due to .getPotionEffect() always returning false on mobs.

     

    Am I using the API wrong? And if so, how would you check whether a mob has a potion effect?

×
×
  • Create New...

Important Information

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