Search in sources :

Example 51 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Galacticraft by micdoodle8.

the class NEIServerUtils method setHourForward.

public static void setHourForward(World world, int hour, boolean notify) {
    long day = (getTime(world) / 24000L) * 24000L;
    long newTime = day + 24000L + hour * 1000;
    setTime(newTime, world);
    if (notify) {
        ServerUtils.sendChatToAll(new ChatComponentTranslation("nei.chat.time", getTime(world) / 24000L, hour));
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Example 52 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Galacticraft by micdoodle8.

the class GuiItemIconDumper method exportItems.

private void exportItems() throws IOException {
    BufferedImage img = screenshot();
    int rows = img.getHeight() / boxSize;
    int cols = img.getWidth() / boxSize;
    int fit = rows * cols;
    for (int i = 0; parseIndex < ItemPanel.items.size() && i < fit; parseIndex++, i++) {
        int x = i % cols * boxSize;
        int y = i / cols * boxSize;
        exportImage(dir, img.getSubimage(x + borderSize, y + borderSize, iconSize, iconSize), ItemPanel.items.get(parseIndex));
    }
    if (parseIndex >= ItemPanel.items.size()) {
        returnScreen(new ChatComponentTranslation(opt.fullName() + ".icon.dumped", "dumps/itempanel_icons"));
    }
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) BufferedImage(java.awt.image.BufferedImage)

Example 53 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project BuildCraft by BuildCraft.

the class TileEngineCreative method onBlockActivated.

@Override
public boolean onBlockActivated(EntityPlayer player, EnumFacing side) {
    if (!getWorld().isRemote) {
        Item equipped = player.getCurrentEquippedItem() != null ? player.getCurrentEquippedItem().getItem() : null;
        if (equipped instanceof IToolWrench && ((IToolWrench) equipped).canWrench(player, pos)) {
            powerMode = powerMode.getNext();
            energy = 0;
            if (!(player instanceof FakePlayer)) {
                if (BuildCraftCore.hidePowerNumbers) {
                    player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode.numberless", LocaleUtil.localize("chat.pipe.power.iron.level." + powerMode.maxPower)));
                } else {
                    player.addChatMessage(new ChatComponentTranslation("chat.pipe.power.iron.mode", powerMode.maxPower));
                }
            }
            sendNetworkUpdate();
            ((IToolWrench) equipped).wrenchUsed(player, pos);
            return true;
        }
    }
    return !player.isSneaking();
}
Also used : Item(net.minecraft.item.Item) IToolWrench(buildcraft.api.tools.IToolWrench) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) FakePlayer(net.minecraftforge.common.util.FakePlayer)

Example 54 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project BuildCraft by BuildCraft.

the class ItemGateCopier method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return true;
    }
    boolean isCopying = !player.isSneaking();
    Block block = world.getBlockState(pos).getBlock();
    TileEntity tile = world.getTileEntity(pos);
    NBTTagCompound data = NBTUtilBC.getItemData(stack);
    PipePluggable pluggable = null;
    Gate gate = null;
    if (tile == null || !(tile instanceof IPipeTile)) {
        isCopying = true;
    } else {
        if (tile instanceof TileGenericPipe && block instanceof BlockGenericPipe) {
            RaytraceResult rayTraceResult = ((BlockGenericPipe) block).doRayTrace(world, pos, player);
            if (rayTraceResult != null && rayTraceResult.boundingBox != null && rayTraceResult.hitPart == Part.Pluggable) {
                pluggable = ((TileGenericPipe) tile).getPipePluggable(rayTraceResult.sideHit);
            }
        } else {
            pluggable = ((IPipeTile) tile).getPipePluggable(side);
        }
    }
    if (pluggable instanceof GatePluggable) {
        gate = ((GatePluggable) pluggable).realGate;
    }
    if (isCopying) {
        if (gate == null) {
            data = new NBTTagCompound();
            stack.setTagCompound(data);
            // Tell ItemModelMesher that this is NOT damageable, so it will use the meta for the icon
            data.setBoolean("Unbreakable", true);
            // Tell ItemStack.getToolTip() that we want to hide the resulting "Unbreakable" line that we just added
            data.setInteger("HideFlags", 4);
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.clear"));
            return true;
        }
        data = new NBTTagCompound();
        stack.setTagCompound(data);
        gate.writeStatementsToNBT(data);
        data.setByte("material", (byte) gate.material.ordinal());
        data.setByte("logic", (byte) gate.logic.ordinal());
        player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.gateCopied"));
        // Tell ItemModelMesher that this is NOT damageable, so it will use the meta for the icon
        data.setBoolean("Unbreakable", true);
        // Tell ItemStack.getToolTip() that we want to hide the resulting "Unbreakable" line that we just added
        data.setInteger("HideFlags", 4);
    } else {
        if (!data.hasKey("logic")) {
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.noInformation"));
            return true;
        } else if (gate == null) {
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.noGate"));
            return true;
        }
        GateMaterial dataMaterial = GateMaterial.fromOrdinal(data.getByte("material"));
        GateMaterial gateMaterial = gate.material;
        if (gateMaterial.numSlots < dataMaterial.numSlots) {
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.warning.slots"));
        }
        if (gateMaterial.numActionParameters < dataMaterial.numActionParameters) {
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.warning.actionParameters"));
        }
        if (gateMaterial.numTriggerParameters < dataMaterial.numTriggerParameters) {
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.warning.triggerParameters"));
        }
        if (data.getByte("logic") != gate.logic.ordinal()) {
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.warning.logic"));
        }
        gate.readStatementsFromNBT(data);
        if (!gate.verifyGateStatements()) {
            player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.warning.load"));
        }
        if (tile instanceof TileGenericPipe) {
            ((TileGenericPipe) tile).sendNetworkUpdate();
        }
        player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.gatePasted"));
        return true;
    }
    return true;
}
Also used : IPipeTile(buildcraft.api.transport.IPipeTile) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PipePluggable(buildcraft.api.transport.pluggable.PipePluggable) TileEntity(net.minecraft.tileentity.TileEntity) GateMaterial(buildcraft.transport.gates.GateDefinition.GateMaterial) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) Block(net.minecraft.block.Block) RaytraceResult(buildcraft.transport.BlockGenericPipe.RaytraceResult) GatePluggable(buildcraft.transport.gates.GatePluggable)

Example 55 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class NSPCT10 method interactFirst.

@Override
public boolean interactFirst(EntityPlayer player) {
    if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player))) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity != player) {
        return false;
    } else {
        if (player != null) {
            ItemStack stack = player.getCurrentEquippedItem();
            if (stack != null) {
                if (stack.getItem() instanceof Item1N4148 || stack.getItem() instanceof ItemNTP8Bit || stack.getItem() instanceof ItemNTP32Bit) {
                    return true;
                }
                if (stack.getItem() instanceof ItemMinecart)
                    return true;
            }
            if (!this.worldObj.isRemote) {
                player.mountEntity(this);
                player.addChatComponentMessage(new ChatComponentTranslation("info.nsr.x"));
            }
        }
        return true;
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemMinecart(net.minecraft.item.ItemMinecart) MinecartInteractEvent(net.minecraftforge.event.entity.minecart.MinecartInteractEvent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

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