Search in sources :

Example 11 with LivingData

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

the class VOBusServer method onPlayerRespawnEvent.

@SubscribeEvent
public static void onPlayerRespawnEvent(PlayerRespawnEvent event) {
    LivingData livingData = LivingData.forEntity(event.getPlayer());
    if (livingData != null)
        livingData.getAbilities().markDirty();
    if (AbilityRegistry.hasAbility(event.getPlayer(), AbilitySize.REGISTRY_NAME))
        event.getPlayer().recalculateSize();
    if (PlayerData.isPlayerBodyDead(event.getPlayer())) {
        PlayerData playerData = PlayerData.forPlayer(event.getPlayer());
        playerData.setBodyCondition(BodyCondition.ALIVE);
        playerData.setSoulCondition(SoulCondition.ALIVE);
    }
}
Also used : PacketSyncLivingData(com.lying.variousoddities.network.PacketSyncLivingData) LivingData(com.lying.variousoddities.capabilities.LivingData) PlayerData(com.lying.variousoddities.capabilities.PlayerData) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 12 with LivingData

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

the class VOBusServer method applyNativeExtraplanar.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void applyNativeExtraplanar(GetEntityTypesEvent event) {
    LivingEntity entity = event.getEntity();
    LivingData data = LivingData.forEntity(entity);
    if (data == null)
        return;
    if (data.getHomeDimension() != null) {
        List<EnumCreatureType> types = event.getTypes();
        if (types.contains(EnumCreatureType.EXTRAPLANAR) || types.contains(EnumCreatureType.NATIVE))
            return;
        ResourceLocation currentDim = entity.getEntityWorld().getDimensionKey().getLocation();
        if (currentDim.equals(data.getHomeDimension())) {
            if (!types.contains(EnumCreatureType.EXTRAPLANAR) && EnumCreatureType.NATIVE.canApplyTo(types))
                event.getTypes().add(EnumCreatureType.NATIVE);
        } else {
            if (!types.contains(EnumCreatureType.NATIVE) && EnumCreatureType.EXTRAPLANAR.canApplyTo(types))
                event.getTypes().add(EnumCreatureType.EXTRAPLANAR);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EnumCreatureType(com.lying.variousoddities.species.types.EnumCreatureType) ResourceLocation(net.minecraft.util.ResourceLocation) PacketSyncLivingData(com.lying.variousoddities.network.PacketSyncLivingData) LivingData(com.lying.variousoddities.capabilities.LivingData) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 13 with LivingData

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

the class VOBusServer method onPlayerLogInEvent.

@SubscribeEvent
public static void onPlayerLogInEvent(PlayerLoggedInEvent event) {
    PlayerEntity player = event.getPlayer();
    PacketHandler.sendTo((ServerPlayerEntity) player, new PacketSyncSpecies(VORegistries.SPECIES));
    LivingData data = LivingData.forEntity(player);
    if (data != null) {
        PacketHandler.sendToAll((ServerWorld) player.getEntityWorld(), new PacketSyncLivingData(player.getUniqueID(), data));
        data.getAbilities().markDirty();
        if (!data.hasSelectedSpecies() && ConfigVO.MOBS.selectSpeciesOnLogin.get()) {
            if (!player.getEntityWorld().isRemote)
                PacketHandler.sendTo((ServerPlayerEntity) player, new PacketSpeciesOpenScreen());
            player.addPotionEffect(new EffectInstance(Effects.RESISTANCE, Reference.Values.TICKS_PER_MINUTE * 15, 15, true, false));
        }
    }
}
Also used : PacketSpeciesOpenScreen(com.lying.variousoddities.network.PacketSpeciesOpenScreen) PacketSyncLivingData(com.lying.variousoddities.network.PacketSyncLivingData) LivingData(com.lying.variousoddities.capabilities.LivingData) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) PacketSyncSpecies(com.lying.variousoddities.network.PacketSyncSpecies) PacketSyncLivingData(com.lying.variousoddities.network.PacketSyncLivingData) EffectInstance(net.minecraft.potion.EffectInstance) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 14 with LivingData

use of com.lying.variousoddities.capabilities.LivingData 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 15 with LivingData

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

the class GuiHandler method renderBludgeoning.

@SuppressWarnings("deprecation")
public static void renderBludgeoning(RenderGameOverlayEvent.Pre event) {
    mc = Minecraft.getInstance();
    if (event.getType() != RenderGameOverlayEvent.ElementType.HEALTH || event.isCanceled() || !PlayerData.isPlayerNormalFunction(mc.player) || VOHelper.isCreativeOrSpectator(mc.player))
        return;
    profiler = mc.getProfiler();
    profiler.startSection("varodd-hud-bludgeoning");
    player = Minecraft.getInstance().player;
    if (player != null) {
        LivingData data = LivingData.forEntity(player);
        if (data != null && !PlayerData.isPlayerBodyAsleep(player)) {
            mc.getTextureManager().bindTexture(HUD_ICONS);
            float bludgeoning = data.getBludgeoning();
            float val = MathHelper.clamp(bludgeoning / player.getHealth(), 0F, 1F);
            int width = (int) (val * 81);
            int height = 9;
            int right = mc.getMainWindow().getScaledWidth() / 2 - 91;
            int top = mc.getMainWindow().getScaledHeight() - ForgeIngameGui.right_height;
            RenderSystem.enableBlend();
            RenderSystem.color4f(1F, 1F, 1F, 0.75F);
            RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            mc.ingameGUI.blit(event.getMatrixStack(), right, top, 0, 0, width, height);
            RenderSystem.disableBlend();
            RenderSystem.color4f(1F, 1F, 1F, 1F);
            mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);
        }
    }
    profiler.endSection();
}
Also used : LivingData(com.lying.variousoddities.capabilities.LivingData)

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