Search in sources :

Example 6 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsObject method processChunkClaims.

/*
	 * Generates the new chunks
	 */
public void processChunkClaims(EntityPlayer player) {
    BlockPos centerInWorld = new BlockPos(wrapper.posX, wrapper.posY, wrapper.posZ);
    SpatialDetector detector = DetectorManager.getDetectorFor(detectorID, centerInWorld, worldObj, ValkyrienWarfareMod.maxShipSize + 1, true);
    if (detector.foundSet.size() > ValkyrienWarfareMod.maxShipSize || detector.cleanHouse) {
        if (player != null) {
            player.addChatComponentMessage(new TextComponentString("Ship construction canceled because its exceeding the ship size limit (Raise with /physSettings maxShipSize <number>) ; Or because it's attatched to bedrock)"));
        }
        wrapper.setDead();
        return;
    }
    assembleShip(player, detector, centerInWorld);
}
Also used : MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) BlockPos(net.minecraft.util.math.BlockPos) SpatialDetector(ValkyrienWarfareBase.Relocation.SpatialDetector) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 7 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsObject method changeOwner.

/**
	 * Tries to change the owner of this PhysicsObject.
	 *
	 * @param newOwner
	 * @return
	 */
public EnumChangeOwnerResult changeOwner(EntityPlayer newOwner) {
    if (!ValkyrienWarfareMod.canChangeAirshipCounter(true, newOwner)) {
        return EnumChangeOwnerResult.ERROR_NEWOWNER_NOT_ENOUGH;
    }
    if (newOwner.entityUniqueID.toString().equals(creator)) {
        return EnumChangeOwnerResult.ALREADY_CLAIMED;
    }
    EntityPlayer player = null;
    try {
        player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(UUID.fromString(creator));
    } catch (NullPointerException e) {
        newOwner.addChatMessage(new TextComponentString("That airship doesn't have an owner, you get to have it :D"));
        newOwner.getCapability(ValkyrienWarfareMod.airshipCounter, null).onCreate();
        allowedUsers.clear();
        creator = newOwner.entityUniqueID.toString();
        return EnumChangeOwnerResult.SUCCESS;
    }
    if (player != null) {
        player.getCapability(ValkyrienWarfareMod.airshipCounter, null).onLose();
    } else {
        try {
            File f = new File(DimensionManager.getCurrentSaveRootDirectory(), "playerdata/" + creator + ".dat");
            NBTTagCompound tag = CompressedStreamTools.read(f);
            NBTTagCompound capsTag = tag.getCompoundTag("ForgeCaps");
            capsTag.setInteger("valkyrienwarfare:IAirshipCounter", capsTag.getInteger("valkyrienwarfare:IAirshipCounter") - 1);
            CompressedStreamTools.safeWrite(tag, f);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    newOwner.getCapability(ValkyrienWarfareMod.airshipCounter, null).onCreate();
    allowedUsers.clear();
    creator = newOwner.entityUniqueID.toString();
    return EnumChangeOwnerResult.SUCCESS;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IOException(java.io.IOException) File(java.io.File) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 8 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class AirshipMapCommand method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    String term = args[0];
    if (term.equals("tpto")) {
        String shipName = args[1];
        if (args.length > 2) {
            for (int i = 2; i < args.length; i++) {
                shipName += " " + args[i];
            }
        }
        Entity player = sender.getCommandSenderEntity();
        World world = player.worldObj;
        ShipNameUUIDData data = ShipNameUUIDData.get(world);
        if (data.ShipNameToLongMap.containsKey(shipName)) {
            long shipUUIDMostSig = data.ShipNameToLongMap.get(shipName);
            ShipUUIDToPosData posData = ShipUUIDToPosData.get(world);
            ShipPositionData positionData = posData.getShipPositionData(shipUUIDMostSig);
            double posX = positionData.shipPosition.X;
            double posY = positionData.shipPosition.Y;
            double posZ = positionData.shipPosition.Z;
            if (player instanceof EntityPlayerMP) {
                EntityPlayerMP playerMP = (EntityPlayerMP) player;
                ((EntityPlayerMP) player).connection.setPlayerLocation(posX, posY, posZ, 0, 0);
            }
        }
    }
    if (term.equals("help")) {
        sender.addChatMessage(new TextComponentString("tpto"));
    }
}
Also used : Entity(net.minecraft.entity.Entity) ShipUUIDToPosData(ValkyrienWarfareBase.Interaction.ShipUUIDToPosData) ShipNameUUIDData(ValkyrienWarfareBase.Interaction.ShipNameUUIDData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TextComponentString(net.minecraft.util.text.TextComponentString) ShipPositionData(ValkyrienWarfareBase.Interaction.ShipUUIDToPosData.ShipPositionData) World(net.minecraft.world.World) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 9 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class AirshipSettingsCommand method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (!(sender instanceof EntityPlayer)) {
        sender.addChatMessage(new TextComponentString("You need to be a player to do that!"));
        return;
    }
    if (args.length == 0) {
        sender.addChatMessage(new TextComponentString(TextFormatting.RED + "Usage: " + getCommandUsage(sender)));
        return;
    }
    EntityPlayer p = (EntityPlayer) sender;
    //This method has an @SIDE.CLIENT, and it broke all the commands on servers!
    //		BlockPos pos = p.rayTrace(p.isCreative() ? 5.0 : 4.5, 1).getBlockPos();
    BlockPos pos = rayTraceBothSides(p, p.isCreative() ? 5.0 : 4.5, 1).getBlockPos();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(p.getEntityWorld(), pos);
    if (wrapper == null) {
        sender.addChatMessage(new TextComponentString("You need to be looking at an airship to do that!"));
        return;
    }
    if (p.entityUniqueID.toString().equals(wrapper.wrapping.creator)) {
        if (args[0].equals("transfer")) {
            if (args.length == 1) {
                return;
            }
            if (!args[1].isEmpty()) {
                EntityPlayer target = server.getPlayerList().getPlayerByUsername(args[1]);
                if (target == null) {
                    p.addChatMessage(new TextComponentString("That player is not online!"));
                    return;
                }
                switch(wrapper.wrapping.changeOwner(target)) {
                    case ERROR_IMPOSSIBLE_STATUS:
                        p.addChatMessage(new TextComponentString("An error occured, please report to mod devs"));
                        break;
                    case ERROR_NEWOWNER_NOT_ENOUGH:
                        p.addChatMessage(new TextComponentString("That player doesn't have enough free airship slots!"));
                        break;
                    case SUCCESS:
                        p.addChatMessage(new TextComponentString("Success! " + target.getName() + " is the new owner of this airship!"));
                        break;
                    case ALREADY_CLAIMED:
                        p.addChatMessage(new TextComponentString("Airship already claimed"));
                        break;
                }
                return;
            }
        } else if (args[0].equals("allowPlayer")) {
            if (args.length == 1) {
                StringBuilder result = new StringBuilder("<");
                Iterator<String> iter = wrapper.wrapping.allowedUsers.iterator();
                while (iter.hasNext()) {
                    result.append(iter.next() + (iter.hasNext() ? ", " : ">"));
                }
                p.addChatMessage(new TextComponentString(result.toString()));
                return;
            }
            if (!args[1].isEmpty()) {
                EntityPlayer target = server.getPlayerList().getPlayerByUsername(args[1]);
                if (target == null) {
                    p.addChatMessage(new TextComponentString("That player is not online!"));
                    return;
                }
                if (target.entityUniqueID.toString().equals(wrapper.wrapping.creator)) {
                    p.addChatMessage(new TextComponentString("You can't add yourself to your own airship!"));
                    return;
                }
                wrapper.wrapping.allowedUsers.add(target.entityUniqueID.toString());
                p.addChatMessage(new TextComponentString("Success! " + target.getName() + " can now interact with this airship!"));
                return;
            }
        }
    } else {
        if (wrapper.wrapping.creator == null || wrapper.wrapping.creator.trim().isEmpty()) {
            if (args.length == 1 && args[0].equals("claim")) {
                wrapper.wrapping.creator = p.entityUniqueID.toString();
                p.addChatMessage(new TextComponentString("You've successfully claimed an airship!"));
                return;
            }
        }
        p.addChatMessage(new TextComponentString("You need to be the owner of an airship to change airship settings!"));
    }
    if (args[0].equals("help")) {
        for (String command : completionOptions) {
            sender.addChatMessage(new TextComponentString(command));
        }
    }
    sender.addChatMessage(new TextComponentString(TextFormatting.RED + "Usage: " + getCommandUsage(sender)));
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Iterator(java.util.Iterator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 10 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ValkyrienWarfareHelpCommand method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    sender.addChatMessage(new TextComponentString("All ValkyrienWarfare Commands"));
    for (String command : commands) {
        sender.addChatMessage(new TextComponentString(command));
    }
    sender.addChatMessage(new TextComponentString("To see avaliable subcommands, type /Command help"));
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)343 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 ItemStack (net.minecraft.item.ItemStack)68 BlockPos (net.minecraft.util.math.BlockPos)60 ITextComponent (net.minecraft.util.text.ITextComponent)48 TileEntity (net.minecraft.tileentity.TileEntity)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)35 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)32 Colony (com.minecolonies.coremod.colony.Colony)26 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)26 IBlockState (net.minecraft.block.state.IBlockState)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 Style (net.minecraft.util.text.Style)21 IColony (com.minecolonies.api.colony.IColony)19 ClickEvent (net.minecraft.util.text.event.ClickEvent)19 Entity (net.minecraft.entity.Entity)18 Block (net.minecraft.block.Block)17 World (net.minecraft.world.World)17 ArrayList (java.util.ArrayList)16 ActionResult (net.minecraft.util.ActionResult)13