Search in sources :

Example 96 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class ItemDevData method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        Block block = world.getBlock(x, y, z);
        int meta = world.getBlockMetadata(x, y, z);
        TileEntity tile = world.getTileEntity(x, y, z);
        if (stack.getItemDamage() == 0) {
            player.addChatComponentMessage(new ChatComponentText("Block: " + block));
            player.addChatComponentMessage(new ChatComponentText(" Extended: " + ExtendedBlockDataManager.SERVER.getValue(world, x, y, z)));
            player.addChatComponentMessage(new ChatComponentText(" Meta: " + meta));
            player.addChatComponentMessage(new ChatComponentText(" Class: " + block.getClass()));
            if (tile != null) {
                player.addChatComponentMessage(new ChatComponentText(" Tile: " + tile));
                player.addChatComponentMessage(new ChatComponentText("  Class: " + tile.getClass()));
            }
        } else //Super tile data mode
        if (stack.getItemDamage() == 1) {
            try {
                if (tile != null) {
                    int i = 0;
                    for (Field field : ReflectionUtility.getAllFields(tile.getClass())) {
                        if (!Modifier.isStatic(field.getModifiers())) {
                            field.setAccessible(true);
                            Object obj = field.get(tile);
                            if (!(obj instanceof Collection)) {
                                player.addChatComponentMessage(new ChatComponentText("Field[" + (i++) + ", " + field.getName() + "] = " + obj));
                                if (i % 5 == 0) {
                                    player.addChatComponentMessage(new ChatComponentText(""));
                                }
                            }
                        }
                    }
                } else {
                    player.addChatComponentMessage(new ChatComponentText("No tile to pull data from"));
                }
            } catch (Exception e) {
                player.addChatComponentMessage(new ChatComponentText("Failed to reflect data! see log for details! " + e.getMessage()));
                e.printStackTrace();
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Field(java.lang.reflect.Field) Block(net.minecraft.block.Block) Collection(java.util.Collection) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 97 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class ItemDevData method hitEntity.

@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase hit, EntityLivingBase player) {
    if (hit != null && player != null) {
        if (player instanceof EntityPlayer && !player.worldObj.isRemote) {
            ((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("Entity: " + hit));
            ((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("ID: " + hit.getEntityId()));
            ((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("Name: " + hit.getCommandSenderName()));
            ((EntityPlayer) player).addChatComponentMessage(new ChatComponentText("Class: " + hit.getClass()));
        }
        return true;
    }
    return false;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 98 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class TileInfInv method onPlayerRightClick.

@Override
protected boolean onPlayerRightClick(EntityPlayer player, int side, Pos hit) {
    if (isServer()) {
        if (player.getHeldItem() != null) {
            if (player.capabilities.isCreativeMode) {
                if (player.isSneaking() && player.getHeldItem().getItem() == Items.stick) {
                    slotStack = null;
                    player.addChatComponentMessage(new ChatComponentText("SlotStack = " + slotStack));
                } else {
                    setInventorySlotContents(0, player.getHeldItem());
                }
            }
        } else {
            player.addChatComponentMessage(new ChatComponentText("SlotStack = " + slotStack));
        }
    }
    return true;
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Example 99 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandDebugItem method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args != null && args.length > 0 && !"help".equalsIgnoreCase(args[0])) {
        if (args[0].equals("dump") || args[0].equals("dumpsubs")) {
            sender.addChatMessage(new ChatComponentText("See console for data"));
            FMLControlledNamespacedRegistry<Item> registry = (FMLControlledNamespacedRegistry<Item>) Item.itemRegistry;
            Set set = registry.getKeys();
            for (Object obj : set) {
                String name = (String) obj;
                Item item = registry.getObject(name);
                System.out.println("" + name + "  " + item);
                if (item != null) {
                    if (args[0].equals("dumpsubs")) {
                        List list = new ArrayList();
                        item.getSubItems(item, item.getCreativeTab(), list);
                        for (Object o : list) {
                            System.out.println("\t" + o);
                            if (o instanceof ItemStack) {
                                ItemStack stack = (ItemStack) o;
                                System.out.println("\t\tName: " + stack.getUnlocalizedName());
                                int[] oreIDs = OreDictionary.getOreIDs(stack);
                                if (oreIDs != null && oreIDs.length > 0) {
                                    for (int i : oreIDs) {
                                        String oreName = OreDictionary.getOreName(i);
                                        System.out.println("\t\t" + oreName);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return true;
        }
    } else {
        return handleHelp(sender, args);
    }
    return false;
}
Also used : FMLControlledNamespacedRegistry(cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry) Item(net.minecraft.item.Item) Set(java.util.Set) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 100 with ChatComponentText

use of net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class GSCUser method handle.

@Override
public boolean handle(ICommandSender sender, AccessGroup group, String user, String[] args) {
    if (!remove) {
        if (group.addMember(user)) {
            sender.addChatMessage(new ChatComponentText("User added to group"));
        } else if (group.getMember(user) != null) {
            sender.addChatMessage(new ChatComponentText("Error: User already added"));
        } else {
            sender.addChatMessage(new ChatComponentText("Error adding user to group"));
        }
    } else {
        if (group.getMember(user) != null) {
            group.removeMember(user);
            sender.addChatMessage(new ChatComponentText("User removed from group"));
        } else {
            sender.addChatMessage(new ChatComponentText("Group does not contain that user"));
        }
    }
    return true;
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)108 EntityPlayer (net.minecraft.entity.player.EntityPlayer)19 ItemStack (net.minecraft.item.ItemStack)16 TileEntity (net.minecraft.tileentity.TileEntity)9 Entity (net.minecraft.entity.Entity)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)7 ArrayList (java.util.ArrayList)7 Block (net.minecraft.block.Block)6 AMVector3 (am2.api.math.AMVector3)4 AccessGroup (com.builtbroken.mc.framework.access.AccessGroup)4 Pos (com.builtbroken.mc.imp.transform.vector.Pos)4 OpenChatGui (logisticspipes.network.packets.gui.OpenChatGui)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ChatStyle (net.minecraft.util.ChatStyle)4 IPowerNode (am2.api.power.IPowerNode)3 IItemActivationListener (com.builtbroken.mc.api.items.listeners.IItemActivationListener)3 IItemEventListener (com.builtbroken.mc.api.items.listeners.IItemEventListener)3 AbstractCommand (com.builtbroken.mc.core.commands.prefab.AbstractCommand)3 ItemListenerIterator (com.builtbroken.mc.prefab.items.listeners.ItemListenerIterator)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3