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);
}
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;
}
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"));
}
}
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)));
}
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"));
}
Aggregations