use of v1_8_9.net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class TileLauncherScreen method receiveRadioWave.
@Override
public void receiveRadioWave(float hz, IRadioWaveSender sender, String messageHeader, Object[] data) {
//Floor frequency as we do not care about sub ranges
int frequency = (int) Math.floor(hz);
//Only tier 3 (2 for tier value) can be remotely fired
if (getTier() == 2 && frequency == getFrequency() && laucherBase != null) {
//Laser detonator signal
if (messageHeader.equals("activateLauncherWithTarget")) {
Pos pos = (Pos) data[0];
if (toPos().distance(pos) < this.laucherBase.getRange()) {
setTarget(pos);
launch();
((FakeRadioSender) sender).player.addChatComponentMessage(new ChatComponentText("Firing missile at " + pos));
}
} else //Remote detonator signal
if (messageHeader.equals("activateLauncher")) {
((FakeRadioSender) sender).player.addChatComponentMessage(new ChatComponentText("Firing missile at " + getTarget()));
launch();
}
}
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class TileLauncherScreen method onPlayerActivated.
@Override
public boolean onPlayerActivated(EntityPlayer player, int side, Pos hit) {
if (isServer()) {
boolean notNull = player.getHeldItem() != null;
if (notNull && player.getHeldItem().getItem() == Items.redstone) {
if (canLaunch()) {
launch();
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.failedToFire")));
String translation = LanguageUtility.getLocal("chat.launcher.status");
translation = translation.replace("%1", getStatus());
player.addChatComponentMessage(new ChatComponentText(translation));
}
} else if (notNull && player.getHeldItem().getItem() instanceof ItemRemoteDetonator) {
((ItemRemoteDetonator) player.getHeldItem().getItem()).setBroadCastHz(player.getHeldItem(), getFrequency());
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolFrequencySet").replace("%1", "" + getFrequency())));
} else if (notNull && player.getHeldItem().getItem() instanceof IWorldPosItem) {
IWorldPosition location = ((IWorldPosItem) player.getHeldItem().getItem()).getLocation(player.getHeldItem());
if (location != null) {
if (location.world() == world()) {
setTarget(new Pos(location.x(), location.y(), location.z()));
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolTargetSet")));
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.toolWorldNotMatch")));
}
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("chat.launcher.noTargetInTool")));
}
} else {
player.openGui(ICBMClassic.INSTANCE, 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
return true;
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project ICBM-Classic by BuiltBrokenModding.
the class CommandICBM method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
try {
EntityPlayer entityPlayer = (EntityPlayer) sender;
int dimension = entityPlayer.worldObj.provider.dimensionId;
if (args == null || args.length == 0 || args[0].equalsIgnoreCase("help")) {
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc help"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc lag <radius>"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc remove <All/Missile/Explosion> <radius>"));
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc emp <radius>"));
return;
} else if (args.length >= 2 && args[0].equalsIgnoreCase("lag")) {
int radius = parseInt(sender, args[1]);
if (radius > 0) {
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(entityPlayer.posX - radius, entityPlayer.posY - radius, entityPlayer.posZ - radius, entityPlayer.posX + radius, entityPlayer.posY + radius, entityPlayer.posZ + radius);
List<Entity> entitiesNearby = entityPlayer.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesNearby) {
if (entity instanceof EntityFlyingBlock) {
((EntityFlyingBlock) entity).setBlock();
} else if (entity instanceof EntityMissile) {
entity.setDead();
} else if (entity instanceof EntityExplosion) {
entity.setDead();
}
}
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM lag sources within " + radius + " radius."));
return;
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
} else if (args.length >= 3 && args[0].equalsIgnoreCase("remove")) {
int radius = parseInt(sender, args[2]);
boolean all = args[1].equalsIgnoreCase("all");
boolean missile = args[1].equalsIgnoreCase("missiles");
boolean explosion = args[1].equalsIgnoreCase("explosion");
String str = "entities";
if (missile) {
str = "missiles";
}
if (explosion) {
str = "explosions";
}
if (radius > 0) {
EntityPlayer player = (EntityPlayer) sender;
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(player.posX - radius, player.posY - radius, player.posZ - radius, player.posX + radius, player.posY + radius, player.posZ + radius);
List<Entity> entitiesNearby = player.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
for (Entity entity : entitiesNearby) {
if ((all || explosion) && entity instanceof EntityFlyingBlock) {
((EntityFlyingBlock) entity).setBlock();
} else if ((all || missile) && entity instanceof EntityMissile) {
entity.setDead();
} else if ((all || explosion) && entity instanceof EntityExplosion) {
entity.setDead();
}
}
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM " + str + " within " + radius + " radius."));
return;
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
} else if (args.length >= 2 && args[0].equalsIgnoreCase("emp")) {
int radius = parseInt(sender, args[1]);
if (radius > 0) {
new BlastEMP(entityPlayer.worldObj, null, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, radius).setEffectBlocks().setEffectEntities().doExplode();
switch(entityPlayer.worldObj.rand.nextInt(20)) {
case 0:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Did you pay the power bill?"));
return;
case 1:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("See them power their toys now!"));
return;
case 2:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Hey who turned the lights out."));
return;
case 3:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Ha! I run on steam power!"));
return;
case 4:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("The power of lighting at my finger tips!"));
return;
default:
((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Zap!"));
return;
}
} else {
throw new WrongUsageException("Radius needs to be higher than zero");
}
}
} catch (Exception e) {
}
throw new WrongUsageException(this.getCommandUsage(sender));
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project SecurityCraft by Geforce132.
the class SCEventHandler method onPlayerLoggedIn.
@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
String tipKey = getRandomTip();
IChatComponent chatcomponenttext;
if (tipsWithLink.containsKey(tipKey.split("\\.")[2]))
chatcomponenttext = new ChatComponentText("[" + EnumChatFormatting.GOLD + "SecurityCraft" + EnumChatFormatting.WHITE + "] " + StatCollector.translateToLocal("messages.thanks").replace("#", SecurityCraft.getVersion()) + " " + StatCollector.translateToLocal("messages.tip") + " " + StatCollector.translateToLocal(tipKey) + " ").appendSibling(ForgeHooks.newChatWithLinks(tipsWithLink.get(tipKey.split("\\.")[2])));
else
chatcomponenttext = new ChatComponentText("[" + EnumChatFormatting.GOLD + "SecurityCraft" + EnumChatFormatting.WHITE + "] " + StatCollector.translateToLocal("messages.thanks").replace("#", SecurityCraft.getVersion()) + " " + StatCollector.translateToLocal("messages.tip") + " " + StatCollector.translateToLocal(tipKey));
if (SecurityCraft.config.sayThanksMessage)
event.player.addChatComponentMessage(chatcomponenttext);
}
use of v1_8_9.net.minecraft.util.ChatComponentText in project Armourers-Workshop by RiskyKen.
the class ModClientFMLEventHandler method onPlayerTickEndEvent.
public void onPlayerTickEndEvent() {
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
if (!shownUpdateInfo && UpdateCheck.updateFound) {
shownUpdateInfo = true;
ChatComponentText updateMessage = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateAvailable", UpdateCheck.remoteModVersion) + " ");
ChatComponentText updateURL = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateDownload"));
updateURL.getChatStyle().setUnderlined(true);
updateURL.getChatStyle().setColor(EnumChatFormatting.BLUE);
updateURL.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateDownloadRollover"))));
updateURL.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, LibModInfo.DOWNLOAD_URL));
updateMessage.appendSibling(updateURL);
player.addChatMessage(updateMessage);
}
if (!showmDevWarning && LibModInfo.DEVELOPMENT_VERSION) {
ChatComponentText devWarning = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:devWarning"));
devWarning.getChatStyle().setColor(EnumChatFormatting.RED);
player.addChatMessage(devWarning);
showmDevWarning = true;
}
}
Aggregations