Search in sources :

Example 56 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.

the class SubCommandOrb method processSubCommand.

@Override
public void processSubCommand(ICommandSender commandSender, String[] args) {
    super.processSubCommand(commandSender, args);
    if (args.length > 0) {
        if (args[0].equalsIgnoreCase("help"))
            return;
        String givenName = commandSender.getCommandSenderName();
        if (args.length > 1)
            givenName = args[1];
        boolean displayHelp = isBounded(0, 2, args.length);
        try {
            switch(ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH))) {
                case SET:
                    {
                        if (displayHelp) {
                            displayHelpString(commandSender, ValidCommands.SET.help);
                            break;
                        }
                        if (args.length == 3) {
                            if (isInteger(args[2])) {
                                int amount = Integer.parseInt(args[2]);
                                SoulNetworkHandler.setMaxOrbToMax(givenName, amount);
                                displaySuccessString(commandSender, "commands.success");
                            } else {
                                displayErrorString(commandSender, "commands.error.arg.invalid");
                            }
                        } else {
                            displayErrorString(commandSender, "commands.error.arg.missing");
                        }
                        break;
                    }
                case GET:
                    {
                        if (displayHelp) {
                            displayHelpString(commandSender, ValidCommands.GET.help);
                            break;
                        }
                        if (args.length > 1)
                            commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("message.orb.currenttier", SoulNetworkHandler.getCurrentMaxOrb(givenName))));
                        break;
                    }
            }
        } catch (IllegalArgumentException e) {
            displayErrorString(commandSender, "commands.error.404");
        }
    }
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Example 57 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.

the class ItemAttunedCrystal method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    if (world.isRemote) {
        return itemStack;
    }
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
    if (movingobjectposition == null) {
        if (player.isSneaking()) {
            this.setHasSavedCoordinates(itemStack, false);
            player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.clearing"));
        }
        return itemStack;
    } else {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            int x = movingobjectposition.blockX;
            int y = movingobjectposition.blockY;
            int z = movingobjectposition.blockZ;
            TileEntity tile = world.getTileEntity(x, y, z);
            if (!(tile instanceof IReagentHandler)) {
                return itemStack;
            }
            IReagentHandler relay = (IReagentHandler) tile;
            if (player.isSneaking()) {
                ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.UNKNOWN);
                if (infos != null) {
                    List<Reagent> reagentList = new LinkedList();
                    for (ReagentContainerInfo info : infos) {
                        if (info != null) {
                            ReagentStack reagentStack = info.reagent;
                            if (reagentStack != null) {
                                Reagent reagent = reagentStack.reagent;
                                if (reagent != null) {
                                    reagentList.add(reagent);
                                }
                            }
                        }
                    }
                    Reagent pastReagent = this.getReagent(itemStack);
                    if (reagentList.size() <= 0) {
                        return itemStack;
                    }
                    int reagentLocation;
                    reagentLocation = reagentList.indexOf(pastReagent);
                    if (reagentLocation == -1 || reagentLocation + 1 >= reagentList.size()) {
                        this.setReagentWithNotification(itemStack, reagentList.get(0), player);
                    } else {
                        this.setReagentWithNotification(itemStack, reagentList.get(reagentLocation + 1), player);
                    }
                }
            } else {
                if (this.getHasSavedCoordinates(itemStack)) {
                    Int3 coords = this.getCoordinates(itemStack);
                    int dimension = this.getDimension(itemStack);
                    if (coords == null) {
                        return itemStack;
                    }
                    if (dimension != world.provider.dimensionId || Math.abs(coords.xCoord - x) > maxDistance || Math.abs(coords.yCoord - y) > maxDistance || Math.abs(coords.zCoord - z) > maxDistance) {
                        player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.toofar"));
                        return itemStack;
                    }
                    TileEntity pastTile = world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
                    if (!(pastTile instanceof TEReagentConduit)) {
                        player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.cannotfind"));
                        return itemStack;
                    }
                    Reagent reagent = this.getReagent(itemStack);
                    if (reagent == null) {
                        return itemStack;
                    }
                    TEReagentConduit pastRelay = (TEReagentConduit) pastTile;
                    if (player.isSneaking()) {
                        pastRelay.removeReagentDestinationViaActual(reagent, x, y, z);
                    } else {
                        if (pastRelay.addReagentDestinationViaActual(reagent, x, y, z)) {
                            player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.attunedcrystal.linked") + " " + reagent.name));
                        } else {
                            player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.noconnections"));
                        }
                    }
                    world.markBlockForUpdate(coords.xCoord, coords.yCoord, coords.zCoord);
                } else {
                    int dimension = world.provider.dimensionId;
                    this.setDimension(itemStack, dimension);
                    this.setCoordinates(itemStack, new Int3(x, y, z));
                    player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.linking"));
                }
            }
        }
    }
    return itemStack;
}
Also used : Int3(WayofTime.alchemicalWizardry.api.Int3) LinkedList(java.util.LinkedList) TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ChatComponentText(net.minecraft.util.ChatComponentText) TEReagentConduit(WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit)

Example 58 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.

the class ItemTankSegmenter method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    if (world.isRemote) {
        return itemStack;
    }
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
    if (movingobjectposition == null) {
        return itemStack;
    } else {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            int x = movingobjectposition.blockX;
            int y = movingobjectposition.blockY;
            int z = movingobjectposition.blockZ;
            TileEntity tile = world.getTileEntity(x, y, z);
            if (!(tile instanceof ISegmentedReagentHandler)) {
                return itemStack;
            }
            ISegmentedReagentHandler reagentHandler = (ISegmentedReagentHandler) tile;
            if (player.isSneaking()) {
                ReagentContainerInfo[] infos = reagentHandler.getContainerInfo(ForgeDirection.UNKNOWN);
                if (infos != null) {
                    List<Reagent> reagentList = new LinkedList();
                    for (ReagentContainerInfo info : infos) {
                        if (info != null) {
                            ReagentStack reagentStack = info.reagent;
                            if (reagentStack != null) {
                                Reagent reagent = reagentStack.reagent;
                                if (reagent != null) {
                                    reagentList.add(reagent);
                                }
                            }
                        }
                    }
                    Reagent pastReagent = this.getReagent(itemStack);
                    boolean goForNext = false;
                    boolean hasFound = false;
                    for (Reagent reagent : reagentList) {
                        if (goForNext) {
                            goForNext = false;
                            break;
                        }
                        if (reagent == pastReagent) {
                            goForNext = true;
                            hasFound = true;
                        }
                    }
                    if (hasFound) {
                        if (goForNext) {
                            this.setReagentWithNotification(itemStack, reagentList.get(0), player);
                        }
                    } else {
                        if (reagentList.size() >= 1) {
                            this.setReagentWithNotification(itemStack, reagentList.get(0), player);
                        }
                    }
                }
            } else {
                Reagent reagent = this.getReagent(itemStack);
                if (reagent == null) {
                    // TODO: Send message that "All are wiped"
                    reagentHandler.getAttunedTankMap().clear();
                    return itemStack;
                }
                int totalTankSize = reagentHandler.getNumberOfTanks();
                int numberAssigned = reagentHandler.getTanksTunedToReagent(reagent) + 1;
                if (numberAssigned > totalTankSize) {
                    numberAssigned = 0;
                }
                player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.tanksegmenter.nowhas") + " " + numberAssigned + " " + StatCollector.translateToLocal("message.tanksegmenter.tankssetto") + " " + reagent.name));
                reagentHandler.setTanksTunedToReagent(reagent, numberAssigned);
            }
        } else if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.MISS) {
            this.setReagent(itemStack, null);
        }
    }
    return itemStack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ChatComponentText(net.minecraft.util.ChatComponentText) LinkedList(java.util.LinkedList)

Example 59 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project BloodMagic by WayofTime.

the class RoutingFocus 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) {
        return false;
    }
    TileEntity tile = world.getTileEntity(x, y, z);
    if (tile instanceof IInventory) {
        if (player.isSneaking()) {
            if (this instanceof ILimitedRoutingFocus) {
                int pastAmount = ((ILimitedRoutingFocus) this).getRoutingFocusLimit(stack);
                int amount = SpellHelper.getNumberOfItemsInInventory((IInventory) tile, ForgeDirection.getOrientation(side));
                if (amount != pastAmount) {
                    ((ILimitedRoutingFocus) this).setRoutingFocusLimit(stack, amount);
                    player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.routerfocus.limit") + amount));
                }
            }
        }
        this.setCoordinates(stack, x, y, z);
        this.setSetDirection(stack, ForgeDirection.getOrientation(side));
        return true;
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 60 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project TecTech by Technus.

the class GiveEM method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) {
    if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) {
        if (args.length < 3) {
            sender.addChatMessage(new ChatComponentText(getCommandUsage(sender)));
        } else {
            TecTech.Logger.info("Spawninig EM for " + ((EntityPlayerMP) sender).getDisplayName() + " - " + Arrays.toString(args));
            ArrayList<String> list = new ArrayList<>();
            list.addAll(Arrays.asList(args));
            String energy = list.remove(0);
            cElementalDefinitionStack def = getDefinitionStack(list);
            cElementalInstanceStack instanceStack = new cElementalInstanceStack(def, 1, 0, Long.parseLong(energy));
            sender.addChatMessage(new ChatComponentText(instanceStack.definition.getSymbol() + " - " + instanceStack.definition.getName()));
            cElementalInstanceStackMap instanceMap = new cElementalInstanceStackMap(instanceStack);
            ItemStack itemStack = new ItemStack(DebugElementalInstanceContainer_EM.INSTANCE);
            NBTTagCompound contents = new NBTTagCompound();
            contents.setTag("info", instanceMap.getInfoNBT());
            contents.setTag("content", instanceMap.toNBT());
            itemStack.setTagCompound(contents);
            ((EntityPlayerMP) sender).inventory.addItemStackToInventory(itemStack);
        }
    }
}
Also used : com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap(com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap) com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack(com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack) com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack(com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)383 IChatComponent (net.minecraft.util.IChatComponent)55 EntityPlayer (net.minecraft.entity.player.EntityPlayer)43 ChatStyle (net.minecraft.util.ChatStyle)39 ItemStack (net.minecraft.item.ItemStack)36 ClickEvent (net.minecraft.event.ClickEvent)31 World (net.minecraft.world.World)28 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)26 TileEntity (net.minecraft.tileentity.TileEntity)25 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)25 HoverEvent (net.minecraft.event.HoverEvent)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 ArrayList (java.util.ArrayList)17 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)16 Block (net.minecraft.block.Block)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)14 Entity (net.minecraft.entity.Entity)14 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)13 File (java.io.File)12