• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Missile

    Sans suite
    1
    1
    845
    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.
    • darkvince37
      darkvince37 dernière édition par

      Bonjours,

      Je voudrai créer un missile elstorme comme le jeux B02, J’ai suivie un tuto sur votre site et un Github, sa marche sauf que la fonction pour le diriger ne marche pas.

      Mais class

      ​package morehealth;
      
      import ibxm.Player;
      
      import java.io.File;
      
      import com.google.common.base.Throwables;
      
      import net.minecraft.block.Block;
      import net.minecraft.client.Minecraft;
      import net.minecraft.creativetab.CreativeTabs;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.Item;
      import net.minecraft.util.MathHelper;
      import net.minecraftforge.client.event.RenderGameOverlayEvent;
      import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
      import net.minecraftforge.client.event.RenderLivingEvent;
      import net.minecraftforge.common.MinecraftForge;
      import net.minecraftforge.event.entity.player.PlayerEvent;
      import morehealth.common.CommonProxy;
      import cpw.mods.fml.client.FMLClientHandler;
      import cpw.mods.fml.common.FMLCommonHandler;
      import cpw.mods.fml.common.Mod;
      import cpw.mods.fml.common.Mod.EventHandler;
      import cpw.mods.fml.common.Mod.Instance;
      import cpw.mods.fml.common.SidedProxy;
      import cpw.mods.fml.common.event.FMLInitializationEvent;
      import cpw.mods.fml.common.event.FMLPostInitializationEvent;
      import cpw.mods.fml.common.event.FMLPreInitializationEvent;
      import cpw.mods.fml.common.eventhandler.EventPriority;
      import cpw.mods.fml.common.eventhandler.SubscribeEvent;
      import cpw.mods.fml.common.gameevent.TickEvent;
      import cpw.mods.fml.common.registry.GameRegistry;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      
      @Mod(modid = "heal", name = "heal", version = "1.0.0")
      public class Heal
      {
      
      //jukebox
      public static Block listerJukeBox;
      public static Item visibombGun;
      
      //pseudo
      @SubscribeEvent
      @SideOnly(Side.CLIENT)
      public void onRenderLabel(RenderLivingEvent.Specials.Pre event)
      {
      if(event.entity instanceof EntityPlayer)
      {
      event.setCanceled(true);
      }
      }
      //pseudo
      @Instance("heal")
      public static Heal modInstance;
      public static final String MODID = "heal";
      @SidedProxy(clientSide = "morehealth.client.ClientProxy", serverSide = "morehealth.common.CommonProxy")
      public static CommonProxy proxy;
      @SubscribeEvent
      @SideOnly(Side.CLIENT)
      public void renderGameOverlay(RenderGameOverlayEvent.Pre event)
      {
      if(event.type == ElementType.FOOD)
      {
      event.setCanceled(false);
      }
      if(event.type == ElementType.ARMOR)
      {
      event.setCanceled(true);
      }
      if(event.type == ElementType.BOSSHEALTH)
      {
      event.setCanceled(true);
      }
      }
      @SubscribeEvent
      public void maskXpBar(RenderGameOverlayEvent.Pre event)
      {
      if(event.type == ElementType.EXPERIENCE)
      {
      event.setCanceled(true);
      }
      }
      
      @SubscribeEvent
      public void PlayerTickEvent(PlayerEvent event)
      {
      if(event.entityPlayer.getFoodStats().getFoodLevel() < 20)
      {
      event.entityPlayer.getFoodStats().addStats(20, 20);
      }
      }
      
      @EventHandler
      public void preInit(FMLPreInitializationEvent event)
      {
      listerJukeBox = new BlockListerJukebox().setHardness(2.0F).setResistance(10.0F).setBlockName("listerJukebox").setBlockTextureName(Heal.MODID + ":listerjukebox").setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundTypeWood);
      visibombGun = new ItemVisibombGun().setUnlocalizedName("visibombGun").setTextureName("rcmod:visibombGun").setCreativeTab(CreativeTabs.tabBlock).setFull3D();
      GameRegistry.registerItem(visibombGun, "visibombGun");
      }
      
      @EventHandler
      public void init(FMLInitializationEvent event)
      {
      //proxy
      proxy.registerRender();
      MinecraftForge.EVENT_BUS.register(this);
      
      }
      
      @EventHandler
      public void postInit(FMLPostInitializationEvent event)
      {
      
      }
      }
      
      
      ​package morehealth;
      
      import net.minecraft.client.Minecraft;
      import net.minecraft.command.ICommandSender;
      import net.minecraft.command.PlayerNotFoundException;
      import net.minecraft.command.PlayerSelector;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.EntityPlayerMP;
      import net.minecraft.entity.projectile.EntityThrowable;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.server.MinecraftServer;
      import net.minecraft.util.DamageSource;
      import net.minecraft.util.MathHelper;
      import net.minecraft.util.MovingObjectPosition;
      import net.minecraft.world.World;
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      
      public class EntityVisibombAmmo extends EntityThrowable {
      private int ticksInAir;
      private EntityPlayer entityFiring;
      private int entityFiringID = -1;
      public String firingEntityName;
      
      public EntityVisibombAmmo(World par1World) {
      super(par1World);
      double speed = 0.5;
      this.motionX *= speed;
      this.motionY *= speed;
      this.motionZ *= speed;
      this.setThrowableHeading(this.motionX, this.motionY, this.motionZ,
      0.0001f, 0.05F);
      
      }
      
      public EntityVisibombAmmo(World par1World, EntityPlayer par2EntityLivingBase) {
      super(par1World, par2EntityLivingBase);
      double speed = 0.5;
      this.motionX *= speed;
      this.motionY *= speed;
      this.motionZ *= speed;
      this.entityFiring = (EntityPlayer) par2EntityLivingBase;
      this.firingEntityName = entityFiring.getDisplayName();
      if (entityFiring instanceof EntityPlayerMP) {
      EntityPlayerMP targetRot = (EntityPlayerMP) entityFiring;
      
      setRotation(-targetRot.rotationYaw, -targetRot.rotationPitch);
      }
      }
      
      /*
      * public EntityVisibombAmmo(World par1World, double par2, double par4,
      * double par6) { super(par1World, par2, par4, par6); }
      */
      
      @Override
      public void entityInit() {
      
      }
      
      @Override
      protected void onImpact(MovingObjectPosition movingobjectposition) {
      if (movingobjectposition.entityHit != null) {
      this.worldObj.createExplosion(this, this.posX, this.posY,
      this.posZ, 0.1F, true);
      movingobjectposition.entityHit.attackEntityFrom(
      DamageSource.causeThrownDamage(this, this.getThrower()),
      12.0F);
      // movingobjectposition.entityHit.setFire(5);
      this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY,
      this.posZ, 0.0D, 0.0D, 0.0D);
      this.setDead();
      } else {
      this.worldObj.createExplosion(this, this.posX, this.posY,
      this.posZ, 0.0F, true);
      this.setDead();
      }
      // this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ,
      // 0.0F, true);
      // this.setDead();
      }
      
      protected float getGravityVelocity() {
      return 0.0F;
      }
      
      public void onUpdate() {
      // if (this.entityFiring == null || this.entityFiring.isDead) {
      // this.setDead();
      // }
      this.lastTickPosX = this.posX;
      this.lastTickPosY = this.posY;
      this.lastTickPosZ = this.posZ;
      super.onUpdate();
      ++this.ticksInAir;
      
      if (entityFiring instanceof EntityPlayerMP) {
      EntityPlayerMP targetRot = (EntityPlayerMP) entityFiring;
      
      setRotation(-targetRot.rotationYaw, -targetRot.rotationPitch);
      } else {
      
      }
      
      // setRotation(-mc.thePlayer.rotationYaw, -mc.thePlayer.rotationPitch);
      
      this.motionX = (double) (MathHelper.sin(this.rotationYaw / 180.0F
      * (float) Math.PI)
      * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI) * 0.4f);
      this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F
      * (float) Math.PI)
      * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI) * 0.4f);
      this.motionY = (double) (MathHelper.sin((this.rotationPitch + this
      .func_70183_g()) / 180.0F * (float) Math.PI) * 0.4f);
      
      if (this.ticksInAir == 200) {
      this.setDead();
      }
      }
      
      public void readFromNBT(NBTTagCompound nbt) {
      super.readFromNBT(nbt);
      // entityFiringID = nbt.getInteger("entityFiringID");
      }
      
      public void writeToNBT(NBTTagCompound nbt) {
      super.writeToNBT(nbt);
      // nbt.setInteger("entityFiringID", entityFiringID);
      }
      
      /*
      * public int getFiringEntityID() { return entityFiringID; }
      */
      }
      
      ​package morehealth;
      
      import net.minecraft.client.Minecraft;
      import net.minecraft.client.entity.EntityClientPlayerMP;
      import net.minecraft.client.renderer.EntityRenderer;
      import net.minecraft.client.renderer.OpenGlHelper;
      import net.minecraft.client.shader.ShaderGroup;
      import net.minecraft.client.util.JsonException;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.EntityLiving;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.util.MathHelper;
      import net.minecraft.util.ResourceLocation;
      import morehealth.EntityVisibombAmmo;
      import morehealth.client.ClientProxy;
      import cpw.mods.fml.common.ObfuscationReflectionHelper;
      
      public class EntityVisibombCamera extends EntityLiving {
      private static EntityVisibombCamera instance;
      private Entity target;
      private boolean enabled, invert, isReturning;
      private int maxLife, despawnDelay;
      
      private boolean hideGUI;
      private float fovSetting;
      private int thirdPersonView;
          private long startedReturningTime;
          private double oldPosX;
          private double oldPosY;
          private double oldPosZ;
      
          private float oldRotYaw;
          private float oldRotYawHead;
          private float oldRotPitch;
      
          private static final long maxReturnTime = 500;
      private static final int positionSmoother = 5;
      private static final int rotationSmoother = 5;
          private static final ResourceLocation shaderLocation = new ResourceLocation("rcmod", "shaders/post/visibomb.json");
      
      private EntityVisibombCamera() {
      super(null);
      
      setSize(0.0F, 0.0F);
      yOffset = 0.0F;
      }
      
      public static EntityVisibombCamera getInstance() {
      if (instance == null) {
      instance = new EntityVisibombCamera();
      }
      return instance;
      }
      
      public void startCam(Entity target) {
      startCam(target, false);
      }
      
      public void startCam(Entity target, boolean invert) {
      startCam(target, invert, 150);
      }
      
      public void startCam(Entity target, boolean invert, int maxLife) {
      startCam(target, invert, maxLife, 20);
      }
      
      public void startCam(Entity target, boolean invert, int maxLife,
      int despawnDelay) {
      Minecraft mc = Minecraft.getMinecraft();
      stopCam();
      hideGUI = mc.gameSettings.hideGUI;
      fovSetting = mc.gameSettings.fovSetting;
      thirdPersonView = mc.gameSettings.thirdPersonView;
      
      mc.gameSettings.hideGUI = true;
      // mc.gameSettings.thirdPersonView = 1;
      mc.renderViewEntity = this;
      
      enabled = true;
      isReturning = false;
      this.target = target;
      this.invert = invert;
      this.maxLife = maxLife;
      this.despawnDelay = despawnDelay;
      this.isDead = false;
      worldObj = target.worldObj;
      worldObj.spawnEntityInWorld(this);
      this.oldRotYaw = mc.thePlayer.rotationYaw;
      this.oldRotYawHead = mc.thePlayer.rotationYawHead;
      this.oldRotPitch = mc.thePlayer.rotationPitch;
      
      setPosition(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ);
      setRotation(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
      activateGreenScreenShader();
      doCameraMove();
      }
      
      private void activateGreenScreenShader()
          {
         if(OpenGlHelper.shadersSupported)
         {
             ShaderGroup theShaderGroup;
                  try
                  {
                      theShaderGroup = new ShaderGroup(ClientProxy.rcResourceManager, Minecraft.getMinecraft().getFramebuffer(), shaderLocation);
                      theShaderGroup.createBindFramebuffers(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
                      ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, theShaderGroup, 42);
                  }
                  catch (JsonException e)
                  {
                      e.printStackTrace();
                  }
         }
          }
      
      private void desactivateGreenScreenShader()
          {
              Minecraft.getMinecraft().entityRenderer.deactivateShader();
          }
      
          public void stopCam() {
      Minecraft mc = Minecraft.getMinecraft();
      if (worldObj != null)
      worldObj.removeEntity(this);
      
      if (!enabled)
      return;
      enabled = false;
      isReturning = false;
      
      mc.gameSettings.hideGUI = hideGUI;
      mc.gameSettings.fovSetting = fovSetting;
      mc.gameSettings.thirdPersonView = thirdPersonView;
      mc.renderViewEntity = mc.thePlayer;
      mc.thePlayer.rotationPitch = oldRotPitch;
      mc.thePlayer.rotationYaw = oldRotYaw;
      mc.thePlayer.rotationYawHead = oldRotYawHead;
      }
      
      private void doCameraMove() {
      double x = posX + (target.posX - posX);
      double y = (posY + (target.posY - posY) / positionSmoother) - 0.3f;
      double z = posZ + (target.posZ - posZ);
      
      float yaw = MathHelper(rotationYaw, target.rotationYaw);
      float pitch = MathHelper(rotationPitch,
      target.rotationPitch);
      if (invert) {
      yaw = -(rotationYaw + yaw);
      pitch = -(rotationPitch + pitch);
      } else {
      
      yaw /= rotationSmoother;
      pitch /= rotationSmoother;
      yaw += rotationYaw;
      pitch += rotationPitch;
      }
      
      if(this.isReturning)
      {
         double t = ((double)System.currentTimeMillis()-(double)startedReturningTime)/(double)maxReturnTime;
                  x = (t)*target.posX + (1.0-t)*oldPosX;
                  y = (t)*target.posY + (1.0-t)*oldPosY;
                  z = (t)*target.posZ + (1.0-t)*oldPosZ;
      }
      setPosition(x, y+target.getEyeHeight(), z);
      setRotation(yaw, pitch);
      }
      
      private float MathHelper(float rotationYaw, float rotationYaw2) {
      // TODO Auto-generated method stub
      return 0;
      }
      
      public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8)
          {
              float f2 = net.minecraft.util.MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
              par1 /= (double)f2;
              par3 /= (double)f2;
              par5 /= (double)f2;
              par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
              par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
              par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8;
              par1 *= (double)par7;
              par3 *= (double)par7;
              par5 *= (double)par7;
              this.motionX = par1;
              this.motionY = par3;
              this.motionZ = par5;
              float f3 = net.minecraft.util.MathHelper.sqrt_double(par1 * par1 + par5 * par5);
              this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI);
              this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI);
          }
      
      private void setIsReturning() {
      oldPosX = posX;
      oldPosY = posY;
      oldPosZ = posZ;
      float oldYaw = rotationYaw;
      float oldPitch = rotationPitch;
      startCam(Minecraft.getMinecraft().thePlayer, false, 20);
      setPosition(oldPosX, oldPosY, oldPosZ);
      setRotation(oldYaw, oldPitch);
      startedReturningTime = System.currentTimeMillis();
      isReturning = true;
      EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
              target = player;
              desactivateGreenScreenShader();
      }
      
      @Override
      public void onEntityUpdate() {
      super.onEntityUpdate();
      
      if (!enabled)
      return;
      
      if (target.isDead && target instanceof EntityVisibombAmmo)
      {
      //    target.isDead = false;
      //    setIsReturning();
      }
      
      /*
      * if (!isReturning) { // if (target !=
      * Minecraft.getMinecraft().thePlayer) { // setIsReturning(); // } else
      * { // stopCam(); // return; // } // }
      */
      if (maxLife < 0 || despawnDelay < 0) {
      if (target != Minecraft.getMinecraft().thePlayer) {
      setIsReturning();
      } else {
      if(Minecraft.getMinecraft().thePlayer.getDistanceSqToEntity(this) <= 2)
         stopCam();
      }
      } else if (target.isDead) {
         setIsReturning();
      // stopCam();
      return;
      } else {
      –maxLife;
      }
      
      if (isReturning) 
      {
      EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
      // if (Math.abs(posX - player.posX) < 1
      // && Math.abs(posY - player.posY) < 1
      // && Math.abs(posZ - player.posZ) < 1) {
      // isReturning = false;
      // stopCam();
      // }
      if(System.currentTimeMillis()-startedReturningTime > maxReturnTime)
      {
         stopCam();
      }
      
      }
      
      doCameraMove();
      
      motionX = motionY = motionZ = 0;
      }
      
      @Override
      public boolean isEntityInvulnerable() {
      return true;
      }
      
      @Override
      protected boolean canTriggerWalking() {
      return false;
      }
      
      @Override
      public boolean canBeCollidedWith() {
      return false;
      }
      
      @Override
      public boolean canBePushed() {
      return false;
      }
      
      /* ===== Don't save the entity ===== */
      @Override
      public void writeEntityToNBT(NBTTagCompound tagCompound) {
      }
      
      @Override
      public void readEntityFromNBT(NBTTagCompound tagCompound) {
      }
      }
      
      ​package morehealth;
      
      import net.minecraft.block.Block;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.world.World;
      
      public class ItemRcWeap extends Item{
      
      protected int ammoPrice;
      protected int maxAmmo;
      protected int heldType;
      public boolean useAmmo;
      public boolean useTargetingSystem;
      
      public String weaponName;
      
      /**
      * Used to say that the item uses its own crosshair. No need to use hideCrossair if using this.
      */
      public boolean hasCrosshair;
      public String crosshairPath;
      
      /**
      * Used to hide the vanilla crosshair, without using a crosshair ( Pyrocitor )
      */
      public boolean hideCrosshair;
      
      public boolean hasAmmoImage;
      public String ammoTexturePath;
      
      public ItemRcWeap() {
      super();
      this.heldType = 0;
      this.setMaxDamage(maxAmmo);
      this.maxStackSize = 1;
      this.useAmmo = true;
      this.useTargetingSystem = false;
      this.hasCrosshair = false;
      this.hideCrosshair = false;
      this.hasAmmoImage = false;
      }
      
      public int getPrice(){
      return ammoPrice;
      }
      
      public boolean canHarvestBlock(Block par1Block) {
      return false;
      }
      
      public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) {
      return 0.0f;
      }
      
      public void onUpdate(ItemStack stack, World w, Entity ent, int i,
      boolean flag) {
      
      }
      
      public void onPlayerStoppedUsing(ItemStack stack, World w,
      EntityPlayer player, int i) {
      }
      
      public String getAmmoImageTexturePath(){
      if(this.hasAmmoImage){
      return "textures/gui/ammoImage/ammoImage_" + this.weaponName + ".png";
      } else {
      return null;
      }
      }
      
      public String getCrosshairImagePath(){
      if(this.hasCrosshair){
      return "textures/gui/crosshair/crosshair_" + this.weaponName + ".png";
      } else {
      return null;
      }
      }
      
      /**
      * This method returns an int
      * If it returns 0, the item is held normally
      * If it returns 1, the item is held like a bow
      * @return the held type
      */
      public int getHeldType(){
      return heldType;
      }
      
      public boolean isUsingAmmo() {
      return useAmmo;
      }
      }
      
      ​package morehealth;
      
      import morehealth.EntityVisibombAmmo;
      import net.minecraft.block.Block;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.world.World;
      
      public class ItemVisibombGun extends ItemRcWeap
      {
      
      private int cooldown;
      
      public ItemVisibombGun() {
      super();
      this.ammoPrice = 0;
      this.maxAmmo = 20;
      this.weaponName = "visibomb";
      this.hasAmmoImage = true;
      this.hideCrosshair = true;
      this.heldType = 1;
      this.setMaxDamage(maxAmmo);
      }
      
      public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
      EntityPlayer par3EntityPlayer) {
      if (maxAmmo - par1ItemStack.getItemDamage() > 0) {
      if (!par2World.isRemote) {
      if (cooldown <= 0) {
      par2World.spawnEntityInWorld(new EntityVisibombAmmo(par2World, par3EntityPlayer));
      par1ItemStack.damageItem(1, par3EntityPlayer);
      cooldown = 200;
      par3EntityPlayer.swingItem();
      }
      }
      }
      return par1ItemStack;
      }
      
      public boolean canHarvestBlock(Block par1Block) {
      return false;
      }
      
      public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) {
      return 0.0f;
      }
      
      public void onUpdate(ItemStack par1ItemStack, World par2World,Entity par3Entity, int par4, boolean par5) 
      {
      if (cooldown >= 1) {
      cooldown--;
      }
      }
      }
      

      Voila, je ne voie pas pourquoi sa ne marche pas

      sa devrai faire sa https://www.youtube.com/watch?v=cdkBb6L58kg

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

      MINECRAFT FORGE FRANCE © 2018

      Powered by NodeBB