use of net.minecraft.util.text.TextComponentString in project RFTools by McJty.
the class StorageTerminalBlock method createServerContainer.
@Override
public Container createServerContainer(EntityPlayer entityPlayer, TileEntity tileEntity) {
if (!entityPlayer.isSneaking()) {
if (tileEntity instanceof StorageTerminalTileEntity) {
StorageTerminalTileEntity terminalTileEntity = (StorageTerminalTileEntity) tileEntity;
ItemStack module = terminalTileEntity.getStackInSlot(StorageTerminalContainer.SLOT_MODULE);
if (!module.isEmpty()) {
int dimension = RFToolsTools.getDimensionFromModule(module);
BlockPos pos = RFToolsTools.getPositionFromModule(module);
WorldServer world = DimensionManager.getWorld(dimension);
if (!RFToolsTools.chunkLoaded(world, pos)) {
entityPlayer.sendStatusMessage(new TextComponentString(TextFormatting.YELLOW + "Storage scanner out of range!"), false);
return null;
}
TileEntity scannerTE = world.getTileEntity(pos);
if (!(scannerTE instanceof StorageScannerTileEntity)) {
entityPlayer.sendStatusMessage(new TextComponentString(TextFormatting.YELLOW + "Storage scanner is missing!"), false);
return null;
}
return new StorageScannerContainer(entityPlayer, (IInventory) scannerTE, terminalTileEntity);
}
}
}
return super.createServerContainer(entityPlayer, tileEntity);
}
use of net.minecraft.util.text.TextComponentString in project RFTools by McJty.
the class StorageTerminalBlock method wrenchUse.
@Override
protected boolean wrenchUse(World world, BlockPos pos, EnumFacing side, EntityPlayer player) {
if (!world.isRemote) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof StorageTerminalTileEntity) {
StorageTerminalTileEntity storageTerminalTileEntity = (StorageTerminalTileEntity) te;
ItemStack module = storageTerminalTileEntity.getStackInSlot(StorageTerminalContainer.SLOT_MODULE);
if (!module.isEmpty()) {
storageTerminalTileEntity.setInventorySlotContents(StorageTerminalContainer.SLOT_MODULE, ItemStack.EMPTY);
storageTerminalTileEntity.markDirtyClient();
if (!player.inventory.addItemStackToInventory(module)) {
player.entityDropItem(module, 1.05f);
}
player.sendStatusMessage(new TextComponentString("Removed module"), false);
}
}
}
return true;
}
use of net.minecraft.util.text.TextComponentString in project Wurst-MC-1.12 by Wurst-Imperium.
the class TemplateToolMod method saveFile.
private void saveFile() {
step = Step.values()[step.ordinal() + 1];
new Thread(() -> {
JsonObject json = new JsonObject();
// get facings
EnumFacing front = EnumFacing.getHorizontal(4 - WMinecraft.getPlayer().getHorizontalFacing().getHorizontalIndex());
EnumFacing left = front.rotateYCCW();
// add sorted blocks
JsonArray jsonBlocks = new JsonArray();
for (BlockPos pos : template.sortedBlocks) {
// translate
pos = pos.subtract(Step.FIRST_BLOCK.pos);
// rotate
pos = new BlockPos(0, pos.getY(), 0).offset(front, pos.getZ()).offset(left, pos.getX());
// add to json
jsonBlocks.add(JsonUtils.gson.toJsonTree(new int[] { pos.getX(), pos.getY(), pos.getZ() }, int[].class));
}
json.add("blocks", jsonBlocks);
try (PrintWriter save = new PrintWriter(new FileWriter(file))) {
// save file
save.print(JsonUtils.prettyGson.toJson(json));
// show success message
TextComponentString message = new TextComponentString("Saved template as ");
TextComponentString link = new TextComponentString(file.getName());
ClickEvent event = new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getParentFile().getAbsolutePath());
link.getStyle().setUnderlined(true).setClickEvent(event);
message.appendSibling(link);
ChatUtils.component(message);
} catch (IOException e) {
e.printStackTrace();
// show error message
ChatUtils.error("File could not be saved.");
}
// update AutoBuild
wurst.mods.autoBuildMod.loadTemplates();
// disable TemplateTool
setEnabled(false);
}, "TemplateTool").start();
}
use of net.minecraft.util.text.TextComponentString in project Wurst-MC-1.12 by Wurst-Imperium.
the class Updater method checkForUpdate.
public void checkForUpdate() {
Version currentVersion = new Version(WurstClient.VERSION);
Version latestVersion = null;
try {
JsonArray json = fetchJson("https://api.github.com/repos/Wurst-Imperium/Wurst-MCX2/releases").getAsJsonArray();
for (JsonElement element : json) {
JsonObject release = element.getAsJsonObject();
if (!currentVersion.isPreRelease() && release.get("prerelease").getAsBoolean())
continue;
if (!containsCompatibleAsset(release.get("assets").getAsJsonArray()))
continue;
latestVersionString = release.get("tag_name").getAsString().substring(1);
latestVersion = new Version(latestVersionString);
break;
}
if (latestVersion == null)
throw new NullPointerException("Latest version is missing!");
System.out.println("[Updater] Current version: " + currentVersion);
System.out.println("[Updater] Latest version: " + latestVersion);
outdated = currentVersion.shouldUpdateTo(latestVersion);
} catch (Exception e) {
System.err.println("[Updater] An error occurred!");
e.printStackTrace();
}
if (latestVersion == null || latestVersion.isInvalid()) {
component = new TextComponentString("An error occurred while checking for updates." + " Click \u00a7nhere\u00a7r to check manually.");
ClickEvent event = new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.wurstclient.net/download/");
component.getStyle().setClickEvent(event);
WurstClient.INSTANCE.events.add(UpdateListener.class, this);
return;
}
if (!latestVersion.isHigherThan(WurstClient.VERSION))
return;
component = new TextComponentString("Wurst " + latestVersion + " is now available." + " Click \u00a7nhere\u00a7r to download the update.");
ClickEvent event = new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.wurstclient.net/download/");
component.getStyle().setClickEvent(event);
WurstClient.INSTANCE.events.add(UpdateListener.class, this);
}
use of net.minecraft.util.text.TextComponentString in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class InputHandler method commandEnter.
public void commandEnter() {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
World world = mc.world;
PlayerStatsCapability.IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
loadLists();
switch(GuiCommandMenu.selected) {
case GuiCommandMenu.ATTACK:
player.swingArm(EnumHand.MAIN_HAND);
if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
// Submenu of the portals
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (!this.portalCommands.isEmpty() && !STATS.getRecharge()) {
GuiCommandMenu.submenu = GuiCommandMenu.SUB_PORTALS;
GuiCommandMenu.portalSelected = 0;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
} else {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
}
return;
}
}
if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Wisdom)) {
PacketDispatcher.sendToServer(new MagicWisdomShot());
}
break;
case GuiCommandMenu.MAGIC:
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (!STATS.getRecharge() && (!this.magicCommands.isEmpty() && !DRIVE.getActiveDriveName().equals(Strings.Form_Valor))) {
GuiCommandMenu.magicselected = 0;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAGIC;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
return;
} else {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
break;
case GuiCommandMenu.ITEMS:
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (!this.itemsCommands.isEmpty()) {
GuiCommandMenu.submenu = GuiCommandMenu.SUB_ITEMS;
GuiCommandMenu.potionselected = 0;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
} else {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
}
return;
}
break;
case GuiCommandMenu.DRIVE:
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
// TODO Use Limit
player.sendMessage(new TextComponentString("Limits are not available yet"));
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
} else {
if (DRIVE.getInDrive()) {
// Revert
if (DRIVE.getActiveDriveName().equals(Strings.Form_Anti) && !player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
player.sendMessage(new TextComponentTranslation("Cannot revert while in Anti form"));
} else {
PacketDispatcher.sendToServer(new DriveFormPacket(DRIVE.getActiveDriveName(), true));
if (DriveFormRegistry.isDriveFormRegistered(DRIVE.getActiveDriveName()))
DriveFormRegistry.get(DRIVE.getActiveDriveName()).endDrive(player);
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
} else if (this.driveCommands.isEmpty() || DRIVE.getDP() <= 0) {
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
} else {
GuiCommandMenu.driveselected = 0;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_DRIVE;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
return;
}
}
}
break;
}
// Portal Submenu
if (GuiCommandMenu.selected == GuiCommandMenu.ATTACK && GuiCommandMenu.submenu == GuiCommandMenu.SUB_PORTALS) {
if (this.portalCommands.isEmpty()) {
} else {
// ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
if (!player.getCapability(ModCapabilities.PLAYER_STATS, null).getRecharge()) {
PortalCoords coords = this.portalCommands.get((byte) GuiCommandMenu.portalSelected);
if (coords.getX() != 0 && coords.getY() != 0 && coords.getZ() != 0) {
// ValidPortal
summonPortal(player, coords);
} else {
player.sendMessage(new TextComponentString(TextFormatting.RED + "You don't have any portal destination"));
}
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
}
// Magic Submenu
if (GuiCommandMenu.selected == GuiCommandMenu.MAGIC && GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAGIC) {
if (this.magicCommands.isEmpty()) {
} else if (!STATS.getRecharge() || Constants.getCost((String) this.magicCommands.get(GuiCommandMenu.magicselected)) == -1 && STATS.getMP() > 0) {
Magic.getMagic(player, world, (String) this.magicCommands.get(GuiCommandMenu.magicselected));
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
if (GuiCommandMenu.selected == GuiCommandMenu.ITEMS && GuiCommandMenu.submenu == GuiCommandMenu.SUB_ITEMS) {
if (this.itemsCommands.isEmpty()) {
} else if (!this.itemsCommands.isEmpty()) {
ItemKKPotion.getItem(player, world, (String) this.itemsCommands.get(GuiCommandMenu.potionselected), GuiCommandMenu.potionselected);
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
if (GuiCommandMenu.selected == GuiCommandMenu.DRIVE && GuiCommandMenu.submenu == GuiCommandMenu.SUB_DRIVE) {
if (this.driveCommands.isEmpty()) {
} else if ((DRIVE.getDP() >= Constants.getCost((String) this.driveCommands.get(GuiCommandMenu.driveselected)))) {
if (this.driveCommands.get(GuiCommandMenu.driveselected).equals(Strings.Form_Final)) {
ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
} else {
if (!antiFormCheck()) {
ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
}
}
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
}
Aggregations