Jump to content

Entityevent.Size event does not fire


Thomas Schwarz

Recommended Posts

Hello,

I want the player's hitbox to get smaller (e.g. when pressing a key combination). To do this, I assigned a tag to the player, but the Entityevent.Size event does not fire. Can someone help me?

package de.chrisicrafter.vampires.event;

import de.chrisicrafter.vampires.Vampires;
import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = Vampires.MODID)
public class ModEvents {

    @SubscribeEvent
    public void onSizeEvent(EntityEvent.Size event) {

        Vampires.LOGGER.info("Size Event");

        Player player = (Player) event.getEntity();

        if (player.getTags().contains("small")) {
            Vampires.LOGGER.info("SMALL");
            event.setNewSize(new EntityDimensions(0.5f,0.25f,true));
        } else {
            Vampires.LOGGER.info("NORMAL");
            event.setNewSize(new EntityDimensions(1f,1f,true));

        }

    }

    @SubscribeEvent
    public void onLoginEvent(PlayerEvent.PlayerLoggedInEvent event) {

        System.out.println("Login Event");

        Player player = (Player) event.getEntity();

    }

    @SubscribeEvent
    public static void onLivingAttackEvent(LivingAttackEvent event)
    {
        Vampires.LOGGER.info("event is here");
    }

}

NOTE:

- The LivingAttackEvent works

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.



×
×
  • Create New...

Important Information

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