Search in sources :

Example 1 with PlayerPreferencesProperties

use of mcjty.lib.preferences.PlayerPreferencesProperties in project RFTools by McJty.

the class FMLEventHandlers method onPlayerTickEvent.

@SubscribeEvent
public void onPlayerTickEvent(TickEvent.PlayerTickEvent event) {
    if (event.phase == TickEvent.Phase.START && !event.player.worldObj.isRemote) {
        IExtendedEntityProperties properties = event.player.getExtendedProperties(PlayerExtendedProperties.ID);
        if (properties instanceof PlayerExtendedProperties) {
            PlayerExtendedProperties playerExtendedProperties = (PlayerExtendedProperties) properties;
            playerExtendedProperties.tick();
        }
        properties = event.player.getExtendedProperties(PlayerPreferencesProperties.ID);
        if (properties instanceof PlayerPreferencesProperties) {
            PlayerPreferencesProperties preferencesProperties = (PlayerPreferencesProperties) properties;
            preferencesProperties.tick(RFToolsMessages.INSTANCE);
        }
    }
}
Also used : PlayerExtendedProperties(mcjty.rftools.playerprops.PlayerExtendedProperties) IExtendedEntityProperties(net.minecraftforge.common.IExtendedEntityProperties) PlayerPreferencesProperties(mcjty.lib.preferences.PlayerPreferencesProperties) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with PlayerPreferencesProperties

use of mcjty.lib.preferences.PlayerPreferencesProperties in project RFTools by McJty.

the class RenderGameOverlayEventHandler method renderBuffs.

private static void renderBuffs() {
    if (buffs == null || buffs.isEmpty()) {
        return;
    }
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    PlayerPreferencesProperties properties = PlayerPreferencesProperties.getProperties(player);
    int x = properties.getPreferencesProperties().getBuffX();
    int y = properties.getPreferencesProperties().getBuffY();
    if (x == -1 || y == -1) {
        return;
    }
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    for (PlayerBuff buff : buffs) {
        Item item;
        switch(buff) {
            case BUFF_FEATHERFALLING:
                item = EnvironmentalSetup.featherFallingEModuleItem;
                break;
            case BUFF_FEATHERFALLINGPLUS:
                item = EnvironmentalSetup.featherFallingPlusEModuleItem;
                break;
            case BUFF_HASTE:
                item = EnvironmentalSetup.hasteEModuleItem;
                break;
            case BUFF_HASTEPLUS:
                item = EnvironmentalSetup.hastePlusEModuleItem;
                break;
            case BUFF_REGENERATION:
                item = EnvironmentalSetup.regenerationEModuleItem;
                break;
            case BUFF_REGENERATIONPLUS:
                item = EnvironmentalSetup.regenerationPlusEModuleItem;
                break;
            case BUFF_SATURATION:
                item = EnvironmentalSetup.saturationEModuleItem;
                break;
            case BUFF_SATURATIONPLUS:
                item = EnvironmentalSetup.saturationPlusEModuleItem;
                break;
            case BUFF_SPEED:
                item = EnvironmentalSetup.speedEModuleItem;
                break;
            case BUFF_SPEEDPLUS:
                item = EnvironmentalSetup.speedPlusEModuleItem;
                break;
            case BUFF_FLIGHT:
                item = EnvironmentalSetup.flightEModuleItem;
                break;
            case BUFF_PEACEFUL:
                item = EnvironmentalSetup.peacefulEModuleItem;
                break;
            case BUFF_WATERBREATHING:
                item = EnvironmentalSetup.waterBreathingEModuleItem;
                break;
            case BUFF_NIGHTVISION:
                item = EnvironmentalSetup.nightVisionEModuleItem;
                break;
            case BUFF_BLINDNESS:
                item = EnvironmentalSetup.blindnessEModuleItem;
                break;
            case BUFF_WEAKNESS:
                item = EnvironmentalSetup.weaknessEModuleItem;
                break;
            case BUFF_POISON:
                item = EnvironmentalSetup.poisonEModuleItem;
                break;
            case BUFF_SLOWNESS:
                item = EnvironmentalSetup.slownessEModuleItem;
                break;
            default:
                item = null;
        }
        if (item != null) {
            IIcon icon = item.getIconFromDamage(0);
            RenderHelper.renderIcon(Minecraft.getMinecraft(), itemRender, icon, x, y, false);
            x += BUFF_ICON_SIZE;
        }
    }
}
Also used : Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.entity.RenderItem) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) IIcon(net.minecraft.util.IIcon) PlayerPreferencesProperties(mcjty.lib.preferences.PlayerPreferencesProperties)

Example 3 with PlayerPreferencesProperties

use of mcjty.lib.preferences.PlayerPreferencesProperties in project RFTools by McJty.

the class CmdSetBuffBar method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    if (!(sender instanceof EntityPlayer)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This command only works as a player!"));
        return;
    }
    EntityPlayer player = (EntityPlayer) sender;
    PlayerPreferencesProperties properties = PlayerPreferencesProperties.getProperties(player);
    if (args.length < 3) {
        int buffX = properties.getPreferencesProperties().getBuffX();
        int buffY = properties.getPreferencesProperties().getBuffY();
        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Current buffbar location: " + buffX + "," + buffY));
        return;
    }
    int x = fetchInt(sender, args, 1, 0);
    int y = fetchInt(sender, args, 2, 0);
    properties.getPreferencesProperties().setBuffXY(x, y);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText) PlayerPreferencesProperties(mcjty.lib.preferences.PlayerPreferencesProperties)

Example 4 with PlayerPreferencesProperties

use of mcjty.lib.preferences.PlayerPreferencesProperties in project RFTools by McJty.

the class CmdReset method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 1) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    if (!(sender instanceof EntityPlayer)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This command only works as a player!"));
        return;
    }
    EntityPlayer player = (EntityPlayer) sender;
    PlayerPreferencesProperties properties = PlayerPreferencesProperties.getProperties(player);
    properties.getPreferencesProperties().reset();
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText) PlayerPreferencesProperties(mcjty.lib.preferences.PlayerPreferencesProperties)

Example 5 with PlayerPreferencesProperties

use of mcjty.lib.preferences.PlayerPreferencesProperties in project RFTools by McJty.

the class ForgeEventHandlers method onEntityConstructingEvent.

@SubscribeEvent
public void onEntityConstructingEvent(EntityEvent.EntityConstructing event) {
    if (event.entity instanceof EntityPlayer) {
        PlayerExtendedProperties properties = new PlayerExtendedProperties();
        event.entity.registerExtendedProperties(PlayerExtendedProperties.ID, properties);
        PlayerPreferencesProperties preferencesProperties = (PlayerPreferencesProperties) event.entity.getExtendedProperties(PlayerPreferencesProperties.ID);
        if (preferencesProperties == null) {
            preferencesProperties = new PlayerPreferencesProperties();
            event.entity.registerExtendedProperties(PlayerPreferencesProperties.ID, preferencesProperties);
        }
    }
}
Also used : PlayerExtendedProperties(mcjty.rftools.playerprops.PlayerExtendedProperties) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PlayerPreferencesProperties(mcjty.lib.preferences.PlayerPreferencesProperties) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

PlayerPreferencesProperties (mcjty.lib.preferences.PlayerPreferencesProperties)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ChatComponentText (net.minecraft.util.ChatComponentText)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 PlayerExtendedProperties (mcjty.rftools.playerprops.PlayerExtendedProperties)2 GuiStyle (mcjty.lib.gui.GuiStyle)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1 RenderItem (net.minecraft.client.renderer.entity.RenderItem)1 Item (net.minecraft.item.Item)1 IIcon (net.minecraft.util.IIcon)1 IExtendedEntityProperties (net.minecraftforge.common.IExtendedEntityProperties)1