Search in sources :

Example 1 with LivingData

use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.

the class CommandAbilities method clearAbilities.

private static int clearAbilities(Entity entity, CommandSource source) throws CommandSyntaxException {
    if (entity instanceof LivingEntity) {
        LivingEntity living = (LivingEntity) entity;
        LivingData data = LivingData.forEntity(living);
        int tally = data.getAbilities().size();
        data.getAbilities().clearCustomAbilities();
        source.sendFeedback(new TranslationTextComponent(translationSlug + "clear", tally, living.getDisplayName()), true);
    } else
        throw INVALID_ENTITY_EXCEPTION.create();
    return 15;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) LivingData(com.lying.variousoddities.capabilities.LivingData)

Example 2 with LivingData

use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.

the class LayerPetrified method render.

public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
    LivingData data = LivingData.forEntity(entitylivingbaseIn);
    if (data == null || !data.getVisualPotion(VOPotions.PETRIFIED))
        return;
    matrixStackIn.push();
    IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RenderType.getEntitySolid(petrifiedTexture));
    EntityModel<T> model = getEntityModel();
    model.setLivingAnimations(entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks);
    model.setRotationAngles(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
    model.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1F, 1F, 1F, 1F);
    matrixStackIn.pop();
}
Also used : LivingData(com.lying.variousoddities.capabilities.LivingData) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 3 with LivingData

use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.

the class EntityPredicateMixin method canTarget.

@Inject(method = "canTarget(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/LivingEntity;)Z", at = @At("RETURN"), cancellable = true)
public void canTarget(LivingEntity attacker, LivingEntity victim, final CallbackInfoReturnable<Boolean> ci) {
    if (victim == null)
        return;
    LivingData data = LivingData.forEntity(attacker);
    if (data != null && data.isTargetingHindered(victim)) {
        ci.setReturnValue(false);
        ci.cancel();
    } else if (victim.getType() == EntityType.PLAYER)
        if (!PlayerData.isPlayerNormalFunction(victim)) {
            if (attacker instanceof MobEntity) {
                MobEntity mob = (MobEntity) attacker;
                if (mob.getAttackTarget() != null && mob.getAttackTarget().equals(victim))
                    mob.setAttackTarget(null);
            }
            ci.setReturnValue(false);
            ci.cancel();
        }
}
Also used : LivingData(com.lying.variousoddities.capabilities.LivingData) MobEntity(net.minecraft.entity.MobEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with LivingData

use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.

the class LivingEntityMixin method canTarget.

@Inject(method = "canTarget(Lnet/minecraft/entity/LivingEntity;)Z", at = @At("HEAD"), cancellable = true)
public void canTarget(LivingEntity living, final CallbackInfoReturnable<Boolean> ci) {
    LivingEntity entity = (LivingEntity) (Object) this;
    LivingData data = LivingData.forEntity(entity);
    if (data.isTargetingHindered(living))
        ci.setReturnValue(false);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) LivingData(com.lying.variousoddities.capabilities.LivingData) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with LivingData

use of com.lying.variousoddities.capabilities.LivingData in project VariousOddities by Lyinginbedmon.

the class NearestAttackableTargetGoalMixin method getPredicate.

private static Predicate<LivingEntity> getPredicate(LivingEntity goalOwnerIn) {
    return new Predicate<LivingEntity>() {

        public boolean test(LivingEntity target) {
            // Undead mobs do not target other undead
            if (goalOwnerIn.isNonBoss() && goalOwnerIn.isEntityUndead())
                if (target.isEntityUndead())
                    return false;
            // Mobs do not attack creatures that have mind-controlled them somehow
            LivingData mobData = LivingData.forEntity(goalOwnerIn);
            if (mobData != null && mobData.isTargetingHindered(target))
                return false;
            // Faction mobs do not attack mobs with good reputation
            if (goalOwnerIn instanceof IFactionMob) {
                FactionManager factionManager = FactionManager.get(target.getEntityWorld());
                Faction ownerFaction = factionManager.getFaction(goalOwnerIn);
                if (ownerFaction != null)
                    if (target.getType() == EntityType.PLAYER) {
                        PlayerData data = PlayerData.forPlayer((PlayerEntity) target);
                        if (data != null) {
                            int reputation = data.reputation.getReputation(ownerFaction.name);
                            if (reputation == Integer.MIN_VALUE) {
                                data.reputation.setReputation(ownerFaction.name, ownerFaction.startingRep);
                                reputation = ownerFaction.startingRep;
                            }
                            return EnumAttitude.fromRep(reputation).allowsInteraction(EnumInteraction.ATTACK);
                        }
                    } else if (target instanceof IFactionMob) {
                        Faction inputFaction = factionManager.getFaction(target);
                        if (inputFaction != null)
                            return ownerFaction.relationWith(inputFaction.name).allowsInteraction(EnumInteraction.ATTACK);
                    }
            }
            return true;
        }
    };
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) IFactionMob(com.lying.variousoddities.api.entity.IFactionMob) LivingData(com.lying.variousoddities.capabilities.LivingData) FactionManager(com.lying.variousoddities.world.savedata.FactionManager) PlayerData(com.lying.variousoddities.capabilities.PlayerData) Predicate(java.util.function.Predicate) Faction(com.lying.variousoddities.world.savedata.FactionManager.Faction) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

LivingData (com.lying.variousoddities.capabilities.LivingData)42 LivingEntity (net.minecraft.entity.LivingEntity)24 PlayerEntity (net.minecraft.entity.player.PlayerEntity)18 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)11 PacketSyncLivingData (com.lying.variousoddities.network.PacketSyncLivingData)10 NetworkEvent (net.minecraftforge.fml.network.NetworkEvent)10 CommonProxy (com.lying.variousoddities.proxy.CommonProxy)9 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)9 PlayerData (com.lying.variousoddities.capabilities.PlayerData)6 Abilities (com.lying.variousoddities.capabilities.Abilities)5 MobEntity (net.minecraft.entity.MobEntity)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 World (net.minecraft.world.World)5 Inject (org.spongepowered.asm.mixin.injection.Inject)5 CreatureEntity (net.minecraft.entity.CreatureEntity)4 Entity (net.minecraft.entity.Entity)4 FireballEntity (net.minecraft.entity.projectile.FireballEntity)4 CompoundNBT (net.minecraft.nbt.CompoundNBT)4 Species (com.lying.variousoddities.species.Species)3 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)3