Search in sources :

Example 1 with AbilitySize

use of com.lying.variousoddities.species.abilities.AbilitySize in project VariousOddities by Lyinginbedmon.

the class EntityMixin method getSize.

@Inject(method = "getBoundingBox(Lnet/minecraft/entity/Pose;)Lnet/minecraft/util/math/AxisAlignedBB;", at = @At("TAIL"), cancellable = true)
public void getSize(Pose poseIn, final CallbackInfoReturnable<AxisAlignedBB> ci) {
    Entity ent = (Entity) (Object) this;
    if (ent.getType() == EntityType.PLAYER && AbilityRegistry.hasAbility((PlayerEntity) ent, AbilitySize.REGISTRY_NAME)) {
        AbilitySize size = (AbilitySize) AbilityRegistry.getAbilityByName((PlayerEntity) ent, AbilitySize.REGISTRY_NAME);
        if (size == null)
            return;
        AxisAlignedBB baseSize = ci.getReturnValue();
        float scale = size.getScale();
        double posX = ent.getPosX();
        double posY = ent.getPosY();
        double posZ = ent.getPosZ();
        double lenX = baseSize.getXSize() * scale * 0.5D;
        double lenY = baseSize.getYSize() * scale;
        double lenZ = baseSize.getZSize() * scale * 0.5D;
        AxisAlignedBB trueSize = new AxisAlignedBB(posX - lenX, posY, posZ - lenZ, posX + lenX, posY + lenY, posZ + lenZ);
        ci.setReturnValue(trueSize);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) AbilitySize(com.lying.variousoddities.species.abilities.AbilitySize) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with AbilitySize

use of com.lying.variousoddities.species.abilities.AbilitySize in project VariousOddities by Lyinginbedmon.

the class VOBusClient method resizeEntity.

@SuppressWarnings("rawtypes")
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static <T extends LivingEntity, M extends EntityModel<T>> void resizeEntity(RenderLivingEvent.Pre event) {
    LivingEntity renderTarget = event.getEntity();
    AbilitySize size = (AbilitySize) AbilityRegistry.getAbilityByName(renderTarget, AbilitySize.REGISTRY_NAME);
    if (size == null)
        return;
    float scale = size.getScale();
    event.getMatrixStack().scale(scale, scale, scale);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) AbilitySize(com.lying.variousoddities.species.abilities.AbilitySize) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

AbilitySize (com.lying.variousoddities.species.abilities.AbilitySize)2 LivingEntity (net.minecraft.entity.LivingEntity)2 Entity (net.minecraft.entity.Entity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1