@Override
  public void onPlayerStoppedUsing(
      ItemStack weapon, World world, EntityPlayer entityPlayer, int time) {
    if (world.isRemote) {
      int maxCount = getShotCount(weapon, entityPlayer);
      int timeElapsed = (getMaxItemUseDuration(weapon) - time);
      int count = Math.max(1, (int) ((1f - (timeElapsed / (float) MAX_CHARGE_TIME)) * maxCount));
      float shotPercent = count / (float) getShotCount(weapon, entityPlayer);

      ItemRenderPlasmaShotgun.RECOIL_AMOUNT =
          15
              + (maxCount - count) * 2
              + getAccuracy(weapon, entityPlayer, isWeaponZoomed(entityPlayer, weapon)) * 2;
      ItemRenderPlasmaShotgun.RECOIL_TIME = 1 + (maxCount - count) * 0.03f;
      Minecraft.getMinecraft().renderViewEntity.hurtTime = 15 + (maxCount - count);
      Minecraft.getMinecraft().renderViewEntity.maxHurtTime = 30 + (maxCount - count);
      Vec3 dir = entityPlayer.getLook(1);
      Vec3 pos = getFirePosition(entityPlayer, dir, Mouse.isButtonDown(1));
      WeaponShot shot = createShot(weapon, entityPlayer, Mouse.isButtonDown(1));
      shot.setCount(count);
      shot.setAccuracy(shot.getAccuracy() * shotPercent);
      shot.setRange(shot.getRange() + (int) (shot.getRange() * (1 - shotPercent)));
      onClientShot(weapon, entityPlayer, pos, dir, shot);
      MatterOverdrive.packetPipeline.sendToServer(
          new PacketFirePlasmaShot(entityPlayer.getEntityId(), pos, dir, shot));
      addShootDelay(weapon);
      stopChargingSound();
      entityPlayer.clearItemInUse();
    }
  }
Esempio n. 2
0
 @SubscribeEvent
 public void onPlayerTick(TickEvent.PlayerTickEvent event) {
   if (event.player == player) {
     for (EntityPlayer player1 : player.worldObj.playerEntities) {
       boolean pokemob;
       PokeInfo info = proxy.getMap().get(player.getUniqueID());
       if (info == null) {
         proxy.getPokemob(player);
         info = proxy.getMap().get(player.getUniqueID());
         pokemob = info != null;
         pokemob = pokemob && player.getEntityData().getBoolean("isPokemob");
       } else {
         pokemob = player.getEntityData().getBoolean("isPokemob");
       }
       PacketBuffer buffer = new PacketBuffer(Unpooled.buffer(6));
       MessageClient message = new MessageClient(buffer);
       buffer.writeByte(MessageClient.SETPOKE);
       buffer.writeInt(player1.getEntityId());
       buffer.writeBoolean(pokemob);
       if (pokemob) {
         buffer.writeFloat(info.originalHeight);
         buffer.writeFloat(info.originalWidth);
         buffer.writeNBTTagCompoundToBuffer(player1.getEntityData().getCompoundTag("Pokemob"));
       }
       PokecubeMod.packetPipeline.sendTo(message, (EntityPlayerMP) player);
       MinecraftForge.EVENT_BUS.unregister(this);
     }
   }
 }
Esempio n. 3
0
 public S0APacketUseBed(
     EntityPlayer p_i45210_1_, int p_i45210_2_, int p_i45210_3_, int p_i45210_4_) {
   this.field_149095_b = p_i45210_2_;
   this.field_149096_c = p_i45210_3_;
   this.field_149094_d = p_i45210_4_;
   this.field_149097_a = p_i45210_1_.getEntityId();
 }
Esempio n. 4
0
 @SubscribeEvent
 public void playerJoinWorld(EntityJoinWorldEvent event) {
   if (event.entity instanceof EntityPlayer) {
     EntityPlayer player = (EntityPlayer) event.entity;
     if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
       EventHandlerEntity.syncSchedule.add(player.getEntityId());
       syncAllAugmentsToClient(player);
     }
   }
 }
 @Override
 public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
   if (entity instanceof EntityLivingBase) {
     EntityInfo.instance()
         .set(
             player.getEntityId(),
             DataType.DiamondSwordAttack,
             ((EntityLivingBase) entity).getHealth());
   }
   return super.onLeftClickEntity(stack, player, entity);
 }
Esempio n. 6
0
 @SubscribeEvent
 public void pokemobMoveMessage(MoveMessageEvent evt) {
   Entity user = (Entity) evt.sender;
   if (user.getEntityData().getBoolean("isPlayer") && !user.worldObj.isRemote) {
     Entity e = user.worldObj.getEntityByID(user.getEntityId());
     if (e instanceof EntityPlayer) {
       EntityPlayer owner = (EntityPlayer) e;
       PacketBuffer buffer = new PacketBuffer(Unpooled.buffer(10));
       buffer.writeByte(PokecubeClientPacket.MOVEMESSAGE);
       buffer.writeInt(owner.getEntityId());
       try {
         buffer.writeChatComponent(evt.message);
       } catch (IOException e1) {
         e1.printStackTrace();
       }
       PokecubeClientPacket mess = new PokecubeClientPacket(buffer);
       PokecubePacketHandler.sendToClient(mess, (EntityPlayer) owner);
     }
   }
 }
Esempio n. 7
0
 private void drawSkillGet(int scaledWidth, int scaledHeight) {
   if (player.skillJustLearnt != null) {
     if (skillGetTimer-- > 0) {
       GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F);
       bind(GuiKnownSkills.GUI);
       drawTexturedModalRect(
           scaledWidth - 150,
           (scaledHeight - 32) / 2 + (skillGetTimer % 50) - 50,
           0,
           152,
           104,
           32);
       GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
       bind(player.skillJustLearnt.getTexture());
       GL11.glScalef(0.0625F, 0.0625F, 1F);
       drawTexturedModalRect(
           (scaledWidth - 140) * 16,
           ((scaledHeight - 16) / 2 + (skillGetTimer % 50) - 50) * 16,
           0,
           0,
           256,
           256);
       GL11.glScalef(16F, 16F, 1F);
       game.fontRendererObj.drawStringWithShadow(
           "Skill Acquired:",
           scaledWidth - 120,
           (scaledHeight - 17) / 2 + (skillGetTimer % 50) - 50,
           -256);
       game.fontRendererObj.drawStringWithShadow(
           player.skillJustLearnt.getName(),
           scaledWidth - 120,
           (scaledHeight + 3) / 2 + (skillGetTimer % 50) - 50,
           player.skillJustLearnt.getNameColour());
     } else {
       player.skillJustLearnt = null;
       SkillPacket pkt = new LearnSkillPacket(thePlayer.getEntityId(), null);
       SkillAPI.channels.get(pkt.getChannel()).sendToServer(pkt.getPacket(Side.SERVER));
       skillGetTimer = 50;
     }
   }
 }
 public static void sendItemNamePacket(
     World worldObj, int x, int y, int z, String s, EntityPlayer player) {
   ByteBuf buf = Unpooled.buffer();
   ByteBufOutputStream out = new ByteBufOutputStream(buf);
   try {
     out.writeByte(1);
     out.writeInt(worldObj.provider.dimensionId);
     out.writeInt(x);
     out.writeInt(y);
     out.writeInt(z);
     out.writeUTF(s);
     out.writeInt(player.getEntityId());
   } catch (IOException e) {
   }
   FMLProxyPacket packet = new FMLProxyPacket(buf, "steamcraft");
   Steamcraft.channel.sendToServer(packet);
   try {
     out.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
 public static void sendGrapplePacket(EntityPlayer player, int x, int y, int z) {
   ByteBuf buf = Unpooled.buffer();
   ByteBufOutputStream out = new ByteBufOutputStream(buf);
   try {
     out.writeByte(5);
     out.writeInt(player.worldObj.provider.dimensionId);
     out.writeInt(player.getEntityId());
     out.writeInt(x);
     out.writeInt(y);
     out.writeInt(z);
     out.writeDouble(player.posX);
     out.writeDouble(player.posY);
     out.writeDouble(player.posZ);
   } catch (IOException e) {
   }
   FMLProxyPacket packet = new FMLProxyPacket(buf, "steamcraft");
   Steamcraft.channel.sendToServer(packet);
   try {
     out.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
 public PacketQuestActions(int command, int questID, EntityPlayer entityPlayer) {
   this.command = command;
   this.questID = questID;
   this.playerID = entityPlayer.getEntityId();
 }
Esempio n. 11
0
 public PacketMGMount(EntityPlayer player, EntityMG mg, boolean mounting) {
   playerEntityId = player.getEntityId();
   mgEntityId = mg.getEntityId();
   this.mounting = mounting;
 }