Search in sources :

Example 61 with ChatComponentTranslation

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();
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) World(net.minecraft.world.World) BlockRailBase(net.minecraft.block.BlockRailBase)

Example 62 with ChatComponentTranslation

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;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemStack(net.minecraft.item.ItemStack) TileEntityRailSniffer(club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailSniffer)

Example 63 with ChatComponentTranslation

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()));
    }
}
Also used : Cancellable(com.chattriggers.ctjs.utils.Cancellable) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ClickEvent(net.minecraft.event.ClickEvent) IChatComponent(net.minecraft.util.IChatComponent) File(java.io.File) ChatComponentText(net.minecraft.util.ChatComponentText) BufferedImage(java.awt.image.BufferedImage)

Example 64 with ChatComponentTranslation

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;
            }
        }
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 65 with ChatComponentTranslation

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;
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Aggregations

ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)89 ItemStack (net.minecraft.item.ItemStack)21 TileEntity (net.minecraft.tileentity.TileEntity)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)11 ChatComponentText (net.minecraft.util.ChatComponentText)6 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 World (net.minecraft.world.World)4 Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)3 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)3 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)3 TileEntityActuator (club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator)3 BufferedImage (java.awt.image.BufferedImage)3 IChatComponent (net.minecraft.util.IChatComponent)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Int3 (WayofTime.alchemicalWizardry.api.Int3)2 TEReagentConduit (WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit)2 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)2