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;
}
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();
}
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();
}
}
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);
}
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;
}
};
}
Aggregations