示例#1
0
    public void enterState() {
      SwingSilencer silencer = getItem().getAction("SwingSilencer");
      if (silencer != null) {
        silencer.active = false;
      }
      EntityPlayer player = getPlayer();
      player.swingItem();

      if (!isRemote()) {
        Vec3 vec1 =
            Vec3.createVectorHelper(player.posX, player.posY + player.eyeHeight, player.posZ);
        Vec3 vec2 = VecUtils.add(vec1, VecUtils.multiply(player.getLookVec(), 1.5));
        MovingObjectPosition ret =
            Raytrace.perform(player.worldObj, vec1, vec2, EntitySelectors.excludeOf(player));
        if (ret != null && ret.typeOfHit == MovingObjectType.ENTITY) {
          ret.entityHit.attackEntityFrom(DamageSource.causePlayerDamage(player), stockDamage);
          player.worldObj.playSoundAtEntity(player, "dawn47:weapons.stock_attack", 0.5f, 1.0f);
        } else player.worldObj.playSoundAtEntity(player, "dawn47:weapons.stock_swing", 0.5f, 1.0f);
      }
    }
示例#2
0
 public void leaveState() {
   SwingSilencer silencer = getItem().getAction("SwingSilencer");
   if (silencer != null) {
     silencer.active = true;
   }
 }