Search in sources :

Example 1 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class EventManager method onClientKeyPress.

/**
     * <h2>Keybind management</h2>
     * called when a client presses a key. this coveres pretty much everything.
     * Most cases just send a packet to manage things
     * @see PacketKeyPress
     *
     * Credit to Ferdinand for help with this function.
     *
     * @param event the event of a key being pressed on client.
     */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientKeyPress(InputEvent.KeyInputEvent event) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    if (player.ridingEntity instanceof GenericRailTransport || player.ridingEntity instanceof EntitySeat) {
        //for lamp
        if (ClientProxy.KeyLamp.isPressed()) {
            TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(0, player.ridingEntity.getEntityId()));
            ((GenericRailTransport) player.ridingEntity).setBoolean(GenericRailTransport.boolValues.LAMP, !((GenericRailTransport) player.ridingEntity).getBoolean(GenericRailTransport.boolValues.LAMP));
        }
        //for inventory
        if (ClientProxy.KeyInventory.isPressed()) {
            TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(1, player.ridingEntity.getEntityId()));
        }
        if (player.ridingEntity instanceof EntityTrainCore) {
            //for speed change
            if (ClientProxy.KeyAccelerate.isPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(2, player.ridingEntity.getEntityId()));
            } else if (ClientProxy.KeyReverse.getIsKeyPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(3, player.ridingEntity.getEntityId()));
            } else if (ClientProxy.KeyHorn.isPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(4, player.ridingEntity.getEntityId()));
            }
        }
    }
}
Also used : EntityTrainCore(ebf.tim.entities.EntityTrainCore) PacketKeyPress(ebf.tim.networking.PacketKeyPress) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) EntitySeat(ebf.tim.entities.EntitySeat) GenericRailTransport(ebf.tim.entities.GenericRailTransport) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project TecTech by Technus.

the class ConstructableTriggerItem method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) {
    TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
    if (tTileEntity == null || aPlayer instanceof FakePlayer) {
        return aPlayer instanceof EntityPlayerMP;
    }
    if (aPlayer instanceof EntityPlayerMP) {
        // struct gen
        if (aPlayer.isSneaking() && aPlayer.capabilities.isCreativeMode) {
            if (tTileEntity instanceof IGregTechTileEntity) {
                IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
                if (metaTE instanceof IConstructable) {
                    ((IConstructable) metaTE).construct(aStack.stackSize, false);
                } else if (multiblockMap.containsKey(metaTE.getClass().getCanonicalName())) {
                    multiblockMap.get(metaTE.getClass().getCanonicalName()).construct(aStack.stackSize, false, tTileEntity, ((IGregTechTileEntity) tTileEntity).getFrontFacing());
                }
            } else if (tTileEntity instanceof IConstructable) {
                ((IConstructable) tTileEntity).construct(aStack.stackSize, false);
            } else if (multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())) {
                multiblockMap.get(tTileEntity.getClass().getCanonicalName()).construct(aStack.stackSize, false, tTileEntity, aSide);
            }
        }
        return true;
    } else if (aPlayer instanceof EntityClientPlayerMP) {
        // if ((!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode)) {
        if (tTileEntity instanceof IGregTechTileEntity) {
            IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
            if (metaTE instanceof IConstructable) {
                ((IConstructable) metaTE).construct(aStack.stackSize, true);
                TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize));
                return false;
            } else if (multiblockMap.containsKey(metaTE.getClass().getCanonicalName())) {
                multiblockMap.get(metaTE.getClass().getCanonicalName()).construct(aStack.stackSize, true, tTileEntity, ((IGregTechTileEntity) tTileEntity).getFrontFacing());
                TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize));
                return false;
            }
        } else if (tTileEntity instanceof IConstructable) {
            ((IConstructable) tTileEntity).construct(aStack.stackSize, true);
            TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize));
            return false;
        } else if (multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())) {
            multiblockMap.get(tTileEntity.getClass().getCanonicalName()).construct(aStack.stackSize, true, tTileEntity, aSide);
            TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize));
            return false;
        }
    // } else {
    // if(tTileEntity instanceof IGregTechTileEntity) {
    // IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
    // if (metaTE instanceof IConstructable) {
    // TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize));
    // return false;
    // } else if(multiblockMap.containsKey(metaTE.getClass().getCanonicalName())){
    // TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize));
    // return false;
    // }
    // } else if(tTileEntity instanceof IConstructable){
    // TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize));
    // return false;
    // } else if(multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())){
    // TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize));
    // return false;
    // }
    // }
    }
    return false;
}
Also used : IGregTechTileEntity(gregtech.api.interfaces.tileentity.IGregTechTileEntity) IMetaTileEntity(gregtech.api.interfaces.metatileentity.IMetaTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) IGregTechTileEntity(gregtech.api.interfaces.tileentity.IGregTechTileEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IConstructable(com.github.technus.tectech.thing.metaTileEntity.IConstructable) FakePlayer(net.minecraftforge.common.util.FakePlayer) IMetaTileEntity(gregtech.api.interfaces.metatileentity.IMetaTileEntity)

Example 3 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project Armourers-Workshop by RiskyKen.

the class MessageServerLibraryFileList method onMessage.

@Override
public IMessage onMessage(MessageServerLibraryFileList message, MessageContext ctx) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    Container container = player.openContainer;
    ModLogger.log("got file list type " + message.listType);
    ArmourersWorkshop.proxy.libraryManager.setFileList(message.fileList, message.listType);
    return null;
}
Also used : Container(net.minecraft.inventory.Container) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP)

Example 4 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project Armourers-Workshop by RiskyKen.

the class MessageServerMiniArmourerSkinData method onMessage.

@Override
public IMessage onMessage(MessageServerMiniArmourerSkinData message, MessageContext ctx) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    Minecraft mc = Minecraft.getMinecraft();
    GuiScreen screen = mc.currentScreen;
    if (screen != null && screen instanceof GuiMiniArmourerBuilding) {
        ((GuiMiniArmourerBuilding) screen).tileEntity.setSkinParts(message.skinParts);
    }
    return null;
}
Also used : EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) GuiMiniArmourerBuilding(riskyken.armourersWorkshop.client.gui.miniarmourer.GuiMiniArmourerBuilding) GuiScreen(net.minecraft.client.gui.GuiScreen) Minecraft(net.minecraft.client.Minecraft)

Example 5 with EntityClientPlayerMP

use of net.minecraft.client.entity.EntityClientPlayerMP in project Armourers-Workshop by RiskyKen.

the class RenderSkinnedArrow method doRender.

@Override
public void doRender(EntityArrow entityArrow, double x, double y, double z, float yaw, float partialTickTime) {
    if (entityArrow.shootingEntity != null && entityArrow.shootingEntity instanceof EntityClientPlayerMP) {
        EntityClientPlayerMP player = (EntityClientPlayerMP) entityArrow.shootingEntity;
        IEntityEquipment entityEquipment = equipmentModelRenderer.getPlayerCustomEquipmentData(player);
        if (entityEquipment != null && entityEquipment.haveEquipment(SkinTypeRegistry.skinBow, 0)) {
            ISkinPointer skinPointer = entityEquipment.getSkinPointer(SkinTypeRegistry.skinBow, 0);
            if (ClientSkinCache.INSTANCE.isSkinInCache(skinPointer)) {
                Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
                if (skin != null) {
                    SkinPart skinPart = skin.getPart("armourers:bow.arrow");
                    if (skinPart != null) {
                        ModRenderHelper.enableAlphaBlend();
                        renderArrowSkin(entityArrow, x, y, z, partialTickTime, skinPart, skinPointer.getSkinDye());
                        ModRenderHelper.disableAlphaBlend();
                        return;
                    }
                }
            } else {
                ClientSkinCache.INSTANCE.requestSkinFromServer(skinPointer);
            }
        }
    }
    super.doRender(entityArrow, x, y, z, yaw, partialTickTime);
}
Also used : EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) IEntityEquipment(riskyken.armourersWorkshop.api.common.skin.IEntityEquipment) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Aggregations

EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)16 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 Minecraft (net.minecraft.client.Minecraft)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 GuiScreen (net.minecraft.client.gui.GuiScreen)2 ClickEvent (net.minecraft.event.ClickEvent)2 HoverEvent (net.minecraft.event.HoverEvent)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 GuiMiniArmourerBuilding (riskyken.armourersWorkshop.client.gui.miniarmourer.GuiMiniArmourerBuilding)2 EntityAirSled (am2.entities.EntityAirSled)1 IConstructable (com.github.technus.tectech.thing.metaTileEntity.IConstructable)1 EntitySeat (ebf.tim.entities.EntitySeat)1 EntityTrainCore (ebf.tim.entities.EntityTrainCore)1 GenericRailTransport (ebf.tim.entities.GenericRailTransport)1 PacketKeyPress (ebf.tim.networking.PacketKeyPress)1 IMetaTileEntity (gregtech.api.interfaces.metatileentity.IMetaTileEntity)1 IGregTechTileEntity (gregtech.api.interfaces.tileentity.IGregTechTileEntity)1 List (java.util.List)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 GuiPlayerInfo (net.minecraft.client.gui.GuiPlayerInfo)1