use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class TileEntityTrackSideReception method cart.
protected static void cart(EntityMinecart cart, TileEntityTrackSideReception reception, EntityPlayer player) {
if (reception == null)
return;
if (cart == null)
return;
World world = reception.worldObj;
ForgeDirection railPos = reception.direction.getRotation(ITrackSide.getAxis());
int x = reception.xCoord + railPos.offsetX, y = reception.yCoord, z = reception.zCoord + railPos.offsetZ;
if (world.getBlock(x, y + 1, z) instanceof BlockRailBase)
y += 1;
double maxV = 0.2;
if (reception.cartType.equals("loco")) {
return;
}
if (reception.cartType.isEmpty() && (cart.motionX * cart.motionX + cart.motionZ * cart.motionZ == 0))
registerCart(reception, cart);
if (player != null) {
if ((cart.motionX * cart.motionX + cart.motionZ * cart.motionZ > 0) && !reception.enable) {
if ((Math.abs(cart.motionX) > maxV / 2) || (Math.abs(cart.motionZ) > maxV / 2)) {
cart.motionX = (Math.signum(cart.motionX) * Dynamics.LocoMotions.calcVelocityDown(Math.abs(cart.motionX), 0.1D, 1.0D, 1.0D, 1.0D, 0.05D, 0.02D));
cart.motionZ = (Math.signum(cart.motionZ) * Dynamics.LocoMotions.calcVelocityDown(Math.abs(cart.motionZ), 0.1D, 1.0D, 1.0D, 1.0D, 0.05D, 0.02D));
} else {
reception.enable = true;
reception.doorCtrl = true;
cart.motionX = 0.0D;
cart.motionZ = 0.0D;
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
if (reception.setDelay == 10) {
player.addChatComponentMessage(new ChatComponentTranslation("info.reception.pause", reception.setDelay));
world.playSoundAtEntity(cart, "nyasamarailway:info.reception.pause", 0.5F, 1.0F);
}
}
} else {
if (reception.delay < reception.setDelay * 20 && reception.enable) {
boolean isEnabled = false;
if (reception.getSender() != null)
isEnabled = reception.senderIsPowered();
if (!isEnabled)
reception.delay += 1;
else {
reception.count += 1;
if (reception.delay + reception.count == reception.setDelay * 15) {
reception.delay = reception.setDelay * 15 - 1;
reception.count += 1;
player.addChatComponentMessage(new ChatComponentTranslation("info.reception.delay"));
world.playSoundAtEntity(cart, "nyasamarailway:info.reception.delay", 0.5F, 1.0F);
}
}
if (reception.delay == reception.setDelay * 15) {
reception.count = 0;
reception.doorCtrl = false;
player.addChatComponentMessage(new ChatComponentTranslation("info.reception.ready"));
world.playSoundAtEntity(cart, "nyasamarailway:info.reception.ready", 0.5F, 1.0F);
}
cart.motionX = 0.0D;
cart.motionZ = 0.0D;
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
} else {
double dir = (reception.direction == ForgeDirection.NORTH || reception.direction == ForgeDirection.EAST) ? 1 : -1;
if (reception.isInvert())
dir = -dir;
if (reception.direction.offsetZ != 0) {
if (cart.motionZ * dir >= 0.0D)
cart.motionZ = -dir * 0.005D;
if (Math.abs(cart.motionZ) < maxV)
cart.motionZ = -dir * Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionZ), 0.1D, 1.0D, 0.1D, 0.02D);
} else if (reception.direction.offsetX != 0) {
if (cart.motionX * dir <= 0.0D)
cart.motionX = dir * 0.005D;
if (Math.abs(cart.motionX) < maxV)
cart.motionX = dir * Dynamics.LocoMotions.calcVelocityUp(Math.abs(cart.motionX), 0.1D, 1.0D, 0.1D, 0.02D);
}
}
}
} else {
cart.motionX = 0.0D;
cart.motionZ = 0.0D;
cart.setPosition(x + 0.5, y + 0.5, z + 0.5);
reception.reset();
}
}
use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.
the class RailMonoMagnetSniffer method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (world.getTileEntity(x, y, z) == null)
return false;
if (world.getTileEntity(x, y, z) instanceof RailSniffer) {
RailSniffer sniffer = (RailSniffer) world.getTileEntity(x, y, z);
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null) {
NBTTagList list = Util.getTagListFromNGT(stack);
if (list == null)
return false;
if (!world.isRemote) {
String code = NSASM.getCodeString(list);
sniffer.nsasmState = RailSniffer.NSASM_IDLE;
sniffer.nsasmCode = code;
player.addChatComponentMessage(new ChatComponentTranslation("info.sniffer.set"));
}
return true;
}
}
return false;
}
use of net.minecraft.util.ChatComponentTranslation in project Hyperium by HyperiumClient.
the class AsyncScreenshotSaver method run.
/**
* Threaded task that creates the image and uploads to Imgur if able to
*/
@Override
public void run() {
// Create the colors and image
processPixelValues(pixelValues, width, height);
// Make an image to be posted
BufferedImage image;
// Create the screenshot file
File screenshot = getTimestampedPNGFileForDirectory(screenshotDir);
// Allow a developer to stop the screenshot process if they want to
Cancellable cancellable = new Cancellable();
// Screenshot is taken, so trigger all ChatTriggers modules using it
TriggerType.SCREENSHOT_TAKEN.triggerAll(screenshot, cancellable);
// Cancel the process if made to cancel
if (cancellable.isCancelled())
return;
try {
// Create the image
if (OpenGlHelper.isFramebufferEnabled()) {
image = new BufferedImage(frameBuffer.framebufferWidth, frameBuffer.framebufferHeight, 1);
int texHeight;
for (int heightSize = texHeight = frameBuffer.framebufferTextureHeight - frameBuffer.framebufferHeight; texHeight < frameBuffer.framebufferTextureHeight; ++texHeight) {
for (int widthSize = 0; widthSize < frameBuffer.framebufferWidth; ++widthSize) {
// Set the image colors
image.setRGB(widthSize, texHeight - heightSize, pixelValues[texHeight * frameBuffer.framebufferTextureWidth + widthSize]);
}
}
} else {
// Fallback if the computer doesnt support Frame buffering
image = new BufferedImage(width, height, 1);
// Set the image colors
image.setRGB(0, 0, width, height, pixelValues, 0, width);
}
// Write the image
ImageIO.write(image, "png", screenshot);
// If the user doesn't want the screenshot to be uploaded, run this
if (!upload) {
IChatComponent chatComponent = new ChatComponentText(ChatColor.RED + "[Hyperium] " + ChatColor.WHITE + "Captured to " + ChatColor.UNDERLINE + screenshot.getName());
chatComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, screenshot.getCanonicalPath()));
Minecraft.getMinecraft().thePlayer.addChatMessage(chatComponent);
} else {
// Otherwise allow the Imgur uploading process to run
new ImgurUploader("649f2fb48e59767", screenshot).run();
}
} catch (Exception e) {
// If an issue is caught, tell the user it couldn't be saved and then give them the error
Hyperium.LOGGER.warn("Couldn't save {} : {}", screenshot, e);
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("screenshot.failure", e.getMessage()));
}
}
use of net.minecraft.util.ChatComponentTranslation in project Tale-of-Kingdoms by Ivasik78.
the class CommandTOK method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) {
if (sender instanceof EntityPlayer) {
if (MinecraftServer.getServer().getConfigurationManager().func_152596_g(((EntityPlayer) sender).getGameProfile())) {
switch(args[0]) {
case "glory":
PlayerProvider.get((EntityPlayer) sender).addGlory(10000);
sender.addChatMessage(new ChatComponentTranslation("command.tok.worthy"));
break;
case "gold":
PlayerProvider.get((EntityPlayer) sender).addGold(10000);
sender.addChatMessage(new ChatComponentText("Gold added!"));
break;
case "res":
ResourcesHandler.INSTANCE.addcobbleResource(10000);
ResourcesHandler.INSTANCE.addwoodResource(10000);
break;
case "help":
sender.addChatMessage(new ChatComponentText("===================================="));
sender.addChatMessage(new ChatComponentText("/tok worthy - 10.000 Worthy"));
sender.addChatMessage(new ChatComponentText("/tok gold - 10.000 Gold coins"));
sender.addChatMessage(new ChatComponentText("===================================="));
break;
}
}
}
}
use of net.minecraft.util.ChatComponentTranslation in project Tale-of-Kingdoms by Ivasik78.
the class EntityBankerKeeper method interact.
@Override
public boolean interact(EntityPlayer player) {
if (this.canInteractWith(player)) {
if (!this.worldObj.isRemote) {
this.heal(100.0F);
player.addChatMessage(new ChatComponentTranslation("npc.banker.dialog.welcome"));
}
player.openGui(TaleOfKingdoms.instance, GUI_BANK, worldObj, 0, 0, 0);
}
return false;
}
Aggregations