Search in sources :

Example 16 with ChatComponentTranslation

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

the class NEIServerUtils method setGamemode.

public static void setGamemode(EntityPlayerMP player, int mode) {
    if (mode < 0 || mode >= NEIActions.gameModes.length || NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode]) && !NEIServerConfig.canPlayerPerformAction(player.getName(), NEIActions.gameModes[mode])) {
        return;
    }
    // creative+
    NEIServerConfig.forPlayer(player.getName()).enableAction("creative+", mode == 2);
    if (// open the container immediately for the client
    mode == 2 && !(player.openContainer instanceof ContainerCreativeInv)) {
        NEISPH.processCreativeInv(player, true);
    }
    // change it on the server
    player.theItemInWorldManager.setGameType(getGameType(mode));
    // tell the client to change it
    new PacketCustom(NEISPH.channel, 14).writeByte(mode).sendToPlayer(player);
    player.addChatMessage(new ChatComponentTranslation("nei.chat.gamemode." + mode));
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) PacketCustom(codechicken.lib.packet.PacketCustom)

Example 17 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project Armourers-Workshop by RiskyKen.

the class BlockSkinnable method sleepInBed.

private boolean sleepInBed(World world, int x, int y, int z, EntityPlayer player, Skin skin, ForgeDirection direction, TileEntitySkinnable tileEntity) {
    if (world.isRemote) {
        return true;
    }
    Point3D point = null;
    if (skin.getParts().get(0).getMarkerCount() > 0) {
        point = skin.getParts().get(0).getMarker(0);
    } else {
        point = new Point3D(0, 0, 16);
    }
    int xBlockOffset = MathHelper.floor_double(((double) point.getX() + 8) / 16D);
    int zBlockOffset = MathHelper.floor_double(((double) point.getZ() + 8) / 16D);
    int xOffset = (point.getX() + 8) - x * 16;
    int zOffset = (point.getY() + 8) - y * 16;
    x -= xBlockOffset * direction.offsetZ + zBlockOffset * direction.offsetX;
    ;
    z -= zBlockOffset * direction.offsetZ + xBlockOffset * direction.offsetX;
    float scale = 1F / 16F;
    EntityPlayer.EnumStatus enumstatus = player.sleepInBedAt(x, y, z);
    if (enumstatus == EntityPlayer.EnumStatus.OK) {
        tileEntity.setBedOccupied(true);
        ModLogger.log("sleeping!");
        player.field_71079_bU = 0.0F;
        player.field_71089_bV = 0.0F;
        player.setPosition(x + 10, y - 0.5F, z + 1);
        player.playerLocation = new ChunkCoordinates(x, y, z);
        world.updateAllPlayersSleepingFlag();
        return true;
    } else {
        if (enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW) {
            player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep", new Object[0]));
        } else if (enumstatus == EntityPlayer.EnumStatus.NOT_SAFE) {
            player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe", new Object[0]));
        }
        return true;
    }
}
Also used : Point3D(riskyken.armourersWorkshop.api.common.skin.Point3D) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChunkCoordinates(net.minecraft.util.ChunkCoordinates)

Example 18 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.

the class RenderItemPneumaticHelmet method render.

public void render() {
    if (helmetModel == null) {
        helmetModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET);
        eyesModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET_EYES);
        faceModel = AdvancedModelLoader.loadModel(Models.PNEUMATIC_HELMET_FACE);
        if (!Config.useHelmetModel) {
            PneumaticCraft.proxy.getPlayer().addChatComponentMessage(new ChatComponentTranslation("message.date.ironman"));
        }
    }
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor4d(1, 0.2, 0.2, 1);
    helmetModel.renderAll();
    GL11.glColor4d(1, 1, 0.7, 1);
    faceModel.renderAll();
    GL11.glColor4d(1, 1, 1, 1);
    GL11.glDisable(GL11.GL_CULL_FACE);
    eyesModel.renderAll();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Example 19 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.

the class EntityDrone method onDeath.

@Override
public void onDeath(DamageSource par1DamageSource) {
    for (int i = 0; i < inventory.getSizeInventory(); i++) {
        if (inventory.getStackInSlot(i) != null) {
            entityDropItem(inventory.getStackInSlot(i), 0);
            inventory.setInventorySlotContents(i, null);
        }
    }
    if (naturallySpawned) {
    } else {
        ItemStack drone = getDroppedStack();
        if (hasCustomNameTag())
            drone.setStackDisplayName(getCustomNameTag());
        entityDropItem(drone, 0);
        if (!worldObj.isRemote) {
            EntityPlayer owner = getOwner();
            if (owner != null) {
                int x = (int) Math.floor(posX);
                int y = (int) Math.floor(posY);
                int z = (int) Math.floor(posZ);
                if (hasCustomNameTag()) {
                    owner.addChatComponentMessage(new ChatComponentTranslation("death.drone.named", getCustomNameTag(), x, y, z));
                } else {
                    owner.addChatComponentMessage(new ChatComponentTranslation("death.drone", x, y, z));
                }
            }
        }
    }
    if (!worldObj.isRemote)
        ((FakePlayerItemInWorldManager) getFakePlayer().theItemInWorldManager).cancelDigging();
    super.onDeath(par1DamageSource);
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) PathPoint(net.minecraft.pathfinding.PathPoint)

Example 20 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project PneumaticCraft by MineMaarten.

the class CommandAmazonDelivery method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) {
    if (args.length < 2)
        throw new WrongUsageException("command.deliverAmazon.args");
    int x, y, z;
    int curArg;
    String regex = "-?\\d+";
    if (args[0].matches(regex)) {
        if (args.length < 4)
            throw new WrongUsageException("command.deliverAmazon.args");
        if (!args[1].matches(regex) || !args[2].matches(regex))
            throw new WrongUsageException("command.deliverAmazon.coords");
        x = Integer.parseInt(args[0]);
        y = Integer.parseInt(args[1]);
        z = Integer.parseInt(args[2]);
        curArg = 3;
    } else {
        EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(args[0]);
        if (player != null) {
            x = (int) Math.floor(player.posX);
            y = (int) Math.floor(player.posY) + 1;
            z = (int) Math.floor(player.posZ);
            curArg = 1;
        } else {
            throw new WrongUsageException("command.deliverAmazon.playerName");
        }
    }
    if (args.length < curArg + 3)
        throw new WrongUsageException("command.deliverAmazon.args");
    if (!args[curArg].matches(regex) || !args[curArg + 1].matches(regex) || !args[curArg + 2].matches(regex))
        throw new WrongUsageException("command.deliverAmazon.coords");
    TileEntity te = sender.getEntityWorld().getTileEntity(Integer.parseInt(args[curArg]), Integer.parseInt(args[curArg + 1]), Integer.parseInt(args[curArg + 2]));
    IInventory inv = IOHelper.getInventoryForTE(te);
    if (inv != null) {
        List<ItemStack> deliveredStacks = new ArrayList<ItemStack>();
        for (int i = 0; i < inv.getSizeInventory() && deliveredStacks.size() < 65; i++) {
            if (inv.getStackInSlot(i) != null)
                deliveredStacks.add(inv.getStackInSlot(i));
        }
        if (deliveredStacks.size() > 0) {
            PneumaticRegistry.getInstance().deliverItemsAmazonStyle(sender.getEntityWorld(), x, y, z, deliveredStacks.toArray(new ItemStack[deliveredStacks.size()]));
            sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.success"));
        } else {
            sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.noItems"));
        }
    } else {
        throw new WrongUsageException("command.deliverAmazon.noInventory");
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) WrongUsageException(net.minecraft.command.WrongUsageException) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ArrayList(java.util.ArrayList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)77 ItemStack (net.minecraft.item.ItemStack)19 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 TileEntity (net.minecraft.tileentity.TileEntity)13 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)11 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 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)3 TileEntityActuator (club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator)3 EntityItem (net.minecraft.entity.item.EntityItem)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 TileEntityRailSniffer (club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailSniffer)2 TileEntityReceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 Side (cpw.mods.fml.relauncher.Side)2