MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Problème Isound

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    25 Messages 4 Publieurs 4.1k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • A Hors-ligne
      aciid
      dernière édition par

      Bonjour

      J’ai mit cette ligne et j’entend pas le son(client/serveur)

      Minecraft.getMinecraft().theWorld.playSoundAtEntity(player, "noria:klaxon", 1.0F, 1.0F);
      
      1 réponse Dernière réponse Répondre Citer 0
      • robin4002R Hors-ligne
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
        dernière édition par

        player.worldObj.playSoundAtEntity(player, “noria:klaxon”, 1.0F, 1.0F);

        1 réponse Dernière réponse Répondre Citer 0
        • A Hors-ligne
          aciid
          dernière édition par

          je n’entend toujours rien

          1 réponse Dernière réponse Répondre Citer 0
          • AymericRedA Hors-ligne
            AymericRed
            dernière édition par

            As-tu un “Unable to play unknow sound event: noria:klaxon” dans la console ?

            Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

            AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

            Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
            Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

            1 réponse Dernière réponse Répondre Citer 0
            • A Hors-ligne
              aciid
              dernière édition par

              Non et quand je fait /playsound noria:klaxon sa marche bien

              1 réponse Dernière réponse Répondre Citer 0
              • A Hors-ligne
                aciid
                dernière édition par

                Bonjour j’ai fait sa

                World world = player.getEntityWorld();
                  world.playSound(player.posX, player.posY, player.posZ, "noria:klaxon", 1.0F, 1.0F, false);
                

                Mais personne entend sur le serveur.

                1 réponse Dernière réponse Répondre Citer 0
                • robin4002R Hors-ligne
                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                  dernière édition par

                  Pourtant il n’y a pas de raison que ça ne fonctionne pas.
                  Est-ce qu’il y a un message dans les logs ?

                  1 réponse Dernière réponse Répondre Citer 0
                  • A Hors-ligne
                    aciid
                    dernière édition par

                    non aucun message dans les log

                    quand moi j’appuie sur la touche j’entend le son et pas les autres

                    c’est bizarre

                    1 réponse Dernière réponse Répondre Citer 0
                    • robin4002R Hors-ligne
                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                      dernière édition par

                      Tu cherches à jouer le son à quel moment ?
                      Tu peux envoyer la classe entière où tu joue le son ?

                      1 réponse Dernière réponse Répondre Citer 0
                      • A Hors-ligne
                        aciid
                        dernière édition par

                        en gros quand on est dans un véhicule et que on appuie sur la touche du klaxon sa joue le son

                        package com.flansmod.common.driveables;
                        
                        import com.flansmod.api.IExplodeable;
                        import com.flansmod.common.CommonProxy;
                        import com.flansmod.common.FlansMod;
                        import com.flansmod.common.RotatedAxes;
                        import com.flansmod.common.network.PacketDriveableKey;
                        import com.flansmod.common.network.PacketHandler;
                        import com.flansmod.common.network.PacketPlaySound;
                        import com.flansmod.common.network.PacketVehicleControl;
                        import com.flansmod.common.parts.PartType;
                        import com.flansmod.common.teams.TeamsManager;
                        import com.flansmod.common.tools.ItemTool;
                        import com.flansmod.common.tools.ToolType;
                        import com.flansmod.common.vector.Vector3f;
                        
                        import cpw.mods.fml.common.network.NetworkRegistry;
                        import cpw.mods.fml.relauncher.Side;
                        import cpw.mods.fml.relauncher.SideOnly;
                        import fr.kerlann.command.BreakVehicule;
                        import fr.kerlann.norialife.noria;
                        import fr.kerlann.packet.PacketKlaxon;
                        import fr.kerlann.proxy.ClientProxy;
                        import io.netty.buffer.ByteBuf;
                        import net.minecraft.client.Minecraft;
                        import net.minecraft.client.audio.PositionedSoundRecord;
                        import net.minecraft.client.resources.I18n;
                        import net.minecraft.entity.Entity;
                        import net.minecraft.entity.EntityLivingBase;
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.entity.player.PlayerCapabilities;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.nbt.NBTTagCompound;
                        import net.minecraft.util.ChatComponentText;
                        import net.minecraft.util.DamageSource;
                        import net.minecraft.util.MathHelper;
                        import net.minecraft.util.ResourceLocation;
                        import net.minecraft.util.Vec3;
                        import net.minecraft.world.World;
                        
                        public class EntityVehicle extends EntityDriveable implements IExplodeable {
                        public int shellDelay;
                        public int gunDelay;
                        public int soundPosition;
                        public float wheelsYaw;
                        private int ticksSinceUsed = 0;
                        public boolean varDoor;
                        public float wheelsAngle;
                        public int toggleTimer = 0;
                        
                        public EntityVehicle(World world) {
                        super(world);
                        this.stepHeight = 1.0F;
                        }
                        
                        public EntityVehicle(World world, double x, double y, double z, VehicleType type, DriveableData data) {
                        super(world, type, data);
                        this.stepHeight = 1.0F;
                        setPosition(x, y, z);
                        initType(type, false);
                        }
                        
                        public EntityVehicle(World world, double x, double y, double z, EntityPlayer placer, VehicleType type,
                        DriveableData data) {
                        super(world, type, data);
                        this.stepHeight = 1.0F;
                        setPosition(x, y, z);
                        rotateYaw(placer.rotationYaw + 90.0F);
                        initType(type, false);
                        }
                        
                        protected void initType(DriveableType type, boolean clientSide) {
                        super.initType(type, clientSide);
                        }
                        
                        public void readSpawnData(ByteBuf data) {
                        super.readSpawnData(data);
                        }
                        
                        protected void writeEntityToNBT(NBTTagCompound tag) {
                        super.writeEntityToNBT(tag);
                        tag.setBoolean("VarDoor", this.varDoor);
                        }
                        
                        protected void readEntityFromNBT(NBTTagCompound tag) {
                        super.readEntityFromNBT(tag);
                        this.varDoor = tag.getBoolean("VarDoor");
                        }
                        
                        public void onMouseMoved(int deltaX, int deltaY) {
                        }
                        
                        public void setPositionRotationAndMotion(double x, double y, double z, float yaw, float pitch, float roll,
                        double motX, double motY, double motZ, float velYaw, float velPitch, float velRoll, float throt,
                        float steeringYaw) {
                        super.setPositionRotationAndMotion(x, y, z, yaw, pitch, roll, motX, motY, motZ, velYaw, velPitch, velRoll,
                        throt, steeringYaw);
                        this.wheelsYaw = steeringYaw;
                        }
                        
                        public boolean interactFirst(EntityPlayer entityplayer) {
                        if (this.isDead) {
                        return false;
                        }
                        if (this.worldObj.isRemote) {
                        return false;
                        }
                        ItemStack currentItem = entityplayer.getCurrentEquippedItem();
                        if ((currentItem != null) && ((currentItem.getItem() instanceof ItemTool))
                        && (((ItemTool) currentItem.getItem()).type.healDriveables)) {
                        return true;
                        }
                        VehicleType type = getVehicleType();
                        for (int i = 0; i <= type.numPassengers; i++) {
                        if (this.seats*.interactFirst(entityplayer)) {
                        if (i == 0) {
                        this.shellDelay = type.vehicleShellDelay;
                        FlansMod.proxy.doTutorialStuff(entityplayer, this);
                        }
                        return true;
                        }
                        }
                        return false;
                        }
                        
                        public boolean pressKey(int key, EntityPlayer player) {
                        VehicleType type = getVehicleType();
                        if ((this.worldObj.isRemote) && (key == 6)) {
                        ClientProxy.setGUIV(false);
                        }
                        if ((this.worldObj.isRemote) && ((key == 6) || (key == 8) || (key == 9))) {
                        FlansMod.getPacketHandler().sendToServer(new PacketDriveableKey(key));
                        return true;
                        }
                        switch (key) {
                        case 0:
                        this.throttle += 0.01F;
                        if (this.throttle > 1.0F) {
                        this.throttle = 1.0F;
                        }
                        return true;
                        case 1:
                        this.throttle -= 0.01F;
                        if (this.throttle < -1.0F) {
                        this.throttle = -1.0F;
                        }
                        if ((this.throttle < 0.0F) && (type.maxNegativeThrottle == 0.0F)) {
                        this.throttle = 0.0F;
                        }
                        return true;
                        case 2:
                        this.wheelsYaw -= 1.0F;
                        this.driveableData.fuelInTank -= 0.25F;
                        return true;
                        case 3:
                        this.wheelsYaw += 1.0F;
                        this.driveableData.fuelInTank -= 0.25F;
                        return true;
                        case 4:
                        this.throttle *= 0.8F;
                        if (this.throttle > 0.001F) {
                        this.throttle = 0.0F;
                        }
                        if (this.throttle > -0.001F) {
                        this.throttle = 0.0F;
                        }
                        return true;
                        case 5:
                        return true;
                        case 6:
                        this.seats[0].riddenByEntity.mountEntity(null);
                        return true;
                        case 7:
                        if (this.worldObj.isRemote) {
                        FlansMod.proxy.openDriveableMenu((EntityPlayer) this.seats[0].riddenByEntity, this.worldObj, this);
                        }
                        return true;
                        case 8:
                        case 9:
                        return super.pressKey(key, player);
                        case 10:
                        return true;
                        case 11:
                        return true;
                        case 12:
                        return true;
                        case 13:
                        return true;
                        case 14:
                        if (this.toggleTimer <= 0) {
                        this.varDoor = (!this.varDoor);
                        if (type.hasDoor) {
                        player.addChatMessage(new ChatComponentText("Porte " + (this.varDoor ? "Ouvert" : "Fermer")));
                        }
                        this.toggleTimer = 10;
                        FlansMod.getPacketHandler().sendToServer(new PacketVehicleControl(this));
                        }
                        return true;
                        case 15:
                        return true;
                        case 16:
                        return true;
                        case 17:
                        player.addChatMessage(new ChatComponentText("Klaxon"));
                        World world = player.getEntityWorld();
                        world.playSound(player.posX, player.posY, player.posZ, "noria:klaxon", 1.0F, 1.0F, false);
                        return true;
                        }
                        return false;
                        }
                        
                        public Vector3f getLookVector(DriveablePosition dp) {
                        return rotate(this.seats[0].looking.getXAxis());
                        }
                        
                        public void onUpdate() {
                        super.onUpdate();
                        
                        VehicleType type = getVehicleType();
                        DriveableData data = getDriveableData();
                        if (type == null) {
                        FlansMod.log("Vehicle type null. Not ticking vehicle");
                        return;
                        }
                        boolean thePlayerIsDrivingThis = (this.worldObj.isRemote) && (this.seats[0] != null)
                        && ((this.seats[0].riddenByEntity instanceof EntityPlayer))
                        && (FlansMod.proxy.isThePlayer((EntityPlayer) this.seats[0].riddenByEntity));
                        
                        this.ticksSinceUsed += 1;
                        if ((!this.worldObj.isRemote) && (this.seats[0].riddenByEntity != null)) {
                        this.ticksSinceUsed = 0;
                        }
                        if ((!this.worldObj.isRemote) && (TeamsManager.vehicleLife > 0)
                        && (this.ticksSinceUsed > TeamsManager.vehicleLife * 20)) {
                        setDead();
                        }
                        if (this.shellDelay > 0) {
                        this.shellDelay -= 1;
                        }
                        if (this.gunDelay > 0) {
                        this.gunDelay -= 1;
                        }
                        if (this.toggleTimer > 0) {
                        this.toggleTimer -= 1;
                        }
                        if (this.soundPosition > 0) {
                        this.soundPosition -= 1;
                        }
                        if (hasEnoughFuel()) {
                        this.wheelsAngle += this.throttle / 7.0F;
                        }
                        this.wheelsYaw *= 0.9F;
                        if (this.wheelsYaw > 20.0F) {
                        this.wheelsYaw = 20.0F;
                        }
                        if (this.wheelsYaw < -20.0F) {
                        this.wheelsYaw = -20.0F;
                        }
                        if ((this.worldObj.isRemote) && (!thePlayerIsDrivingThis)) {
                        if (this.serverPositionTransitionTicker > 0) {
                        double x = this.posX + (this.serverPosX - this.posX) / this.serverPositionTransitionTicker;
                        double y = this.posY + (this.serverPosY - this.posY) / this.serverPositionTransitionTicker;
                        double z = this.posZ + (this.serverPosZ - this.posZ) / this.serverPositionTransitionTicker;
                        double dYaw = MathHelper.wrapAngleTo180_double(this.serverYaw - this.axes.getYaw());
                        double dPitch = MathHelper.wrapAngleTo180_double(this.serverPitch - this.axes.getPitch());
                        double dRoll = MathHelper.wrapAngleTo180_double(this.serverRoll - this.axes.getRoll());
                        this.rotationYaw = ((float) (this.axes.getYaw() + dYaw / this.serverPositionTransitionTicker));
                        this.rotationPitch = ((float) (this.axes.getPitch() + dPitch / this.serverPositionTransitionTicker));
                        float rotationRoll = (float) (this.axes.getRoll() + dRoll / this.serverPositionTransitionTicker);
                        this.serverPositionTransitionTicker -= 1;
                        setPosition(x, y, z);
                        setRotation(this.rotationYaw, this.rotationPitch, rotationRoll);
                        }
                        }
                        
                        // Movement
                        
                        Vector3f amountToMoveCar = new Vector3f();
                        
                        for (EntityWheel wheel : wheels) {
                        if (wheel == null)
                        continue;
                        
                        // Hacky way of forcing the car to step up blocks
                        onGround = true;
                        wheel.onGround = true;
                        
                        // Update angles
                        wheel.rotationYaw = axes.getYaw();
                        // Front wheels
                        if (!type.tank && (wheel.ID == 2 || wheel.ID == 3)) {
                        wheel.rotationYaw += wheelsYaw;
                        }
                        
                        wheel.motionX *= 0.9F;
                        wheel.motionY *= 0.9F;
                        wheel.motionZ *= 0.9F;
                        
                        // Apply gravity
                        wheel.motionY -= 10F / 20F;
                        
                        // Apply velocity
                        // If the player driving this is in creative, then we can thrust, no
                        // matter what
                        boolean canThrustCreatively = !TeamsManager.vehiclesNeedFuel
                        || (seats != null && seats[0] != null && seats[0].riddenByEntity instanceof EntityPlayer
                        && ((EntityPlayer) seats[0].riddenByEntity).capabilities.isCreativeMode);
                        // Otherwise, check the fuel tanks!
                        if (canThrustCreatively || data.fuelInTank > data.engine.fuelConsumption * throttle) {
                        if (getVehicleType().tank) {
                        boolean left = wheel.ID == 0 || wheel.ID == 3;
                        float turningDrag = 0.02F;
                        wheel.motionX *= 1F - (Math.abs(wheelsYaw) * turningDrag);
                        wheel.motionZ *= 1F - (Math.abs(wheelsYaw) * turningDrag);
                        
                        float velocityScale = 0.04F * (throttle > 0 ? type.maxThrottle : type.maxNegativeThrottle)
                        * data.engine.engineSpeed;
                        float steeringScale = 0.1F * (wheelsYaw > 0 ? type.turnLeftModifier : type.turnRightModifier);
                        float effectiveWheelSpeed = (throttle + (wheelsYaw * (left ? 1 : -1) * steeringScale))
                        * velocityScale;
                        wheel.motionX += effectiveWheelSpeed * Math.cos(wheel.rotationYaw * 3.14159265F / 180F);
                        wheel.motionZ += effectiveWheelSpeed * Math.sin(wheel.rotationYaw * 3.14159265F / 180F);
                        
                        } else {
                        // if(getVehicleType().fourWheelDrive || wheel.ID == 0 ||
                        // wheel.ID == 1)
                        {
                        float velocityScale = 0.1F * throttle
                        * (throttle > 0 ? type.maxThrottle : type.maxNegativeThrottle)
                        * data.engine.engineSpeed;
                        wheel.motionX += Math.cos(wheel.rotationYaw * 3.14159265F / 180F) * velocityScale;
                        wheel.motionZ += Math.sin(wheel.rotationYaw * 3.14159265F / 180F) * velocityScale;
                        }
                        
                        // Apply steering
                        if (wheel.ID == 2 || wheel.ID == 3) {
                        float velocityScale = 0.01F * (wheelsYaw > 0 ? type.turnLeftModifier : type.turnRightModifier)
                        * (throttle > 0 ? 1 : -1);
                        
                        wheel.motionX -= wheel.getSpeedXZ() * Math.sin(wheel.rotationYaw * 3.14159265F / 180F)
                        * velocityScale * wheelsYaw;
                        wheel.motionZ += wheel.getSpeedXZ() * Math.cos(wheel.rotationYaw * 3.14159265F / 180F)
                        * velocityScale * wheelsYaw;
                        } else {
                        wheel.motionX *= 0.9F;
                        wheel.motionZ *= 0.9F;
                        }
                        }
                        }
                        
                        if (type.floatOnWater && worldObj.isAnyLiquid(wheel.boundingBox)) {
                        wheel.motionY += type.buoyancy;
                        }
                        
                        wheel.moveEntity(wheel.motionX, wheel.motionY, wheel.motionZ);
                        
                        // Pull wheels towards car
                        Vector3f targetWheelPos = axes.findLocalVectorGlobally(getVehicleType().wheelPositions[wheel.ID].position);
                        Vector3f currentWheelPos = new Vector3f(wheel.posX - posX, wheel.posY - posY, wheel.posZ - posZ);
                        
                        Vector3f dPos = ((Vector3f) Vector3f.sub(targetWheelPos, currentWheelPos, null)
                        .scale(getVehicleType().wheelSpringStrength));
                        
                        if (dPos.length() > 0.001F) {
                        wheel.moveEntity(dPos.x, dPos.y, dPos.z);
                        dPos.scale(0.5F);
                        Vector3f.sub(amountToMoveCar, dPos, amountToMoveCar);
                        }
                        }
                        
                        moveEntity(amountToMoveCar.x, amountToMoveCar.y, amountToMoveCar.z);
                        
                        if (wheels[0] != null && wheels[1] != null && wheels[2] != null && wheels[3] != null) {
                        Vector3f frontAxleCentre = new Vector3f((wheels[2].posX + wheels[3].posX) / 2F,
                        (wheels[2].posY + wheels[3].posY) / 2F, (wheels[2].posZ + wheels[3].posZ) / 2F);
                        Vector3f backAxleCentre = new Vector3f((wheels[0].posX + wheels[1].posX) / 2F,
                        (wheels[0].posY + wheels[1].posY) / 2F, (wheels[0].posZ + wheels[1].posZ) / 2F);
                        
                        float dx = frontAxleCentre.x - backAxleCentre.x;
                        float dy = frontAxleCentre.y - backAxleCentre.y;
                        float dz = frontAxleCentre.z - backAxleCentre.z;
                        
                        float dxz = (float) Math.sqrt(dx * dx + dz * dz);
                        
                        float yaw = (float) Math.atan2(dz, dx);
                        float pitch = -(float) Math.atan2(dy, dxz);
                        float roll = 0;
                        
                        if (type.tank) {
                        yaw = (float) Math.atan2(wheels[3].posZ - wheels[2].posZ, wheels[3].posX - wheels[2].posX)
                        + (float) Math.PI / 2F;
                        }
                        
                        axes.setAngles(yaw * 180F / 3.14159F, pitch * 180F / 3.14159F, roll * 180F / 3.14159F);
                        }
                        
                        checkForCollisions();
                        
                        // Sounds
                        // Starting sound
                        if (throttle > 0.01F && throttle < 0.2F && soundPosition == 0 && hasEnoughFuel()) {
                        PacketPlaySound.sendSoundPacket(posX, posY, posZ, 50, dimension, type.startSound, false);
                        soundPosition = type.startSoundLength;
                        }
                        // Flying sound
                        if (throttle > 0.2F && soundPosition == 0 && hasEnoughFuel()) {
                        PacketPlaySound.sendSoundPacket(posX, posY, posZ, 50, dimension, type.engineSound, false);
                        soundPosition = type.engineSoundLength;
                        }
                        
                        for (EntitySeat seat : seats) {
                        if (seat != null)
                        seat.updatePosition();
                        }
                        
                        // Calculate movement on the client and then send position, rotation etc
                        // to the server
                        if (thePlayerIsDrivingThis) {
                        FlansMod.getPacketHandler().sendToServer(new PacketVehicleControl(this));
                        serverPosX = posX;
                        serverPosY = posY;
                        serverPosZ = posZ;
                        serverYaw = axes.getYaw();
                        }
                        
                        // If this is the server, send position updates to everyone, having
                        // received them from the driver
                        if (!worldObj.isRemote && ticksExisted % 5 == 0) {
                        FlansMod.getPacketHandler().sendToAllAround(new PacketVehicleControl(this), posX, posY, posZ,
                        FlansMod.driveableUpdateRange, dimension);
                        }
                        }
                        
                        private float averageAngles(float a, float b) {
                        FlansMod.log("Pre  " + a + " " + b);
                        
                        float pi = 3.1415927F;
                        while (a > b + pi) {
                        a -= 2.0F * pi;
                        }
                        while (a < b - pi) {
                        a += 2.0F * pi;
                        }
                        float avg = (a + b) / 2.0F;
                        while (avg > pi) {
                        avg -= 2.0F * pi;
                        }
                        while (avg < -pi) {
                        avg += 2.0F * pi;
                        }
                        FlansMod.log("Post " + a + " " + b + " " + avg);
                        
                        return avg;
                        }
                        
                        private Vec3 subtract(Vec3 a, Vec3 b) {
                        return Vec3.createVectorHelper(a.xCoord - b.xCoord, a.yCoord - b.yCoord, a.zCoord - b.zCoord);
                        }
                        
                        private Vec3 crossProduct(Vec3 a, Vec3 b) {
                        return Vec3.createVectorHelper(a.yCoord * b.zCoord - a.zCoord * b.yCoord,
                        a.zCoord * b.xCoord - a.xCoord * b.zCoord, a.xCoord * b.yCoord - a.yCoord * b.xCoord);
                        }
                        
                        public boolean landVehicle() {
                        return true;
                        }
                        
                        public VehicleType getVehicleType() {
                        return VehicleType.getVehicle(this.driveableType);
                        }
                        
                        public float getPlayerRoll() {
                        return this.axes.getRoll();
                        }
                        
                        public boolean attackEntityFrom(DamageSource damagesource, float i) {
                        if ((this.worldObj.isRemote) || (this.isDead)) {
                        return true;
                        }
                        VehicleType type = getVehicleType();
                        if (((!damagesource.damageType.equals("player")) || (this.seats[0] == null)
                        || (this.seats[0].riddenByEntity != null || BreakVehicule.BreakVoiture == true))) {
                        ItemStack vehicleStack = new ItemStack(type.item, 1, 0);
                        vehicleStack.stackTagCompound = new NBTTagCompound();
                        this.driveableData.writeToNBT(vehicleStack.stackTagCompound);
                        entityDropItem(vehicleStack, 0.5F);
                        setDead();
                        }
                        return true;
                        }
                        
                        protected void dropItemsOnPartDeath(Vector3f midpoint, DriveablePart part) {
                        }
                        
                        public String getBombInventoryName() {
                        return "Mines";
                        }
                        
                        public String getMissileInventoryName() {
                        return "Shells";
                        }
                        
                        public boolean hasMouseControlMode() {
                        return false;
                        }
                        
                        @SideOnly(Side.CLIENT)
                        public EntityLivingBase getCamera() {
                        return null;
                        }
                        
                        public void setDead() {
                        super.setDead();
                        for (EntityWheel wheel : this.wheels) {
                        if (wheel != null) {
                        wheel.setDead();
                        }
                        }
                        }
                        }
                        
                        1 réponse Dernière réponse Répondre Citer 0
                        • robin4002R Hors-ligne
                          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                          dernière édition par

                          Ah, tu modifies flan’s mod.
                          L’appuies de touche est côté client, donc forcement les autres ne l’entendent pas.

                          La fonction pressKey peut déjà gérer le paquet, il faut juste modifier cette condition :
                          if ((this.worldObj.isRemote) && ((key == 6) || (key == 😎 || (key == 9))) {
                          Comme ceci :
                          if ((this.worldObj.isRemote) && ((key == 6) || (key == 😎 || (key == 9) || (key == 17))) {
                          Et ça sera bon.

                          1 réponse Dernière réponse Répondre Citer 0
                          • A Hors-ligne
                            aciid
                            dernière édition par

                            Bah maintenant j’entend pas le son

                            package com.flansmod.common.driveables;
                            
                            import com.flansmod.api.IExplodeable;
                            import com.flansmod.common.CommonProxy;
                            import com.flansmod.common.FlansMod;
                            import com.flansmod.common.RotatedAxes;
                            import com.flansmod.common.network.PacketDriveableKey;
                            import com.flansmod.common.network.PacketHandler;
                            import com.flansmod.common.network.PacketPlaySound;
                            import com.flansmod.common.network.PacketVehicleControl;
                            import com.flansmod.common.parts.PartType;
                            import com.flansmod.common.teams.TeamsManager;
                            import com.flansmod.common.tools.ItemTool;
                            import com.flansmod.common.tools.ToolType;
                            import com.flansmod.common.vector.Vector3f;
                            
                            import cpw.mods.fml.common.network.NetworkRegistry;
                            import cpw.mods.fml.relauncher.Side;
                            import cpw.mods.fml.relauncher.SideOnly;
                            import fr.kerlann.command.BreakVehicule;
                            import fr.kerlann.norialife.noria;
                            import fr.kerlann.packet.PacketKlaxon;
                            import fr.kerlann.proxy.ClientProxy;
                            import io.netty.buffer.ByteBuf;
                            import net.minecraft.client.Minecraft;
                            import net.minecraft.client.audio.PositionedSoundRecord;
                            import net.minecraft.client.resources.I18n;
                            import net.minecraft.entity.Entity;
                            import net.minecraft.entity.EntityLivingBase;
                            import net.minecraft.entity.player.EntityPlayer;
                            import net.minecraft.entity.player.PlayerCapabilities;
                            import net.minecraft.item.ItemStack;
                            import net.minecraft.nbt.NBTTagCompound;
                            import net.minecraft.util.ChatComponentText;
                            import net.minecraft.util.DamageSource;
                            import net.minecraft.util.MathHelper;
                            import net.minecraft.util.ResourceLocation;
                            import net.minecraft.util.Vec3;
                            import net.minecraft.world.World;
                            
                            public class EntityVehicle extends EntityDriveable implements IExplodeable {
                            public int shellDelay;
                            public int gunDelay;
                            public int soundPosition;
                            public float wheelsYaw;
                            private int ticksSinceUsed = 0;
                            public boolean varDoor;
                            public float wheelsAngle;
                            public int toggleTimer = 0;
                            
                            public EntityVehicle(World world) {
                            super(world);
                            this.stepHeight = 1.0F;
                            }
                            
                            public EntityVehicle(World world, double x, double y, double z, VehicleType type, DriveableData data) {
                            super(world, type, data);
                            this.stepHeight = 1.0F;
                            setPosition(x, y, z);
                            initType(type, false);
                            }
                            
                            public EntityVehicle(World world, double x, double y, double z, EntityPlayer placer, VehicleType type,
                            DriveableData data) {
                            super(world, type, data);
                            this.stepHeight = 1.0F;
                            setPosition(x, y, z);
                            rotateYaw(placer.rotationYaw + 90.0F);
                            initType(type, false);
                            }
                            
                            protected void initType(DriveableType type, boolean clientSide) {
                            super.initType(type, clientSide);
                            }
                            
                            public void readSpawnData(ByteBuf data) {
                            super.readSpawnData(data);
                            }
                            
                            protected void writeEntityToNBT(NBTTagCompound tag) {
                            super.writeEntityToNBT(tag);
                            tag.setBoolean("VarDoor", this.varDoor);
                            }
                            
                            protected void readEntityFromNBT(NBTTagCompound tag) {
                            super.readEntityFromNBT(tag);
                            this.varDoor = tag.getBoolean("VarDoor");
                            }
                            
                            public void onMouseMoved(int deltaX, int deltaY) {
                            }
                            
                            public void setPositionRotationAndMotion(double x, double y, double z, float yaw, float pitch, float roll,
                            double motX, double motY, double motZ, float velYaw, float velPitch, float velRoll, float throt,
                            float steeringYaw) {
                            super.setPositionRotationAndMotion(x, y, z, yaw, pitch, roll, motX, motY, motZ, velYaw, velPitch, velRoll,
                            throt, steeringYaw);
                            this.wheelsYaw = steeringYaw;
                            }
                            
                            public boolean interactFirst(EntityPlayer entityplayer) {
                            if (this.isDead) {
                            return false;
                            }
                            if (this.worldObj.isRemote) {
                            return false;
                            }
                            ItemStack currentItem = entityplayer.getCurrentEquippedItem();
                            if ((currentItem != null) && ((currentItem.getItem() instanceof ItemTool))
                            && (((ItemTool) currentItem.getItem()).type.healDriveables)) {
                            return true;
                            }
                            VehicleType type = getVehicleType();
                            for (int i = 0; i <= type.numPassengers; i++) {
                            if (this.seats*.interactFirst(entityplayer)) {
                            if (i == 0) {
                            this.shellDelay = type.vehicleShellDelay;
                            FlansMod.proxy.doTutorialStuff(entityplayer, this);
                            }
                            return true;
                            }
                            }
                            return false;
                            }
                            
                            public boolean pressKey(int key, EntityPlayer player) {
                            VehicleType type = getVehicleType();
                            if ((this.worldObj.isRemote) && (key == 6)) {
                            ClientProxy.setGUIV(false);
                            }
                            if ((this.worldObj.isRemote) && ((key == 6) || (key == 8) || (key == 9) || (key == 17))) {
                            FlansMod.getPacketHandler().sendToServer(new PacketDriveableKey(key));
                            return true;
                            }
                            switch (key) {
                            case 0:
                            this.throttle += 0.01F;
                            if (this.throttle > 1.0F) {
                            this.throttle = 1.0F;
                            }
                            return true;
                            case 1:
                            this.throttle -= 0.01F;
                            if (this.throttle < -1.0F) {
                            this.throttle = -1.0F;
                            }
                            if ((this.throttle < 0.0F) && (type.maxNegativeThrottle == 0.0F)) {
                            this.throttle = 0.0F;
                            }
                            return true;
                            case 2:
                            this.wheelsYaw -= 1.0F;
                            this.driveableData.fuelInTank -= 0.25F;
                            return true;
                            case 3:
                            this.wheelsYaw += 1.0F;
                            this.driveableData.fuelInTank -= 0.25F;
                            return true;
                            case 4:
                            this.throttle *= 0.8F;
                            if (this.throttle > 0.001F) {
                            this.throttle = 0.0F;
                            }
                            if (this.throttle > -0.001F) {
                            this.throttle = 0.0F;
                            }
                            return true;
                            case 5:
                            return true;
                            case 6:
                            this.seats[0].riddenByEntity.mountEntity(null);
                            return true;
                            case 7:
                            if (this.worldObj.isRemote) {
                            FlansMod.proxy.openDriveableMenu((EntityPlayer) this.seats[0].riddenByEntity, this.worldObj, this);
                            }
                            return true;
                            case 8:
                            case 9:
                            return super.pressKey(key, player);
                            case 10:
                            return true;
                            case 11:
                            return true;
                            case 12:
                            return true;
                            case 13:
                            return true;
                            case 14:
                            if (this.toggleTimer <= 0) {
                            this.varDoor = (!this.varDoor);
                            if (type.hasDoor) {
                            player.addChatMessage(new ChatComponentText("Porte " + (this.varDoor ? "Ouvert" : "Fermer")));
                            }
                            this.toggleTimer = 10;
                            FlansMod.getPacketHandler().sendToServer(new PacketVehicleControl(this));
                            }
                            return true;
                            case 15:
                            return true;
                            case 16:
                            return true;
                            case 17:
                            player.addChatMessage(new ChatComponentText("Klaxon"));
                            World world = player.getEntityWorld();
                            world.playSound(player.posX, player.posY, player.posZ, "noria:klaxon", 1.0F, 1.0F, false);
                            return true;
                            }
                            return false;
                            }
                            
                            public Vector3f getLookVector(DriveablePosition dp) {
                            return rotate(this.seats[0].looking.getXAxis());
                            }
                            
                            public void onUpdate() {
                            super.onUpdate();
                            
                            VehicleType type = getVehicleType();
                            DriveableData data = getDriveableData();
                            if (type == null) {
                            FlansMod.log("Vehicle type null. Not ticking vehicle");
                            return;
                            }
                            boolean thePlayerIsDrivingThis = (this.worldObj.isRemote) && (this.seats[0] != null)
                            && ((this.seats[0].riddenByEntity instanceof EntityPlayer))
                            && (FlansMod.proxy.isThePlayer((EntityPlayer) this.seats[0].riddenByEntity));
                            
                            this.ticksSinceUsed += 1;
                            if ((!this.worldObj.isRemote) && (this.seats[0].riddenByEntity != null)) {
                            this.ticksSinceUsed = 0;
                            }
                            if ((!this.worldObj.isRemote) && (TeamsManager.vehicleLife > 0)
                            && (this.ticksSinceUsed > TeamsManager.vehicleLife * 20)) {
                            setDead();
                            }
                            if (this.shellDelay > 0) {
                            this.shellDelay -= 1;
                            }
                            if (this.gunDelay > 0) {
                            this.gunDelay -= 1;
                            }
                            if (this.toggleTimer > 0) {
                            this.toggleTimer -= 1;
                            }
                            if (this.soundPosition > 0) {
                            this.soundPosition -= 1;
                            }
                            if (hasEnoughFuel()) {
                            this.wheelsAngle += this.throttle / 7.0F;
                            }
                            this.wheelsYaw *= 0.9F;
                            if (this.wheelsYaw > 20.0F) {
                            this.wheelsYaw = 20.0F;
                            }
                            if (this.wheelsYaw < -20.0F) {
                            this.wheelsYaw = -20.0F;
                            }
                            if ((this.worldObj.isRemote) && (!thePlayerIsDrivingThis)) {
                            if (this.serverPositionTransitionTicker > 0) {
                            double x = this.posX + (this.serverPosX - this.posX) / this.serverPositionTransitionTicker;
                            double y = this.posY + (this.serverPosY - this.posY) / this.serverPositionTransitionTicker;
                            double z = this.posZ + (this.serverPosZ - this.posZ) / this.serverPositionTransitionTicker;
                            double dYaw = MathHelper.wrapAngleTo180_double(this.serverYaw - this.axes.getYaw());
                            double dPitch = MathHelper.wrapAngleTo180_double(this.serverPitch - this.axes.getPitch());
                            double dRoll = MathHelper.wrapAngleTo180_double(this.serverRoll - this.axes.getRoll());
                            this.rotationYaw = ((float) (this.axes.getYaw() + dYaw / this.serverPositionTransitionTicker));
                            this.rotationPitch = ((float) (this.axes.getPitch() + dPitch / this.serverPositionTransitionTicker));
                            float rotationRoll = (float) (this.axes.getRoll() + dRoll / this.serverPositionTransitionTicker);
                            this.serverPositionTransitionTicker -= 1;
                            setPosition(x, y, z);
                            setRotation(this.rotationYaw, this.rotationPitch, rotationRoll);
                            }
                            }
                            
                            // Movement
                            
                            Vector3f amountToMoveCar = new Vector3f();
                            
                            for (EntityWheel wheel : wheels) {
                            if (wheel == null)
                            continue;
                            
                            // Hacky way of forcing the car to step up blocks
                            onGround = true;
                            wheel.onGround = true;
                            
                            // Update angles
                            wheel.rotationYaw = axes.getYaw();
                            // Front wheels
                            if (!type.tank && (wheel.ID == 2 || wheel.ID == 3)) {
                            wheel.rotationYaw += wheelsYaw;
                            }
                            
                            wheel.motionX *= 0.9F;
                            wheel.motionY *= 0.9F;
                            wheel.motionZ *= 0.9F;
                            
                            // Apply gravity
                            wheel.motionY -= 10F / 20F;
                            
                            // Apply velocity
                            // If the player driving this is in creative, then we can thrust, no
                            // matter what
                            boolean canThrustCreatively = !TeamsManager.vehiclesNeedFuel
                            || (seats != null && seats[0] != null && seats[0].riddenByEntity instanceof EntityPlayer
                            && ((EntityPlayer) seats[0].riddenByEntity).capabilities.isCreativeMode);
                            // Otherwise, check the fuel tanks!
                            if (canThrustCreatively || data.fuelInTank > data.engine.fuelConsumption * throttle) {
                            if (getVehicleType().tank) {
                            boolean left = wheel.ID == 0 || wheel.ID == 3;
                            float turningDrag = 0.02F;
                            wheel.motionX *= 1F - (Math.abs(wheelsYaw) * turningDrag);
                            wheel.motionZ *= 1F - (Math.abs(wheelsYaw) * turningDrag);
                            
                            float velocityScale = 0.04F * (throttle > 0 ? type.maxThrottle : type.maxNegativeThrottle)
                            * data.engine.engineSpeed;
                            float steeringScale = 0.1F * (wheelsYaw > 0 ? type.turnLeftModifier : type.turnRightModifier);
                            float effectiveWheelSpeed = (throttle + (wheelsYaw * (left ? 1 : -1) * steeringScale))
                            * velocityScale;
                            wheel.motionX += effectiveWheelSpeed * Math.cos(wheel.rotationYaw * 3.14159265F / 180F);
                            wheel.motionZ += effectiveWheelSpeed * Math.sin(wheel.rotationYaw * 3.14159265F / 180F);
                            
                            } else {
                            // if(getVehicleType().fourWheelDrive || wheel.ID == 0 ||
                            // wheel.ID == 1)
                            {
                            float velocityScale = 0.1F * throttle
                            * (throttle > 0 ? type.maxThrottle : type.maxNegativeThrottle)
                            * data.engine.engineSpeed;
                            wheel.motionX += Math.cos(wheel.rotationYaw * 3.14159265F / 180F) * velocityScale;
                            wheel.motionZ += Math.sin(wheel.rotationYaw * 3.14159265F / 180F) * velocityScale;
                            }
                            
                            // Apply steering
                            if (wheel.ID == 2 || wheel.ID == 3) {
                            float velocityScale = 0.01F * (wheelsYaw > 0 ? type.turnLeftModifier : type.turnRightModifier)
                            * (throttle > 0 ? 1 : -1);
                            
                            wheel.motionX -= wheel.getSpeedXZ() * Math.sin(wheel.rotationYaw * 3.14159265F / 180F)
                            * velocityScale * wheelsYaw;
                            wheel.motionZ += wheel.getSpeedXZ() * Math.cos(wheel.rotationYaw * 3.14159265F / 180F)
                            * velocityScale * wheelsYaw;
                            } else {
                            wheel.motionX *= 0.9F;
                            wheel.motionZ *= 0.9F;
                            }
                            }
                            }
                            
                            if (type.floatOnWater && worldObj.isAnyLiquid(wheel.boundingBox)) {
                            wheel.motionY += type.buoyancy;
                            }
                            
                            wheel.moveEntity(wheel.motionX, wheel.motionY, wheel.motionZ);
                            
                            // Pull wheels towards car
                            Vector3f targetWheelPos = axes.findLocalVectorGlobally(getVehicleType().wheelPositions[wheel.ID].position);
                            Vector3f currentWheelPos = new Vector3f(wheel.posX - posX, wheel.posY - posY, wheel.posZ - posZ);
                            
                            Vector3f dPos = ((Vector3f) Vector3f.sub(targetWheelPos, currentWheelPos, null)
                            .scale(getVehicleType().wheelSpringStrength));
                            
                            if (dPos.length() > 0.001F) {
                            wheel.moveEntity(dPos.x, dPos.y, dPos.z);
                            dPos.scale(0.5F);
                            Vector3f.sub(amountToMoveCar, dPos, amountToMoveCar);
                            }
                            }
                            
                            moveEntity(amountToMoveCar.x, amountToMoveCar.y, amountToMoveCar.z);
                            
                            if (wheels[0] != null && wheels[1] != null && wheels[2] != null && wheels[3] != null) {
                            Vector3f frontAxleCentre = new Vector3f((wheels[2].posX + wheels[3].posX) / 2F,
                            (wheels[2].posY + wheels[3].posY) / 2F, (wheels[2].posZ + wheels[3].posZ) / 2F);
                            Vector3f backAxleCentre = new Vector3f((wheels[0].posX + wheels[1].posX) / 2F,
                            (wheels[0].posY + wheels[1].posY) / 2F, (wheels[0].posZ + wheels[1].posZ) / 2F);
                            
                            float dx = frontAxleCentre.x - backAxleCentre.x;
                            float dy = frontAxleCentre.y - backAxleCentre.y;
                            float dz = frontAxleCentre.z - backAxleCentre.z;
                            
                            float dxz = (float) Math.sqrt(dx * dx + dz * dz);
                            
                            float yaw = (float) Math.atan2(dz, dx);
                            float pitch = -(float) Math.atan2(dy, dxz);
                            float roll = 0;
                            
                            if (type.tank) {
                            yaw = (float) Math.atan2(wheels[3].posZ - wheels[2].posZ, wheels[3].posX - wheels[2].posX)
                            + (float) Math.PI / 2F;
                            }
                            
                            axes.setAngles(yaw * 180F / 3.14159F, pitch * 180F / 3.14159F, roll * 180F / 3.14159F);
                            }
                            
                            checkForCollisions();
                            
                            // Sounds
                            // Starting sound
                            if (throttle > 0.01F && throttle < 0.2F && soundPosition == 0 && hasEnoughFuel()) {
                            PacketPlaySound.sendSoundPacket(posX, posY, posZ, 50, dimension, type.startSound, false);
                            soundPosition = type.startSoundLength;
                            }
                            // Flying sound
                            if (throttle > 0.2F && soundPosition == 0 && hasEnoughFuel()) {
                            PacketPlaySound.sendSoundPacket(posX, posY, posZ, 50, dimension, type.engineSound, false);
                            soundPosition = type.engineSoundLength;
                            }
                            
                            for (EntitySeat seat : seats) {
                            if (seat != null)
                            seat.updatePosition();
                            }
                            
                            // Calculate movement on the client and then send position, rotation etc
                            // to the server
                            if (thePlayerIsDrivingThis) {
                            FlansMod.getPacketHandler().sendToServer(new PacketVehicleControl(this));
                            serverPosX = posX;
                            serverPosY = posY;
                            serverPosZ = posZ;
                            serverYaw = axes.getYaw();
                            }
                            
                            // If this is the server, send position updates to everyone, having
                            // received them from the driver
                            if (!worldObj.isRemote && ticksExisted % 5 == 0) {
                            FlansMod.getPacketHandler().sendToAllAround(new PacketVehicleControl(this), posX, posY, posZ,
                            FlansMod.driveableUpdateRange, dimension);
                            }
                            }
                            
                            private float averageAngles(float a, float b) {
                            FlansMod.log("Pre  " + a + " " + b);
                            
                            float pi = 3.1415927F;
                            while (a > b + pi) {
                            a -= 2.0F * pi;
                            }
                            while (a < b - pi) {
                            a += 2.0F * pi;
                            }
                            float avg = (a + b) / 2.0F;
                            while (avg > pi) {
                            avg -= 2.0F * pi;
                            }
                            while (avg < -pi) {
                            avg += 2.0F * pi;
                            }
                            FlansMod.log("Post " + a + " " + b + " " + avg);
                            
                            return avg;
                            }
                            
                            private Vec3 subtract(Vec3 a, Vec3 b) {
                            return Vec3.createVectorHelper(a.xCoord - b.xCoord, a.yCoord - b.yCoord, a.zCoord - b.zCoord);
                            }
                            
                            private Vec3 crossProduct(Vec3 a, Vec3 b) {
                            return Vec3.createVectorHelper(a.yCoord * b.zCoord - a.zCoord * b.yCoord,
                            a.zCoord * b.xCoord - a.xCoord * b.zCoord, a.xCoord * b.yCoord - a.yCoord * b.xCoord);
                            }
                            
                            public boolean landVehicle() {
                            return true;
                            }
                            
                            public VehicleType getVehicleType() {
                            return VehicleType.getVehicle(this.driveableType);
                            }
                            
                            public float getPlayerRoll() {
                            return this.axes.getRoll();
                            }
                            
                            public boolean attackEntityFrom(DamageSource damagesource, float i) {
                            if ((this.worldObj.isRemote) || (this.isDead)) {
                            return true;
                            }
                            VehicleType type = getVehicleType();
                            if (((!damagesource.damageType.equals("player")) || (this.seats[0] == null)
                            || (this.seats[0].riddenByEntity != null || BreakVehicule.BreakVoiture == true))) {
                            ItemStack vehicleStack = new ItemStack(type.item, 1, 0);
                            vehicleStack.stackTagCompound = new NBTTagCompound();
                            this.driveableData.writeToNBT(vehicleStack.stackTagCompound);
                            entityDropItem(vehicleStack, 0.5F);
                            setDead();
                            }
                            return true;
                            }
                            
                            protected void dropItemsOnPartDeath(Vector3f midpoint, DriveablePart part) {
                            }
                            
                            public String getBombInventoryName() {
                            return "Mines";
                            }
                            
                            public String getMissileInventoryName() {
                            return "Shells";
                            }
                            
                            public boolean hasMouseControlMode() {
                            return false;
                            }
                            
                            @SideOnly(Side.CLIENT)
                            public EntityLivingBase getCamera() {
                            return null;
                            }
                            
                            public void setDead() {
                            super.setDead();
                            for (EntityWheel wheel : this.wheels) {
                            if (wheel != null) {
                            wheel.setDead();
                            }
                            }
                            }
                            }
                            
                            
                            1 réponse Dernière réponse Répondre Citer 0
                            • robin4002R Hors-ligne
                              robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                              dernière édition par

                              Utilises plutôt playSoundEffect :

                              world.playSoundEffect(player.posX, player.posY, player.posZ, "noria:klaxon", 1.0F, 1.0F);
                              

                              playSound ne fait rien côté serveur.

                              1 réponse Dernière réponse Répondre Citer 0
                              • A Hors-ligne
                                aciid
                                dernière édition par

                                Merci sa marche !

                                1 réponse Dernière réponse Répondre Citer 0
                                • 1
                                • 2
                                • 1 / 2
                                • Premier message
                                  Dernier message
                                Design by Woryk
                                ContactMentions Légales

                                MINECRAFT FORGE FRANCE © 2024

                                Powered by NodeBB