Search in sources :

Example 16 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project BluePower by Qmunity.

the class PneumaticTube method rayTrace.

@Override
public QMovingObjectPosition rayTrace(Vec3d start, Vec3d end) {
    QMovingObjectPosition mop = super.rayTrace(start, end);
    if (mop == null)
        return null;
    EntityPlayer player = BluePower.proxy.getPlayer();
    if (redwireType != null && player != null && player.isSneaking()) {
        double wireSize = getSize() / 16D;
        double frameSeparation = 4 / 16D - (wireSize - 2 / 16D);
        double frameThickness = 1 / 16D;
        frameThickness /= 1.5;
        frameSeparation -= 1 / 32D;
        QMovingObjectPosition wire = RayTracer.instance().rayTraceCubes(getFrameBoxes(wireSize, frameSeparation, frameThickness, shouldRenderConnection(ForgeDirection.DOWN), shouldRenderConnection(ForgeDirection.UP), shouldRenderConnection(ForgeDirection.WEST), shouldRenderConnection(ForgeDirection.EAST), shouldRenderConnection(ForgeDirection.NORTH), shouldRenderConnection(ForgeDirection.SOUTH), redstoneConnections[ForgeDirection.DOWN.ordinal()], redstoneConnections[ForgeDirection.UP.ordinal()], redstoneConnections[ForgeDirection.WEST.ordinal()], redstoneConnections[ForgeDirection.EAST.ordinal()], redstoneConnections[ForgeDirection.NORTH.ordinal()], redstoneConnections[ForgeDirection.SOUTH.ordinal()], getParent() != null && getWorld() != null), start, end, new Vec3i(this));
        QMovingObjectPosition frame = RayTracer.instance().rayTraceCubes(getFrameBoxes(), start, end, new Vec3i(this));
        if (wire != null) {
            if (frame != null) {
                if (wire.hitVec.distanceTo(start.toVec3()) < frame.hitVec.distanceTo(start.toVec3()))
                    mop.hitInfo = PartManager.getPartInfo("wire." + redwireType.getName()).getStack();
            } else {
                mop.hitInfo = PartManager.getPartInfo("wire." + redwireType.getName()).getStack();
            }
        }
    }
    return mop;
}
Also used : Vec3i(uk.co.qmunity.lib.vec.Vec3i) EntityPlayer(net.minecraft.entity.player.EntityPlayer) QMovingObjectPosition(uk.co.qmunity.lib.raytrace.QMovingObjectPosition)

Example 17 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.

the class MorePageDisplay method display.

public void display(ICommandSender sender, int page, boolean flag, boolean all, int linesub) {
    if (terminated) {
        return;
    }
    sender.addChatMessage(new ChatComponentText("%LPCLEARCHAT%"));
    int count = row - header.size() - 1 - linesub;
    page = (page > 0 && !all ? page : 1);
    currentpage = page;
    int pagecount = getPageCount(count);
    currentpagecount = pagecount;
    if (all) {
        count = -2;
    }
    for (Object zeilenobject : header.toArray()) {
        if (!(zeilenobject instanceof String)) {
            continue;
        }
        sender.addChatMessage(new ChatComponentText(replaceMeta((String) zeilenobject, page, count)));
    }
    int currentPage = 0;
    int lineOnCurentPage = 0;
    int doneLines = 0;
    for (int i = 0; i < content.size(); i++, lineOnCurentPage++) {
        if (all) {
            sender.addChatMessage(new ChatComponentText(content.get(i).content));
        } else {
            int I;
            for (I = i; I < (content.size() - 1) && content.get(I + 1).connected; I++) {
                ;
            }
            int needed = I - i;
            if (lineOnCurentPage + needed > count - 1) {
                currentPage++;
                lineOnCurentPage = 0;
            }
            if (page == currentPage + 1) {
                sender.addChatMessage(new ChatComponentText(content.get(i).content));
                doneLines = lineOnCurentPage;
            }
        }
    }
    if (!all) {
        clearscreen(sender, row - 2 - header.size() - doneLines - linesub);
    }
    if (all && count > content.size()) {
        clearscreen(sender, count - content.size());
    }
    if (!flag) {
        printLastLine(sender);
    }
    if (sender instanceof EntityPlayer) {
        MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), (EntityPlayer) sender);
    }
}
Also used : OpenChatGui(logisticspipes.network.packets.gui.OpenChatGui) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 18 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.

the class MorePageDisplay method handleChat.

public boolean handleChat(String input, ICommandSender sender) {
    if (terminated) {
        return false;
    }
    if (input.equalsIgnoreCase("exit") || input.equalsIgnoreCase("quit") || input.equalsIgnoreCase("q") || input.equalsIgnoreCase("e")) {
        terminated = true;
        sender.addChatMessage(new ChatComponentText("%LPCLEARCHAT%"));
        for (Object zeilenobject : header.toArray()) {
            if (!(zeilenobject instanceof String)) {
                continue;
            }
            sender.addChatMessage(new ChatComponentText(replaceMeta((String) zeilenobject, 0, -1)));
        }
        clearscreen(sender, 19 - header.size());
        sender.addChatMessage(new ChatComponentText(ChatColor.AQUA + "Pageview: " + ChatColor.RED + "Exit."));
        sender.addChatMessage(new ChatComponentText("%LPRESTORESENDMESSAGE%"));
    } else if (input.equalsIgnoreCase("next") || input.equalsIgnoreCase("nex") || input.equalsIgnoreCase("n")) {
        if (currentpage > (currentpagecount - 1)) {
            display(sender, 0);
        } else {
            currentpage++;
            display(sender, currentpage);
        }
        if (sender instanceof EntityPlayer) {
            MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), (EntityPlayer) sender);
        }
    } else if (input.equalsIgnoreCase("previous") || input.equalsIgnoreCase("prev") || input.equalsIgnoreCase("pre") || input.equalsIgnoreCase("p")) {
        if (currentpage < 2) {
            display(sender, currentpagecount);
        } else {
            currentpage--;
            display(sender, currentpage);
        }
    } else if (MorePageDisplay.isNumber(input)) {
        if (MorePageDisplay.toNumber(input) <= currentpagecount && MorePageDisplay.toNumber(input) > 0) {
            display(sender, MorePageDisplay.toNumber(input));
        } else {
            display(sender, currentpage, true);
            sender.addChatMessage(new ChatComponentText(ChatColor.AQUA + "Pageview:" + ChatColor.RED + " Not a valid number."));
        }
    } else if (input.equalsIgnoreCase("reprint")) {
        display(sender, currentpage);
    } else if (input.equalsIgnoreCase("all")) {
        display(sender, currentpage, false, true, 0);
    } else if (input.startsWith("save ")) {
        sender.addChatMessage(new ChatComponentText("%LPADDTOSENDMESSAGE%" + input.substring(5)));
        display(sender, currentpage, true, false, 1);
        sender.addChatMessage(new ChatComponentText(ChatColor.AQUA + "Added '" + ChatColor.YELLOW + input.substring(5) + ChatColor.AQUA + "' to your chat history."));
        printLastLine(sender, false);
        if (sender instanceof EntityPlayer) {
            MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), (EntityPlayer) sender);
        }
    } else if (input.equals("save")) {
        display(sender, currentpage, true, false, 2);
        sender.addChatMessage(new ChatComponentText(ChatColor.AQUA + "Add an command after the '" + ChatColor.YELLOW + "save " + ChatColor.AQUA + "' and it will be added to your chat history."));
        printLastLine(sender, false);
        if (sender instanceof EntityPlayer) {
            MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), (EntityPlayer) sender);
        }
    } else {
        //display(sender,currentpage,true);
        printLastLine(sender, true);
        if (sender instanceof EntityPlayer) {
            MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OpenChatGui.class), (EntityPlayer) sender);
        }
    }
    return true;
}
Also used : OpenChatGui(logisticspipes.network.packets.gui.OpenChatGui) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 19 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.

the class BypassCommand method executeCommand.

@Override
public void executeCommand(ICommandSender sender, String[] args) {
    if (!LogisticsSecurityTileEntity.byPassed.contains((EntityPlayer) sender)) {
        LogisticsSecurityTileEntity.byPassed.add((EntityPlayer) sender);
        sender.addChatMessage(new ChatComponentText("Enabled"));
    } else {
        LogisticsSecurityTileEntity.byPassed.remove((EntityPlayer) sender);
        sender.addChatMessage(new ChatComponentText("Disabled"));
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 20 with EntityPlayer

use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.

the class HandCommand method executeCommand.

@Override
public void executeCommand(ICommandSender sender, String[] args) {
    EntityPlayer player = (EntityPlayer) sender;
    ItemStack item = player.inventory.mainInventory[player.inventory.currentItem];
    if (item != null) {
        DebugGuiController.instance().startWatchingOf(item, player);
        sender.addChatMessage(new ChatComponentText("Starting HandDebuging"));
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)524 ItemStack (net.minecraft.item.ItemStack)141 EntityLivingBase (net.minecraft.entity.EntityLivingBase)95 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)68 Entity (net.minecraft.entity.Entity)64 BlockPos (net.minecraft.util.math.BlockPos)53 World (net.minecraft.world.World)50 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)42 TileEntity (net.minecraft.tileentity.TileEntity)36 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)34 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)34 ArrayList (java.util.ArrayList)33 EntityItem (net.minecraft.entity.item.EntityItem)31 PotionEffect (net.minecraft.potion.PotionEffect)28 Block (net.minecraft.block.Block)25 IBlockState (net.minecraft.block.state.IBlockState)24 List (java.util.List)23 TextComponentString (net.minecraft.util.text.TextComponentString)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)20 WrongUsageException (net.minecraft.command.WrongUsageException)19