Search in sources :

Example 1 with EntitySize

use of net.minecraft.entity.EntitySize in project upgrade-aquatic by team-abnormals.

the class FlareEntity method getSize.

public EntitySize getSize(Pose poseIn) {
    int i = this.getPhantomSize();
    EntitySize entitysize = super.getSize(poseIn);
    float f = (entitysize.width + 0.2F * (float) i) / entitysize.width;
    return entitysize.scale(f);
}
Also used : EntitySize(net.minecraft.entity.EntitySize)

Example 2 with EntitySize

use of net.minecraft.entity.EntitySize in project VariousOddities by Lyinginbedmon.

the class AbilitySize method handleSize.

public void handleSize(EntityEvent.Size event) {
    if (event.getEntity() instanceof LivingEntity && event.getEntity().getType() == EntityType.PLAYER) {
        LivingEntity living = (LivingEntity) event.getEntity();
        LivingData data = LivingData.forEntity(living);
        if (data == null || !AbilityRegistry.hasAbility(living, REGISTRY_NAME))
            return;
        AbilitySize size = (AbilitySize) AbilityRegistry.getAbilityByName(living, REGISTRY_NAME);
        if (size == null)
            return;
        if (!event.getEntity().isAddedToWorld())
            return;
        float scale = size.getScale();
        EntitySize baseSize = event.getNewSize();
        event.setNewSize(EntitySize.fixed(baseSize.width * scale, baseSize.height * scale));
        event.setNewEyeHeight(event.getNewEyeHeight() * scale);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EntitySize(net.minecraft.entity.EntitySize) LivingData(com.lying.variousoddities.capabilities.LivingData)

Example 3 with EntitySize

use of net.minecraft.entity.EntitySize in project BudschieMorphMod by Budschie.

the class Events method onCalculatingAABB.

@SubscribeEvent(priority = EventPriority.LOW)
public static void onCalculatingAABB(EntityEvent.Size event) {
    if (event.getEntity() instanceof PlayerEntity) {
        PlayerEntity player = (PlayerEntity) event.getEntity();
        LazyOptional<IMorphCapability> cap = player.getCapability(MorphCapabilityAttacher.MORPH_CAP);
        if (cap.isPresent()) {
            float divisor = ShrinkAPIInteractor.getInteractor().getShrinkingValue(player);
            IMorphCapability resolved = cap.resolve().get();
            resolved.getCurrentMorph().ifPresent(item -> {
                try {
                    Entity createdEntity = item.createEntity(event.getEntity().world);
                    createdEntity.setPose(event.getPose());
                    // We do this as we apply our own sneaking logic as I couldn't figure out how to get the multiplier for the eye height... F in the chat plz
                    EntitySize newSize = createdEntity.getSize(Pose.STANDING);
                    if (ShrinkAPIInteractor.getInteractor().isShrunk(player)) {
                        newSize = newSize.scale(1.6f / divisor, 1 / divisor);
                    }
                    if (event.getPose() == Pose.CROUCHING)
                        newSize = newSize.scale(1, .85f);
                    event.setNewSize(newSize, false);
                    // event.setNewEyeHeight(createdEntity.getEyeHeightAccess(event.getPose(), newSize));
                    event.setNewEyeHeight(newSize.height * 0.85f);
                // event.setNewEyeHeight(player.getEyeHeightAccess(event.getPose(), createdEntity.getSize(event.getPose())));
                } catch (NullPointerException ex) {
                    LOGGER.catching(ex);
                    if (!player.world.isRemote)
                        MorphUtil.morphToServer(Optional.empty(), Optional.empty(), player);
                    else {
                        resolved.demorph();
                        player.sendMessage(new StringTextComponent(TextFormatting.RED + "Couldn't morph to " + item.getEntityType().getRegistryName().toString() + ". This is a compatability issue. If possible, report this to the mod author on GitHub."), new UUID(0, 0));
                    }
                }
            });
        }
    }
}
Also used : IMorphCapability(de.budschie.bmorph.capabilities.IMorphCapability) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) MobEntity(net.minecraft.entity.MobEntity) Entity(net.minecraft.entity.Entity) MorphEntity(de.budschie.bmorph.entity.MorphEntity) EntitySize(net.minecraft.entity.EntitySize) StringTextComponent(net.minecraft.util.text.StringTextComponent) UUID(java.util.UUID) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with EntitySize

use of net.minecraft.entity.EntitySize in project AstralSorcery by HellFirePvP.

the class TimeStopEffectHelper method playEntityParticles.

@OnlyIn(Dist.CLIENT)
static void playEntityParticles(LivingEntity e) {
    EntitySize size = e.getSize(e.getPose());
    double x = e.getPosX() - size.width / 2F + rand.nextFloat() * size.width;
    double y = e.getPosY() + rand.nextFloat() * size.height;
    double z = e.getPosZ() - size.width / 2F + rand.nextFloat() * size.width;
    playParticles(x, y, z);
}
Also used : EntitySize(net.minecraft.entity.EntitySize) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 5 with EntitySize

use of net.minecraft.entity.EntitySize in project ChocolateQuestRepoured by TeamChocoQuest.

the class AbstractEntityCQR method getDimensionsCloneFromEntity.

@Nullable
private EntitySize getDimensionsCloneFromEntity(Pose poseIn) {
    if (poseIn != null) {
        EntitySize result = poseIn == Pose.SLEEPING ? SLEEPING_DIMENSIONS : this.getSize();
        if (result == null) {
            return null;
        }
        float scale = this.getSizeVariation();
        result = result.scale(scale);
        if (poseIn != Pose.SLEEPING) {
            if (this.isSitting()) {
                result.scale(1.0F, 0.75F);
            }
        }
        return result;
    }
    return this.getSize();
}
Also used : EntitySize(net.minecraft.entity.EntitySize) Nullable(javax.annotation.Nullable)

Aggregations

EntitySize (net.minecraft.entity.EntitySize)7 LivingData (com.lying.variousoddities.capabilities.LivingData)1 IMorphCapability (de.budschie.bmorph.capabilities.IMorphCapability)1 MorphEntity (de.budschie.bmorph.entity.MorphEntity)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 StringTextComponent (net.minecraft.util.text.StringTextComponent)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1